lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley (JIRA)" <>
Subject [jira] Commented: (LUCENE-639) [PATCH] Slight performance improvement for readVInt() of IndexInput
Date Thu, 03 Aug 2006 17:10:15 GMT
    [ ] 
Yonik Seeley commented on LUCENE-639:

OK, I had a bug in Vint2a... correcting it makes it slower than Vint2 on Java6 (at least on
a P4).  But VInt2a is still slightly faser on the Opteron w/ Java5.

You might want to try this version also:

class VInt2 extends VInt {
  public int readVInt() throws IOException {
    byte b = readByte();
    if (b>=0) return b;
    b &= 0x7f;
    byte b2 = readByte();
    if (b2>=0) return (b2<<7) | b;
    b2 &= 0x7f;
    byte b3 = readByte();
    if (b3>=0) return (b3<<14) | (b2<<7) | b;
    b3 &= 0x7f;
    byte b4 = readByte();
    if (b4>=0) return (b4<<21) | (b3<<14) | (b2<<7) | b;
    b4 &= 0x7f;
    byte b5 = readByte();
    return (b5<<28) | (b4<<21) | (b3<<14) | (b2<<7) | b;

For a random distribution of vints less than 200 only, times in miliseconds:
P4, Java6 -server -Xbatch: VInt2=15833  VInt2a=17425  XOR=15583  Lucene=16900
P4, Java5 -server -Xbatch: VInt2=16063 VInt2a=16060  XOR=18097 Lucene=16108
Opteron, Java5 -server -Xbatch: VInt2=13441 VInt2a=13123  XOR=13110  Lucene=13626
Opteron, Java5 -server: VInt2=26589 VInt2a=26050 XOR=26484 Lucene=28718  (double the iterations)

In general, XOR looks good, except for Java5 on P4 for some reason, where it is 12.5% slower.
*But* when -Xbatch isn't used, the results change on the Opteron oddly enough!

> [PATCH] Slight performance improvement for readVInt() of IndexInput
> -------------------------------------------------------------------
>                 Key: LUCENE-639
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Index
>    Affects Versions: 2.0.0
>            Reporter: Johan Stuyts
>            Priority: Minor
>         Attachments: Lucene2ReadVIntPerformance.patch, readVInt performance results.pdf,
> By unrolling the loop in readVInt() I was able to get a slight, about 1.8 %, performance
improvement for this method. The test program invoked the method over 17 million times on
each run.
> I ran the performance tests on:
> - Windows XP Pro SP2
> - Sun JDK 1.5.0_07
> - YourKit 5.5.4
> - Lucene trunk

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message