lucene icon indicating copy to clipboard operation
lucene copied to clipboard

Reduce some unnecessary ArrayUtil#grow calls

Open easyice opened this issue 1 year ago • 0 comments

This change will slightly improve the performance of DataOutput#writeGroupVInts and some other methods related to XXXRefBuilder#append.

Here is a JMH benchmark for Util.toIntsRef, using java 21 on my MAC (intel chip).

Benchmark                    Mode  Cnt   Score   Error   Units
PR   ToIntsRefBenchMark.run  thrpt    5  38.208 ± 1.054  ops/us
main ToIntsRefBenchMark.run  thrpt    5   7.862 ± 0.832  ops/us

JMH benchmark code for Util#toIntsRef:

public class ToIntsRefBenchMark {
  IntsRefBuilder intsRefBuilder = new IntsRefBuilder();
  BytesRef bytesRef = new BytesRef(new byte[32]);

  @Benchmark
  public void run() {
    Util.toIntsRef(bytesRef, intsRefBuilder);
  }
}

easyice avatar Mar 09 '24 12:03 easyice