Repository navigation
Collect sparse constant-score iterators one doc at a time - #17029
uchiha-asha wants to merge 5 commits into
Conversation
|
@romseygeek @costin could you please review this when available. Thanks! |
|
Thanks for opening @uchiha-asha! I wonder if we can get similar performance by checking the cost() of the filter upfront, rather than trying to switch between collection modes? I think I'd also like to see an end-to-end https://github.com/mikemccand/luceneutil benchmark. |
|
Thanks @romseygeek. I reran the same JMH benchmarks again after choosing Times are µs/op, lower is better. JDK 25.0.5, 2 GB heap, 3 forks × 5 measured iterations on a shared VM.
I also ran luceneutil’s Because of the simpler implementation, I plan to switch this PR to the upfront |
jainankitk
left a comment
There was a problem hiding this comment.
Thanks @uchiha-asha for iterating.
I looked at whether we could do better than cost(), e.g. estimating density from the doc ID span of the matches. The first match is cheap to get, but DocIdSetIterator can't give us the last one without new API. docIDRunEnd() only helps for fully contiguous runs. Given your numbers, I agree with @romseygeek that the upfront cost() check is the best trade-off: simpler, and as fast or faster on most workloads. +1 to switching to it.
|
Thanks @jainankitk @romseygeek, I have made the change for cost() check, updated description and title. |
Since #16141,
ConstantScoreBulkScorerloads matches of plain iterators into a 4096-doc bit-set window viaintoBitSetand collects the window as aDocIdStream. Processing each window incurs fixed overhead even when it contains few matches. So, selective filters (a term or range matching 1 doc in 1000) pay the full window cost for a handful of docs.This change checks the iterator's
cost()up front. Plain iterators that are expected to match fewer than 1 doc in 128 (32 matches per window) are collected one doc at a time withDefaultBulkScorer, both inConstantScoreScorerSupplierand in the no-score filter path ofBooleanScorerSupplier.Benchmark - Times are µs/op, lower is better. JDK 25.0.5, 2 GB heap, 3 forks × 5 measured iterations on a shared VM.