jainankitk commented on issue #12527:
URL: https://github.com/apache/lucene/issues/12527#issuecomment-1708857931

   @mikemccand - Thanks for sharing the numbers. This is truly surprising 
result. Even though the impact of this small change not positive, it is 
significant enough to explore areas of improvement on this. I am thinking of 
trying out couple of things below:
   
   - Update the patch to use scratch array similar to int, and rerun the 
benchmark:
   ```
   diff --git 
a/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java 
b/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java
   index 40db4c0069d..64ed9b84084 100644
   --- a/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java
   +++ b/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java
   @@ -35,9 +35,11 @@ final class DocIdsWriter {
      private static final byte LEGACY_DELTA_VINT = (byte) 0;
    
      private final int[] scratch;
   +  private final long[] scratchLong;
    
      DocIdsWriter(int maxPointsInLeaf) {
        scratch = new int[maxPointsInLeaf];
   +    scratchLong = new long[(maxPointsInLeaf / 8) * 3];
      }
    
      void writeDocIds(int[] docIds, int start, int count, DataOutput out) 
throws IOException {
   @@ -236,12 +238,14 @@ final class DocIdsWriter {
        }
      }
    
   -  private static void readInts24(IndexInput in, int count, int[] docIDs) 
throws IOException {
   +  private void readInts24(IndexInput in, int count, int[] docIDs) throws 
IOException {
   +    in.readLongs(scratchLong, 0, (count/8) * 3);
        int i;
        for (i = 0; i < count - 7; i += 8) {
   -      long l1 = in.readLong();
   -      long l2 = in.readLong();
   -      long l3 = in.readLong();
   +      int li = (i/8) * 3;
   +      long l1 = scratchLong[li];
   +      long l2 = scratchLong[li+1];
   +      long l3 = scratchLong[li+2];
          docIDs[i] = (int) (l1 >>> 40);
          docIDs[i + 1] = (int) (l1 >>> 16) & 0xffffff;
          docIDs[i + 2] = (int) (((l1 & 0xffff) << 8) | (l2 >>> 56));
   @@ -323,13 +327,15 @@ final class DocIdsWriter {
        }
      }
    
   -  private static void readInts24(IndexInput in, int count, IntersectVisitor 
visitor)
   +  private void readInts24(IndexInput in, int count, IntersectVisitor 
visitor)
          throws IOException {
   +    in.readLongs(scratchLong, 0, (count/8) * 3);
        int i;
        for (i = 0; i < count - 7; i += 8) {
   -      long l1 = in.readLong();
   -      long l2 = in.readLong();
   -      long l3 = in.readLong();
   +      int li = (i/8) * 3;
   +      long l1 = scratchLong[li];
   +      long l2 = scratchLong[li+1];
   +      long l3 = scratchLong[li+2];
          visitor.visit((int) (l1 >>> 40));
          visitor.visit((int) (l1 >>> 16) & 0xffffff);
          visitor.visit((int) (((l1 & 0xffff) << 8) | (l2 >>> 56)));
   ```
   
   - If the performance is still regressed after this, we can try removing the 
scratch array even for `readInts32`. Although, not sure if the benchmark has 
sufficient coverage for both types of docIds


-- 
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