iprithv opened a new pull request, #15868:
URL: https://github.com/apache/lucene/pull/15868

   ### 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.


-- 
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]

Reply via email to