Avoid unnecessary overhead in TopScoreDoc and TopField collector manager [LUCENE-10486]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
TopScoreDocCollector and TopFieldCollector expose a createSharedManager method that returns a collector manager for concurrent search, which relies on a shared global counter for hits counting as well as a shared max score accumulator.
As part of #11041 we are going to deprecate the ability to search providing a collector, in favour of using a corresponding collector manager. The above mentioned shared collector managers are great for concurrent searches, yet they add overhead when search is single threaded, which can be the case despite a collector manager is used. That is the case when an executor is not set to the index searcher, or when there's only one slice to be searched.
We could adapt the hits threshold checker as well as the max score accumulator depending on whether a search is effectively executed by multiple threads or not.
An additional idea along the same lines could be to introduce a new hits threshold checker for the case when totalHitsThreshold is set to Integer.MAX_VALUE, which does no counting at all. This could be safely used both in the single threaded as well as in the concurrent scenario.
---
Migrated from [LUCENE-10486](https://issues.apache.org/jira/browse/LUCENE-10486) by Luca Cavanna (@javanna), updated Apr 04 2022
Pull requests: https://github.com/apache/lucene/pull/769
Contributor guide
Research direction
Start by examining TopScoreDocCollector and TopFieldCollector, especially their createSharedManager methods, then review how single-slice or executor-free searches are handled. The linked pull request is PR 769; done means single-threaded searches avoid unnecessary shared hit-counting and max-score overhead while concurrent searches retain the shared behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100