Combine all postings enum impls of the default codec into a single class (#14033)

Recent speedups by making call sites bimorphic made me want to play with combining all postings enums and impacts enums of the default codec into a single class, in order to reduce polymorphism. Unfortunately, it does not yield a speedup since the major polymorphic call sites we have that hurt performance (DefaultBulkScorer, ConjunctionDISI) are still 3-polymorphic or more.

Yet, reduced polymorphism at little performance impact is a good trade-off as it would help make call sites bimorphic for users who don't have as much query diversity as nightly benchmarks, or in the future when we remove other causes of polymorphism.
This commit is contained in:
Adrien Grand 2024-12-04 15:19:41 +01:00
parent 17bd129cea
commit 05ed6ebd3b
4 changed files with 454 additions and 1131 deletions

View File

@ -34,6 +34,9 @@ Improvements
segments for merges below the floor segment size, even if maxMergeAtOnce is
bigger than segsPerTier. (Adrien Grand)
* GITHUB#14033: Combine all postings enum impls of the default codec into a
single class. (Adrien Grand)
Optimizations
---------------------

View File

@ -399,7 +399,7 @@ public class PhraseQuery extends Query {
/**
* A guess of the average number of simple operations for the initial seek and buffer refill per
* document for the positions of a term. See also {@link
* Lucene101PostingsReader.BlockImpactsPostingsEnum#nextPosition()}.
* Lucene101PostingsReader.BlockPostingsEnum#nextPosition()}.
*
* <p>Aside: Instead of being constant this could depend among others on {@link
* Lucene101PostingsFormat#BLOCK_SIZE}, {@link TermsEnum#docFreq()}, {@link
@ -410,9 +410,8 @@ public class PhraseQuery extends Query {
private static final int TERM_POSNS_SEEK_OPS_PER_DOC = 128;
/**
* Number of simple operations in {@link
* Lucene101PostingsReader.BlockImpactsPostingsEnum#nextPosition()} when no seek or buffer refill
* is done.
* Number of simple operations in {@link Lucene101PostingsReader.BlockPostingsEnum#nextPosition()}
* when no seek or buffer refill is done.
*/
private static final int TERM_OPS_PER_POS = 7;

View File

@ -261,7 +261,7 @@ class TermIntervalsSource extends IntervalsSource {
/**
* A guess of the average number of simple operations for the initial seek and buffer refill per
* document for the positions of a term. See also {@link
* Lucene101PostingsReader.EverythingEnum#nextPosition()}.
* Lucene101PostingsReader.BlockPostingsEnum#nextPosition()}.
*
* <p>Aside: Instead of being constant this could depend among others on {@link
* Lucene101PostingsFormat#BLOCK_SIZE}, {@link TermsEnum#docFreq()}, {@link
@ -272,7 +272,7 @@ class TermIntervalsSource extends IntervalsSource {
private static final int TERM_POSNS_SEEK_OPS_PER_DOC = 128;
/**
* Number of simple operations in {@link Lucene101PostingsReader.EverythingEnum#nextPosition()}
* Number of simple operations in {@link Lucene101PostingsReader.BlockPostingsEnum#nextPosition()}
* when no seek or buffer refill is done.
*/
private static final int TERM_OPS_PER_POS = 7;