uchiha-asha opened a new pull request, #17029: URL: https://github.com/apache/lucene/pull/17029
Since #16141, `ConstantScoreBulkScorer` loads matches of plain iterators into a 4096-doc bit-set window via `intoBitSet` and collects the window as a `DocIdStream`. 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 collects plain iterators one doc at a time while matches are sparse, and switches to windows once 32 matches fall within one window. After a window, it goes back to one-by-one collection if the window had fewer than 32 matches. It checks this when the next match is at least 512 docs past the window, and in any case every 8 windows. Benchmarks: new JMH benchmarks (not part of this PR), baseline and patched lucene-core swapped on identical indexes, 3 forks x 5 iterations, 2 GB heap, JDK 25.0.5, a shared 4-vCPU cloud VM without CPU isolation. | Workload (4M docs, 1 segment) | Baseline | Patched | Change | |---|---:|---:|---:| | Term filter, 1 in 1,000, collector reads a doc value per hit | 195.5 ± 16.6 µs | 40.1 ± 4.4 µs | -80% | | Term filter, 1 in 10,000, same collector | 33.9 ± 2.6 µs | 6.5 ± 0.5 µs | -81% | | Term filter, 1 in 256, count only | 79.1 ± 12.0 µs | 73.1 ± 11.4 µs | -8% (noise) | | Point range, 1 in 1,000, doc value per hit | 230.9 ± 19.9 µs | 70.2 ± 5.2 µs | -70% | | 64 adjacent matches, then 1 match every 4,096 docs, count | 33.2 ± 3.4 µs | 8.6 ± 1.1 µs | -74% | | Term filter, 1 in 50 (dense enough for windows), doc value per hit | 1713 ± 283 µs | 1538 ± 79 µs | -10% (noise) | -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
