Add a fast path to Map::prepare.#1023
Open
hildebrandmw wants to merge 3 commits intomainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an early-return fast path to diskann::graph::workingset::Map::prepare when the internal HashMap is empty, aiming to make prepare() cheap to call after Map::clear() and avoid touching the provided iterator in that case.
Changes:
- Add
self.map.is_empty()fast path toMap::prepare, returning before doing generation/eviction work. - Document that
prepare()may not consume its iterator. - Add a unit test asserting the iterator is not advanced (and that generation does not change) on the empty-map fast path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
metajack
approved these changes
May 5, 2026
harsha-simhadri
approved these changes
May 5, 2026
added 2 commits
May 5, 2026 14:07
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1023 +/- ##
==========================================
- Coverage 89.51% 89.51% -0.01%
==========================================
Files 460 460
Lines 85424 85436 +12
==========================================
+ Hits 76467 76477 +10
- Misses 8957 8959 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
When the map is empty, we can avoid doing any work in
Map::prepare. This change makesMap::prepareefficient to call after aMap::clear, which helps keep calling code simpler indiskann-garnetwhen we dynamically switch to quantization part-way through backedge pruning.