goankur opened a new pull request, #16956: URL: https://github.com/apache/lucene/pull/16956
**(Implemented using AI with human in the loop)** When a merge reuses the HNSW graph of its largest segment, `InitializedHnswGraphBuilder.copyAndPruneGraphStructure` copies that graph node by node and calls `scorer.setScoringOrdinal` for every node on every level. Nothing in the copy loop scores: neighbors are copied with a NaN score, and repair and rebalance set the ordinal themselves before they score. The call came in with #15003 and was never needed. It is not free. With the quantized merge scorer, `setScoringOrdinal` reads the node's query vector from the temporary query file, so copying an N-node graph reads N query vectors for nothing. This PR removes that one line. The copied graph does not change. Copying the 71M-node graph of one segment of a real index (4096 dims, 1-bit codes, maxConn 16), with the page cache dropped before each run: | query file read advice | main | this PR | speedup | |---|---|---|---| | RANDOM | 13.8 min | 1.3 min | 10.4x | | default | 3.2 min | 1.3 min | 2.4x | On main the copy made 76M `setScoringOrdinal` calls and read about 150 GB of query vectors; with this PR it makes none, and what is left is reading the graph itself. With the default read advice, kernel read-ahead hides part of that cost, because the copy reads the query file in ordinal order. With RANDOM advice, which a large merge may use to keep the query file from flooding the page cache, every read goes to disk. The benchmark is [GraphCopyBench.java](https://github.com/goankur/lucene/blob/eef003672b8c0ffb4fa1ee404ad0c7c1cad9c36f/dev-tools/graph-copy-bench/GraphCopyBench.java) on a separate branch. I can add it to the PR if reviewers want it. -- 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]
