LantaoJin opened a new pull request, #16739: URL: https://github.com/apache/lucene/pull/16739
### Description `IncrementalHnswGraphMerger#addReader` picks the base graph for a merge with `candidateVectorCount > largestGraphReader.graphSize`. The left side is the candidate's **live** vector count. The right side is the current base's **total** node count, which includes deleted nodes. Before #15003 the two were always equal, because graphs with deletions were never admitted as the base. Since #15003, a graph with up to 40% deletions can become the base, so the comparison mixes units. As a result, which graph becomes the base depends on the order in which readers are added. Example: segment A has 1000 nodes with 300 deleted (700 live), and segment B has 900 nodes with no deletions. If A is added first, B would need 900 > 1000 to replace it, so A stays the base even though B has more live vectors. If B is added first, B is chosen. The merged graph is still correct either way, so this is a performance issue, not a correctness issue. With a worse base, more nodes must be joined or inserted. This hurts most in `ConcurrentHnswMerger`, which initializes only from the base graph and inserts every other node one by one. `MergingHnswGraphBuilder` joins the other deletion-free graphs, so the effect there is smaller. The fix adds a `liveVectorCount` component to the `GraphReader` record and compares live against live. `graphSize` stays the total node count, because `getNewOrdMapping` uses it to size the old-to-new ordinal arrays. Ties still keep the earlier reader. `ConcurrentHnswMerger` inherits `addReader`, so it is covered too. `GraphReader` is a `protected` record, so adding a component changes its canonical constructor. Nothing in Lucene constructs it outside `IncrementalHnswGraphMerger`. -- 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]
