Skip to content

Add a fast path to Map::prepare.#1023

Open
hildebrandmw wants to merge 3 commits intomainfrom
mhildebr/prepare-fast-path
Open

Add a fast path to Map::prepare.#1023
hildebrandmw wants to merge 3 commits intomainfrom
mhildebr/prepare-fast-path

Conversation

@hildebrandmw
Copy link
Copy Markdown
Contributor

When the map is empty, we can avoid doing any work in Map::prepare. This change makes Map::prepare efficient to call after a Map::clear, which helps keep calling code simpler in diskann-garnet when we dynamically switch to quantization part-way through backedge pruning.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to Map::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.

Comment thread diskann/src/graph/workingset/map.rs Outdated
Comment thread diskann/src/graph/workingset/map.rs Outdated
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.51%. Comparing base (09af6f0) to head (baea179).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
diskann/src/graph/workingset/map.rs 91.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
miri 89.51% <91.66%> (-0.01%) ⬇️
unittests 89.35% <91.66%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
diskann/src/graph/workingset/map.rs 97.36% <91.66%> (-0.08%) ⬇️

... and 7 files with indirect coverage changes

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

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.

5 participants