Introduce support for pruning and skipping to FirstPassGroupingCollector #15210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Extends the
FirstPassGroupingCollector
to support pruning (for numeric sort fields usingcompetitiveIterator
) and skipping of non-competitive documents (for relevance score sorting usingScorable#setMinCompetitiveScore
).Both optimizations are enabled automatically, thereby reducing the hit count of the collector if circumstances allow.
@jainankitk Are we fine with enabling this by default, or do we need this configurable (e.g. configurable hit threshold)?
Benchmark results using
luceneutils
for theTermBGroup1M
scenario (combines first and second pass grouping) using a modifiedwikimedium.10M.nostopwords.tasks
job. This scenario uses sort by relevance score.Running on
m6a.2xlarge
using Corretto 24:=> ~17% overall performance improvement (first+second pass).
@jpountz I'm getting some rare test failures for
TestGrouping
caused by theassert canSetMinCompetitiveScore
assertion inAssertingScorer#setMinCompetitiveScore
, even though theFirstPassGroupingCollector
usesScoreMode.TOP_SCORES
in all configurations when it callsScorable#setMinCompetitiveScore
. Is this a known issue?Reproduce with:
gradlew test --tests TestGrouping.testRandom -Dtests.seed=EC2EC279F564DD82 -Dtests.locale=de-AT -Dtests.timezone=America/St_Thomas -Dtests.asserts=true -Dtests.file.encoding=UTF-8
edit//Seems to be caused by the
Weight
that gets instantiated by the unit tests with eitherScoreMode.COMPLETE
orScoreMode.COMPLETE_NO_SCORES
regardless of the actual collectors. I updated the code to instantiate a newWeight
instance for every collector that is in line with the collectorScoreMode
.