bftree lazy neighbor init#1215
Open
JordanMaples wants to merge 2 commits into
Open
Conversation
Treat a bf-tree `NotFound` on neighbor read as an empty adjacency list rather than an error, and drop the O(max_points) eager initialization that wrote an empty list for every id at construction. The eager loop was a stop-gap for a missing "exists" query, but bf-tree already distinguishes `Found` / `NotFound` / `Deleted` natively. Mapping `NotFound` to an empty list (identical to the existing `Found(0)` case) lets neighbor lists be created lazily on first write. This makes construction O(num_start_points) instead of O(max_points) — eliminating a billion-insert startup wall for large, larger-than-memory datasets — and removes the artificial coupling that required capacity to be fully materialized up front. The consolidate paths that motivated the stop-gap remain covered by the delete-and-search tests, which exercise inplace_delete end to end. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add coverage for the NotFound -> empty mapping introduced by lazy neighbor-list initialization: a serial sweep over a wide range of never-written ids (including sparse written ids and ids beyond any write) and a concurrent multi-thread hammer. Both assert that absent ids yield an empty adjacency list with no errors or panics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1215 +/- ##
==========================================
- Coverage 90.85% 89.82% -1.04%
==========================================
Files 489 489
Lines 93575 93618 +43
==========================================
- Hits 85020 84093 -927
- Misses 8555 9525 +970
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
|
nice! can you post perf and recall results for this change? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make bf-tree neighbor lists initialize lazily instead of eagerly materializing
an empty list for every id at construction.
Two changes in
diskann-bftree:neighbors.rs— On neighbor read, treat a bf-treeNotFoundresult as anempty adjacency list rather than an error. (
Deleted/InvalidKeystill error.)provider.rs— Drop theO(max_points)eager loop innew_emptythatwrote an empty list for every id up front.
Why
The eager loop was a stop-gap for a missing "exists" query. But bf-tree already
distinguishes
Found/NotFound/Deletednatively, so mappingNotFoundtoan empty list (identical to the existing
Found(0)case) lets neighbor lists becreated on first write.
This makes construction
O(num_start_points)instead ofO(max_points),eliminating a billion-insert startup wall for large, larger-than-memory datasets,
and removes the artificial coupling that required capacity to be fully
materialized up front.
Correctness
The consolidation paths that motivated the stop-gap (
consolidate_vector/on_neighbors) read neighbor lists during delete; aNotFound→empty result isidentical to the eager-init outcome for an unwritten id. These remain covered by
the delete-and-search tests, which exercise
inplace_deleteend to end.