add bf_tree benchmark infrastructure#1106
Conversation
4201a33 to
1661985
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1106 +/- ##
==========================================
- Coverage 89.40% 89.38% -0.03%
==========================================
Files 485 485
Lines 92079 92199 +120
==========================================
+ Hits 82323 82408 +85
- Misses 9756 9791 +35
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
2981ffc to
c36e2a5
Compare
There was a problem hiding this comment.
Pull request overview
Adds bf_tree-backed benchmark support to diskann-benchmark (full-precision + spherical quantization; static + streaming variants) and updates diskann-bftree to address inplace-delete behavior and reduce per-call allocations in neighbor serialization.
Changes:
- Add a new
bftreeinput schema + backend benchmarks (static build/search and streaming runbook modes, including spherical quantization bit-width dispatch). - Add delete-time vector caching in
diskann-bftreeto support inplace-delete pruning after the underlying storage entries are removed. - Rework neighbor list serialization to avoid per-call heap allocations (stack buffer fast path).
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| diskann-bftree/src/quant.rs | Makes get_vector_sync available outside tests for delete-time caching. |
| diskann-bftree/src/provider.rs | Adds delete caches + accessor fallbacks for inplace-delete pruning; exposes clear_delete_caches(). |
| diskann-bftree/src/neighbors.rs | Switches neighbor serialization to a stack buffer fast path. |
| diskann-benchmark/src/inputs/mod.rs | Centralizes PRINT_WIDTH + write_field! for consistent summaries. |
| diskann-benchmark/src/inputs/graph_index.rs | Exposes IndexBuild helpers for reuse by bf_tree inputs. |
| diskann-benchmark/src/inputs/bftree.rs | New bf_tree input schemas (FP + spherical; static + streaming) and display/validation. |
| diskann-benchmark/src/backend/index/streaming/stats.rs | Adds a bf_tree-only GenericStats::noop() helper for skipped maintenance steps. |
| diskann-benchmark/src/backend/index/mod.rs | Registers bf_tree benchmarks behind the bftree feature. |
| diskann-benchmark/src/backend/index/bftree/mod.rs | New bf_tree benchmark module + shared streaming runner. |
| diskann-benchmark/src/backend/index/bftree/full_precision.rs | Implements bf_tree full-precision static + streaming benchmarks. |
| diskann-benchmark/src/backend/index/bftree/spherical.rs | Implements bf_tree spherical quantization static + streaming benchmarks. |
| diskann-benchmark/example/graph-index-bftree.json | Example config for bf_tree full-precision static build/search. |
| diskann-benchmark/example/graph-index-bftree-stream.json | Example config for bf_tree full-precision streaming runbook. |
| diskann-benchmark/example/graph-index-bftree-spherical.json | Example config for bf_tree spherical quantization static build/search. |
| diskann-benchmark/example/graph-index-bftree-spherical-stream.json | Example config for bf_tree spherical quantization streaming runbook. |
| diskann-benchmark/Cargo.toml | Adds bf_tree dependency + feature flag. |
| Cargo.toml | Adds diskann-bftree to workspace dependencies. |
| Cargo.lock | Locks in the new dependency edge. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b8cdc3a to
8b0469c
Compare
|
@copilot re-evaluate please |
Re-evaluated: you’re right, those |
0461814 to
cfddda1
Compare
hildebrandmw
left a comment
There was a problem hiding this comment.
Thanks Jordan, this is looking good!
1170fe8 to
3bf48a1
Compare
|
I'm not sure I fully understand the bug in deletion. Why do we need to keep the deleted vector around for pruning its neighbors? If it's in someone's neighbor list after deletion, it should be ignored during pruning. Is there some difference in how bf-tree handles this versus how in-mem providers handle this that meant deletes needed to be handled differently? |
|
I think posting some experiments with a more complicated runbook would be a good idea, it looks like all the experimental results here are from |
There was a problem hiding this comment.
I left some cosmetic comments but overall the structure and code look good to me. For the streaming I have a couple of concerns:
- I would like to see experiments with a more complicated runbook to make sure we have caught any perf or correctness issues. I would especially want to make sure we've tested
replaceadequately. - I am not sure I understand why encountering deleted nodes during pruning and throwing a
Transienterror is a bug. This seems like intended behavior and the transient error can be appropriately ignored. If we instead leave the deleted vectors in the graph until the end of deletion and take them into account during pruning of other nodes, we're just wasting work by computing distances to them anyway. Can you explain the reasoning here if I am wrong?
Thanks!
In-mem marks the vectors as deleted but keeps them around to be used during the inplace delete as the query point for finding replacement neighbors. bf_tree's design decision to hard delete would break this flow, which is why storing them temporarily is necessary. The bug I'm addressing was introduced during the bftree migration out of providers and into its own crate and we opted to go for the hard deletes. |
- Switch bf-tree to hard deletes: remove pending_deletes tracking, Mutex, and flush_deletes() methods. delete() now immediately removes vector data from the bf-tree store. - Reject VisitedAndTopK delete method in try_match for both streaming bf-tree benchmarks (requires deferred deletes). - Update StreamStats::Maintain to Vec<GenericStats> instead of named optional fields. - Update example JSON files to use small test_data and one_hop delete method. - Remove dead QuantVectorProvider::delete_vector. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3bc7e49 to
860f7e6
Compare
BfTreeProvider performs hard deletes — vector data is immediately erased. This makes InplaceDeleteMethod::VisitedAndTopK incompatible because it requires reading the deleted vector after the delete is committed. - Add doc comment on Delete impl explaining hard-delete semantics - Add compatibility notes on both InplaceDeleteStrategy impls - Remove stale delete_cache references from accessor doc comments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change set_neighbors and append_vector buf parameter from &mut Vec<u8> to &mut [u8] since only slice operations are used. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rd-delete based providers
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…viders Add a SlotReclaim enum to the Managed streaming layer that allows hard-delete providers (bf-tree) to recycle slots immediately during delete, rather than deferring to a consolidation pass. This eliminates the slot exhaustion issue where deferred consolidation couldn't keep up with insert/delete churn. Changes: - Add SlotReclaim enum (Immediate/Deferred) to managed.rs - Add TagSlotManager::recycle_tags() for immediate slot return - bf-tree streaming passes SlotReclaim::Immediate - inmem streaming passes SlotReclaim::Deferred(threshold) - Make consolidate_threshold optional in DynamicRunbookParams - Remove consolidate_threshold from bf-tree example JSON - Allow transient FailedVectorRetrieval during back-edge prune in insert (skip prune for deleted source vectors) The allow_transient change in graph/index.rs is safe because: - inplace_delete already handles missing vectors gracefully - Skipping back-edge prune for deleted nodes has no recall impact - Tested on wikipedia-100K: identical recall to deferred approach Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Could you add your new json examples as integration tests to https://github.com/microsoft/DiskANN/blob/main/diskann-benchmark/src/main.rs? Now we have a runbook in our test data directory, we should have a norm that all example jsons should be wired up as integration tests. |
And to add on to this, perhaps you could modify the README to mention adding example jsons as integration tests when you mention creating them? |
626f0e1 to
d5d8a93
Compare
Add TransientHandling enum (Escalate/Allow) to prune::Options so the decision is made at the call site and handled internally. Primary insert prunes use Escalate (vector retrieval must succeed), while consolidate and back-edge prunes use Allow (deleted source is expected, returns SourceUnavailable). Also adds prune::Outcome enum to signal whether pruning completed or was skipped due to a missing source, and From<ListError> for ANNError to support clean ? conversion at Allow call sites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d5d8a93 to
abc56c5
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26926eb to
b55e43e
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thank you for bearing with the weirdness of soft deletes and slot recycling, and for dealing with the learning curve of big-ann-benchmarks and runbooks! Now that the integration tests are present and you validated with a longer runbook, I am happy with this PR. |
Summary
Adds benchmark support for the bf_tree storage backend — both full-precision and spherical-quantized, in static (build-once) and streaming (insert/delete/search) modes.
What's included
Core crate fix (
diskann/src/graph/index.rs):inplace_delete_innernow pre-fetches the delete element before callingdelete(), so thatVisitedAndTopKcan use the deleted vector as a search query. This is critical for hard-delete providers (bf-tree) where the data is erased on delete. Soft-delete providers (in-mem) are unaffected since data remains accessible either way. All three delete methods (OneHop, TwoHopAndOneHop, VisitedAndTopK) continue to work for both provider types.Benchmark variants (4 tags):
graph-index-bftree-full-precision-f32— static build + searchgraph-index-bftree-stream-full-precision-f32— streaming with runbookgraph-index-build-bftree-spherical-quantization— static spherical (1/2/4-bit)graph-index-stream-bftree-spherical-quantization— streaming spherical (1/2/4-bit)Bug fixes in diskann-bftree:
Delete::delete. The ordering fix in the core crate ensures the delete element is captured before erasure, enabling all three inplace_delete methods to work correctly.append_vectorwould resize the neighbor list toself.dimand write the count atdim - 1, butset_neighborswrote a variable-length buffer. This inconsistency caused bf-tree page fragmentation and potential read errors when the two code paths produced different value sizes for the same key. Fix: both paths now write a fixed-size dim-element buffer using the same format (|neighbors|padding|count|).set_neighborsandappend_vectorpreviously allocated on every call. Replaced with a caller-provided&mut [u8]scratch buffer, eliminating per-call heap allocations.Benchmark infrastructure:
bftree_parameters_from(),run_streaming()in dedicated util moduleGenericStats::emptyreplaced withOption<GenericStats>for maintain stats (bf_tree has no separate drop_deleted/release phases)Example configs
See
diskann-benchmark/example/graph-index-bftree*.jsonfor ready-to-run configurations targeting test_data.Tests on CosmosDBDevBox VM (16 vCPU 64GB RAM 2,048GB SSD)
Results from MSTuring-1M
Full Precision streaming:
Spherical 2-bit streaming:
Spherical 4-bit streaming:
Comparison across bit widths at L=200:
The configuration used in the above tests was enough to keep all of the data in memory and didn't overflow to disk. I also tested full-precision using 32mb of cb size and experienced a 2x performance degradation due to the disk lookups.
CI Notes
CI reports an increase in IR size of 11%, which is over the 5% allowed in the CI file. This is largely unavoidable given the amount of code added here, so that CI gate should be ignored for this PR.