easyice commented on PR #12782:
URL: https://github.com/apache/lucene/pull/12782#issuecomment-1806834098

   @jpountz You are right, recomputing the length is faster than table lookup, 
here is the benchmark when reading the ints, each value  will takes 4 bytes: 
   
   ```
   GroupVInt.readGroupVInt                  16  thrpt    5  11.822 ± 0.187  
ops/us
   GroupVInt.readGroupVInt                  32  thrpt    5   7.558 ± 0.209  
ops/us
   GroupVInt.readGroupVInt                  64  thrpt    5   3.556 ± 0.344  
ops/us
   GroupVInt.readGroupVInt                 128  thrpt    5   1.786 ± 0.145  
ops/us
   GroupVInt.readGroupVInt                 248  thrpt    5   0.972 ± 0.025  
ops/us
   GroupVInt.readGroupVIntWithoutTable      16  thrpt    5  19.787 ± 2.848  
ops/us
   GroupVInt.readGroupVIntWithoutTable      32  thrpt    5  10.162 ± 1.491  
ops/us
   GroupVInt.readGroupVIntWithoutTable      64  thrpt    5   5.141 ± 0.121  
ops/us
   GroupVInt.readGroupVIntWithoutTable     128  thrpt    5   2.247 ± 0.017  
ops/us
   GroupVInt.readGroupVIntWithoutTable     248  thrpt    5   1.183 ± 0.014  
ops/us
   GroupVInt.readVInt                       16  thrpt    5  12.679 ± 0.405  
ops/us
   GroupVInt.readVInt                       32  thrpt    5   6.519 ± 0.247  
ops/us
   GroupVInt.readVInt                       64  thrpt    5   3.218 ± 0.804  
ops/us
   GroupVInt.readVInt                      128  thrpt    5   1.762 ± 0.096  
ops/us
   GroupVInt.readVInt                      248  thrpt    5   0.887 ± 0.035  
ops/us
   ```
   
   But i found that the group-varint encoding is faster than vint only when the 
value takes up 4 bytes, here is the benchmark for reading 64 int values. 
`numBytesOfInt` is the bytes for an int value that will be taken :
   ```
   Benchmark                            (numBytesOfInt)  (size)   Mode  Cnt  
Score   Error   Units
   GroupVInt.readGroupVIntWithoutTable                1      64  thrpt    5  
5.099 ± 0.147  ops/us
   GroupVInt.readGroupVIntWithoutTable                2      64  thrpt    5  
4.982 ± 0.632  ops/us
   GroupVInt.readGroupVIntWithoutTable                3      64  thrpt    5  
5.194 ± 0.163  ops/us
   GroupVInt.readGroupVIntWithoutTable                4      64  thrpt    5  
4.923 ± 0.092  ops/us
   GroupVInt.readVInt                                 1      64  thrpt    5  
8.433 ± 0.287  ops/us
   GroupVInt.readVInt                                 2      64  thrpt    5  
6.309 ± 0.155  ops/us
   GroupVInt.readVInt                                 3      64  thrpt    5  
5.196 ± 0.213  ops/us
   GroupVInt.readVInt                                 4      64  thrpt    5  
3.300 ± 0.302  ops/us
   ```
   
   The decoding for group-varint takes up constant time. vint decoding is 
faster when the values take up fewer bytes.  so the actual payoff depends on 
factors like `maxDoc`.


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