jpountz commented on code in PR #13636:
URL: https://github.com/apache/lucene/pull/13636#discussion_r1709362066


##########
lucene/core/src/java/org/apache/lucene/internal/vectorization/DefaultPostingDecodingUtil.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.internal.vectorization;
+
+import java.io.IOException;
+import org.apache.lucene.store.IndexInput;
+
+final class DefaultPostingDecodingUtil extends PostingDecodingUtil {
+
+  protected final IndexInput in;
+
+  public DefaultPostingDecodingUtil(IndexInput in) {
+    this.in = in;
+  }
+
+  @Override
+  public void splitLongs(int count, long[] b, int bShift, long bMask, long[] 
c, long cMask)
+      throws IOException {
+    assert count <= 64;
+    in.readLongs(c, 0, count);
+    // The below loop is auto-vectorized
+    for (int i = 0; i < count; ++i) {
+      b[i] = (c[i] >>> bShift) & bMask;
+      c[i] &= cMask;

Review Comment:
   I tried a different approach that consists of only specializing 8 and 16. 
Otherwise, we keep applying the mask all, but then take advantage of the fact 
that this mask has been applied when decoding tail values using scalar code. 
This seems to yield a small performance improvement when the vector module is 
disabled and make performance similar to what it was before. This effectively 
generalizes the current optimization we have to all numbers of bits per value, 
so I removed the specialization.
   
   ```
   Benchmark                                      (bpv)   Mode  Cnt   Score   
Error   Units
   PostingIndexInputBenchmark.decode                  5  thrpt   15  34.857 ± 
0.678  ops/us
   PostingIndexInputBenchmark.decode                  6  thrpt   15  33.752 ± 
1.060  ops/us
   PostingIndexInputBenchmark.decode                  7  thrpt   15  28.966 ± 
4.743  ops/us
   PostingIndexInputBenchmark.decode                  8  thrpt   15  47.009 ± 
0.518  ops/us
   PostingIndexInputBenchmark.decode                  9  thrpt   15  28.328 ± 
0.978  ops/us
   PostingIndexInputBenchmark.decode                 10  thrpt   15  32.007 ± 
1.173  ops/us
   PostingIndexInputBenchmark.decodeAndPrefixSum      5  thrpt   15  18.161 ± 
0.244  ops/us
   PostingIndexInputBenchmark.decodeAndPrefixSum      6  thrpt   15  17.470 ± 
1.149  ops/us
   PostingIndexInputBenchmark.decodeAndPrefixSum      7  thrpt   15  16.907 ± 
1.788  ops/us
   PostingIndexInputBenchmark.decodeAndPrefixSum      8  thrpt   15  20.259 ± 
1.487  ops/us
   PostingIndexInputBenchmark.decodeAndPrefixSum      9  thrpt   15  14.214 ± 
0.521  ops/us
   PostingIndexInputBenchmark.decodeAndPrefixSum     10  thrpt   15  15.618 ± 
1.410  ops/us
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to