chishui commented on code in PR #16836:
URL: https://github.com/apache/lucene/pull/16836#discussion_r4310951528


##########
lucene/core/src/java/org/apache/lucene/util/compress/LZ4.java:
##########
@@ -147,6 +147,95 @@ public static int decompress(DataInput compressed, int 
decompressedLen, byte[] d
     return dOff;
   }
 
+  /**
+   * Same as {@link #decompress(DataInput, int, byte[], int)}, but reads the 
compressed bytes from
+   * {@code compressed[cOff:cOff+cLen]}. Reading from a heap array avoids the 
per-byte overhead of
+   * {@link DataInput#readByte()}, which dominates decompression when the 
input is an {@code
+   * IndexInput}.
+   */
+  public static int decompress(

Review Comment:
   I ran a benchmark and the performance of using `ByteArrayDataInput` is worse
   ```
   
┌────────────────────┬───────────────┬────────────────────┬─────────────────────────────────┐
   │      docType       │   benchmark   │ ByteArrayDataInput │ 
ByteArrayDataInput & IndexInput │
   
├────────────────────┼───────────────┼────────────────────┼─────────────────────────────────┤
   │ text               │ randomAccess  │ +6.8%              │ +15.6% (223.6 → 
258.5 µs)       │
   
├────────────────────┼───────────────┼────────────────────┼─────────────────────────────────┤
   │ text               │ mergeInstance │ +1.2%              │ +14.0%           
               │
   
├────────────────────┼───────────────┼────────────────────┼─────────────────────────────────┤
   │ sparse_vector_json │ randomAccess  │ +5.7%              │ +20.3% (334.2 → 
402.1 µs)       │
   
├────────────────────┼───────────────┼────────────────────┼─────────────────────────────────┤
   │ sparse_vector_json │ mergeInstance │ +6.1%              │ +18.4%           
               │
   
└────────────────────┴───────────────┴────────────────────┴─────────────────────────────────┘
   note: LZ4.decompress(DataInput) also decodes blocktree terms and doc values 
from an IndexInput
   ```
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to