diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index d83e82ee71ca..08014f638014 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -342,6 +342,10 @@ Optimizations * GITHUB#15607: Utilize bulk scoring for diversity checking when building HNSW vector indices. This results in some performance improvements during indexing and segment merges. (Ben Trent) +* GITHUB#15658: DisjunctionMaxBulkScorer now uses progressive window sizing sub-scorers to be skipped + sooner when their scores are no longer competitive (Shimpei Kodama) + + Bug Fixes --------------------- * GITHUB#14161: PointInSetQuery's constructor now throws IllegalArgumentException diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxBulkScorer.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxBulkScorer.java index e6dc70502709..413494d8090c 100644 --- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxBulkScorer.java +++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxBulkScorer.java @@ -46,6 +46,7 @@ private static class BulkScorerAndNext { private final float[] windowScores = new float[WINDOW_SIZE]; private final PriorityQueue scorers; private final SimpleScorable topLevelScorable = new SimpleScorable(); + private int currentWindowSize = 1; DisjunctionMaxBulkScorer(List scorers) { if (scorers.size() < 2) { @@ -64,7 +65,7 @@ public int score(LeafCollector collector, Bits acceptDocs, int min, int max) thr while (top.next < max) { final int windowMin = Math.max(top.next, min); - final int windowMax = MathUtil.unsignedMin(max, windowMin + WINDOW_SIZE); + final int windowMax = MathUtil.unsignedMin(max, windowMin + currentWindowSize); // First compute matches / scores in the window do { @@ -105,6 +106,10 @@ public void collect(int doc) throws IOException { collector.collect(doc); } + if (currentWindowSize < WINDOW_SIZE) { + currentWindowSize = Math.min(currentWindowSize << 1, WINDOW_SIZE); + } + // Finally clean up state windowMatches.clear(); Arrays.fill(windowScores, 0f);