Skip to content

Optimise DisjunctionMaxBulkScorer#15868

Open
iprithv wants to merge 1 commit intoapache:mainfrom
iprithv:optimize-disjunctionmax-bulkscorer
Open

Optimise DisjunctionMaxBulkScorer#15868
iprithv wants to merge 1 commit intoapache:mainfrom
iprithv:optimize-disjunctionmax-bulkscorer

Conversation

@iprithv
Copy link
Copy Markdown

@iprithv iprithv commented Mar 24, 2026

Description:

Made two optimisations here:

1. Reuse inner LeafCollector : The anonymous LeafCollector was allocated inside the inner do-while loop for every sub-scorer in every window. Moved to a reusable field (innerCollector), eliminating per-window allocations and GC pressure. Measured 4.3x faster in allocation microbenchmark.

2. Inline score reset during replay : Replaced Arrays.fill(windowScores, 0f) (which zeros all 4096 entries unconditionally) with windowScores[doc] = 0f inline during the replay loop. Since the replay already reads windowScores[doc], the reset piggybacks on the same cache line access at near-zero cost.

Benchmark evidence (window=4096, 200k iterations, best of 3):

Matches/Window OLD (replay + fill) NEW (inline reset) Speedup
10 272.0 ms 25.1 ms 10.83x
50 330.7 ms 84.7 ms 3.90x
100 405.3 ms 159.8 ms 2.54x
500 979.4 ms 742.4 ms 1.32x
1000 1683.7 ms 1443.8 ms 1.17x
4096 (full) 5521.0 ms 5352.8 ms 1.03x

Faster at ALL densities : never slower, even when fully saturated.

Precedent

For both I followed MaxScoreBulkScorer, which already uses selective score reset during its replay loop.

@github-actions github-actions bot added this to the 11.0.0 milestone Mar 24, 2026
@iprithv iprithv force-pushed the optimize-disjunctionmax-bulkscorer branch from 7f12860 to 50a3b97 Compare March 24, 2026 19:54
@iprithv iprithv force-pushed the optimize-disjunctionmax-bulkscorer branch from 50a3b97 to 7b7a68c Compare March 24, 2026 20:09
@iprithv
Copy link
Copy Markdown
Author

iprithv commented Mar 25, 2026

@uschindler would be great if you could take a look at this, thanks!

@uschindler
Copy link
Copy Markdown
Contributor

@uschindler would be great if you could take a look at this, thanks!

I can have a look, but I think @jpountz is the better one to look at this

Uwe

@uschindler uschindler requested a review from jpountz March 25, 2026 19:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Apr 9, 2026
@iprithv
Copy link
Copy Markdown
Author

iprithv commented Apr 9, 2026

sure thanks @uschindler, @jpountz, could you please help review this? Thanks!

@github-actions github-actions bot removed the Stale label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants