Skip to content

Measure batched neighbor queue insertion - #1600

Draft
Wei Wu (wuw92) wants to merge 14 commits into
mainfrom
wuw92-beam-queue-benchmark
Draft

Wei Wu (wuw92) wants to merge 14 commits into
mainfrom
wuw92-beam-queue-benchmark

Conversation

@wuw92

@wuw92 Wei Wu (wuw92) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor
  • Does this PR have a descriptive title that could go in our release notes?
  • Does this PR add any new dependencies? No.
  • Does this PR modify any existing APIs? Includes the batch API from Optimize neighbor queue insertion with batched updates #1590.
  • Is the change to the API backwards compatible?
  • Should this result in any changes to our documentation, either updating existing docs or adding new ones? Includes batch API rustdoc and a reproducible benchmark input.

Reference Issues/PRs

Queue-only benchmarks for #1590. This PR is not intended to merge.

What does this implement/fix? Briefly explain your changes.

Compare per-item insert with fixed-capacity batch_insert using the same fixtures. Untimed verification compares the ordered IDs and distance bit patterns, the unvisited sequence, and buffer reuse against sequential insertion.

The workload covers 18 cases with different queue capacities, batch sizes, initial queue sizes, cutoff survivors, and candidate placements and orders. Fixture generation, queue reset, and candidate refill are outside the timer.

Any other comments?

Current results

Three-platform CI run: all three benchmark jobs passed. Benchmark head: 67deb5c1c5f4887bf4c9be275e0104e3942f42d4; measured CI merge: 588b3e1931e220d61d16a21931af0752dcdda7ea.

At L=2000/N=2000, batch_insert speedup over insert is 3.59x on Linux x64, 18.47x on Linux ARM64, 6.66x on Windows x64. Results depend on cutoff survivors, input order, placement, and queue occupancy. These measurements isolate queue updates, not end-to-end search speedups.

With L=20, N=64, and all candidates passing the initial cutoff, shuffled input is slower with batch_insert on all three platforms, both for full queues and for queues starting with 10 entries. Ascending and descending input are faster with batch_insert. Singleton results vary by platform.

Method and environment

Three independent processes per platform, 15 samples per process, eight shared fixtures, two blocks per sample, seed 20261113. Table values are medians over all 45 samples per method. Method order rotates. Fixture generation, queue reset, candidate refill, and verification are outside the timer.

At L=2000/N=2000, per-process speedup ratios range from 3.576-3.603x on Linux x64, 18.294-18.511x on Linux ARM64, 6.632-6.740x on Windows x64. Raw samples and all process medians are in the artifacts below.

All builds use Rust 1.97.1, LLVM 22.1.6, cargo build --locked --release -p diskann-benchmark, and the repository's target configuration. Each job builds once and reuses its binary for all three processes. Runners are shared VMs; elapsed times are reference measurements and can vary with VM load.

Platform CPU Logical CPUs
Linux x64 AMD EPYC 9V45 96-Core Processor 4
Linux ARM64 Neoverse-N2 4
Windows x64 AMD EPYC 9V45 96-Core Processor 4

Speedup is a ratio of pooled medians, not a median of paired ratios. Small timings are sensitive to timer resolution and process variation; a rounded 1.00x does not establish parity.

Full measurement table

Each cell is insert µs → batch_insert µs; speedup. Speedup is median(insert) / median(batch_insert), computed from unrounded samples: above 1x favors batch_insert; below 1x means a regression. N is the input candidate count. Cutoff survivors pass the initial queue cutoff; they are not necessarily retained in the final top-L.

L Initial N Cutoff survivors Placement/order Linux x64 Linux ARM64 Windows x64
20 20 1 1 uniform/shuffled 0.014 → 0.010; 1.38x 0.018 → 0.021; 0.84x 0.019 → 0.013; 1.50x
20 20 64 0 uniform/shuffled 0.096 → 0.014; 6.98x 0.152 → 0.040; 3.85x 0.138 → 0.019; 7.33x
20 20 64 1 uniform/shuffled 0.114 → 0.020; 5.68x 0.175 → 0.051; 3.39x 0.144 → 0.025; 5.75x
20 20 64 8 uniform/shuffled 0.181 → 0.074; 2.43x 0.276 → 0.119; 2.31x 0.237 → 0.081; 2.92x
20 20 64 64 uniform/shuffled 0.316 → 0.510; 0.62x 0.483 → 0.682; 0.71x 0.425 → 0.631; 0.67x
20 20 64 64 uniform/ascending 0.341 → 0.199; 1.71x 0.336 → 0.200; 1.68x 0.331 → 0.188; 1.77x
20 20 64 64 uniform/descending 0.819 → 0.137; 5.98x 0.951 → 0.179; 5.30x 0.875 → 0.181; 4.83x
20 10 64 64 uniform/shuffled 0.416 → 0.514; 0.81x 0.574 → 0.693; 0.83x 0.525 → 0.644; 0.82x
64 64 64 1 uniform/shuffled 0.116 → 0.024; 4.89x 0.184 → 0.064; 2.88x 0.194 → 0.050; 3.88x
64 64 64 8 uniform/shuffled 0.181 → 0.120; 1.51x 0.361 → 0.161; 2.25x 0.281 → 0.144; 1.96x
64 64 64 32 uniform/shuffled 0.372 → 0.329; 1.13x 0.832 → 0.462; 1.80x 0.562 → 0.419; 1.34x
64 64 64 8 head/shuffled 0.224 → 0.058; 3.84x 0.367 → 0.110; 3.34x 0.338 → 0.100; 3.38x
64 64 64 8 tail/shuffled 0.175 → 0.023; 7.74x 0.429 → 0.054; 7.95x 0.206 → 0.025; 8.25x
200 200 64 8 uniform/shuffled 0.228 → 0.168; 1.36x 0.723 → 0.225; 3.21x 0.319 → 0.188; 1.70x
200 200 64 64 uniform/shuffled 1.022 → 0.909; 1.12x 3.888 → 1.241; 3.13x 1.469 → 0.950; 1.55x
2000 2000 1 1 uniform/shuffled 0.138 → 0.138; 1.01x 0.743 → 0.745; 1.00x 0.194 → 0.200; 0.97x
2000 2000 64 8 uniform/shuffled 0.991 → 0.422; 2.35x 4.841 → 0.840; 5.77x 1.769 → 0.562; 3.14x
2000 2000 2000 2000 uniform/shuffled 157.674 → 43.964; 3.59x 825.283 → 44.690; 18.47x 296.081 → 44.450; 6.66x

Run

From this PR's checkout, run the 18-case workload without a dataset (PowerShell):

cargo build --locked --release -p diskann-benchmark
1..3 | ForEach-Object {
  .\target\release\diskann-benchmark.exe run `
    --input-file .\diskann-benchmark\example\neighbor-queue.json `
    --output-file "run-$_.json"
}
python .github\scripts\summarize_neighbor_queue.py run-1.json run-2.json run-3.json

The summary script reports batch_insert / insert; values below 1 favor batching. Edit neighbor-queue.json to change workload parameters. To reproduce the measured build, use the CI merge revision identified above.

Raw results

Artifacts contain the environment, three raw result files, logs, and per-process medians. Downloads are retained for 30 days:

Wei Wu (wuw92) and others added 2 commits November 13, 2026 19:55
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@wuw92
Wei Wu (wuw92) force-pushed the wuw92-beam-queue-benchmark branch from 1387514 to ba0b492 Compare November 13, 2026 11:55
@wuw92
Wei Wu (wuw92) force-pushed the wuw92-beam-queue-batching branch from da80f17 to 25e8b68 Compare November 13, 2026 11:55
@wuw92 Wei Wu (wuw92) changed the title Benchmark neighbor queue append vs insert Measure batched neighbor queue insertion Nov 13, 2026
@wuw92
Wei Wu (wuw92) changed the base branch from wuw92-beam-queue-batching to main November 13, 2026 12:47
Wei Wu (wuw92) and others added 2 commits November 13, 2026 20:57
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.17148% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.26%. Comparing base (dd896a3) to head (67deb5c).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
diskann-benchmark/src/neighbor_queue.rs 86.17% 52 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1600      +/-   ##
==========================================
+ Coverage   92.14%   92.26%   +0.12%     
==========================================
  Files         621      629       +8     
  Lines      130986   133398    +2412     
==========================================
+ Hits       120694   123082    +2388     
- Misses      10292    10316      +24     
Flag Coverage Δ
miri 92.26% <91.17%> (+0.12%) ⬆️
unittests 92.21% <91.17%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-benchmark/src/main.rs 94.08% <100.00%> (+0.01%) ⬆️
diskann/src/graph/index.rs 96.47% <100.00%> (-0.01%) ⬇️
diskann/src/graph/search/inline_filter_search.rs 98.14% <100.00%> (-1.38%) ⬇️
diskann/src/graph/search/multihop_filter_search.rs 100.00% <100.00%> (ø)
diskann/src/neighbor/queue.rs 99.13% <100.00%> (+0.19%) ⬆️
diskann-benchmark/src/neighbor_queue.rs 86.17% <86.17%> (ø)

... and 59 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Wei Wu (wuw92) and others added 10 commits November 19, 2026 17:11
Keep linear lookup as the default and allow binary lookup or a caller-configured size threshold for individual inserts and batch prefix lookup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep binary top-L partitioning, merge candidates backwards, and copy old runs in place without a separate lower-bound prefix lookup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep binary top-L partitioning, merge candidates backwards, and copy old runs in place without a separate lower-bound prefix lookup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use exponential probing and local binary lookup to locate contiguous old runs without scanning each old distance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve timer-resolution zeros, omit unresolved ratios, and reject negative or nonfinite measurements.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use stable descending candidate order and standard slice operations while preserving sequential insertion tie behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use insert when cutoff filtering leaves one candidate.
Find old-entry merge boundaries with a right-to-left exponential search.
Express old/new top-L selection as a partition point with explicit bounds.
Keep cursor updates and equal-distance ordering consistent with insert.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use 18 workload cases and 15 samples per process. Cover sparse cutoff survivors, input ordering, placement, and partial occupancy.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants