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
FirstPassGroupingCollectorto 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
luceneutilsfor theTermBGroup1Mscenario (combines first and second pass grouping) using a modifiedwikimedium.10M.nostopwords.tasksjob. This scenario uses sort by relevance score.Running on
m6a.2xlargeusing Corretto 24:=> ~17% overall performance improvement (first+second pass).
@jpountz I'm getting some rare test failures for
TestGroupingcaused by theassert canSetMinCompetitiveScoreassertion inAssertingScorer#setMinCompetitiveScore, even though theFirstPassGroupingCollectorusesScoreMode.TOP_SCORESin 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-8edit//Seems to be caused by the
Weightthat gets instantiated by the unit tests with eitherScoreMode.COMPLETEorScoreMode.COMPLETE_NO_SCORESregardless of the actual collectors. I updated the code to instantiate a newWeightinstance for every collector that is in line with the collectorScoreMode.