Skip to content

Add synchronous load_with constructors and run escape hatch to wrapped_async#864

Open
suri-kumkaran wants to merge 2 commits intomainfrom
users/suryangupta/load-feature-in-wrapped-async
Open

Add synchronous load_with constructors and run escape hatch to wrapped_async#864
suri-kumkaran wants to merge 2 commits intomainfrom
users/suryangupta/load-feature-in-wrapped-async

Conversation

@suri-kumkaran
Copy link
Contributor

Why

Sync callers who need to load a prebuilt index must manually create a tokio runtime and call the async LoadWith trait — leaking async internals. Similarly, there's no way to call an async method on the inner index if a sync wrapper doesn't exist for it yet.

What

All changes are in diskann-providers/src/index/wrapped_async.rs.

  • load_with_multi_thread_runtime, load_with_current_thread_runtime, load_with_handle — Sync constructors that load a prebuilt index from storage, mirroring the existing new_with_* pattern.
  • run — Escape hatch: runs any async closure against the inner index on the wrapper's runtime, for methods that don't have a dedicated sync wrapper.
  • Extracted create_multi_thread_runtime / create_current_thread_runtime helpers to reduce duplication.
  • test_save_then_sync_load_round_trip — End-to-end test: build → insert → save (via run) → load → search.

Copy link
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

Adds synchronous entry points to load prebuilt async DiskANN indexes in diskann-providers, and introduces a run escape hatch for calling async-only inner methods from the sync wrapper.

Changes:

  • Added load_with_multi_thread_runtime, load_with_current_thread_runtime, and load_with_handle sync constructors that wrap LoadWith::load_with.
  • Added run to execute an arbitrary async closure on the wrapper’s runtime/handle.
  • Added an end-to-end save→sync-load→search round-trip test and refactored runtime creation into helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 73.48485% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.28%. Comparing base (b616aa3) to head (6c19fcb).

Files with missing lines Patch % Lines
diskann-providers/src/index/wrapped_async.rs 73.48% 35 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #864      +/-   ##
==========================================
- Coverage   90.45%   89.28%   -1.17%     
==========================================
  Files         442      442              
  Lines       83248    83372     +124     
==========================================
- Hits        75301    74439     -862     
- Misses       7947     8933     +986     
Flag Coverage Δ
miri 89.28% <73.48%> (-1.17%) ⬇️
unittests 89.12% <73.48%> (-1.29%) ⬇️

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

Files with missing lines Coverage Δ
diskann-providers/src/index/wrapped_async.rs 47.59% <73.48%> (+14.84%) ⬆️

... and 40 files with indirect coverage changes

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

Copy link
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 67 to 71
/// Construct a synchronous `DiskANNIndex` with its own `tokio::runtime::Runtime`.
///
/// A default configured runtime that uses the curren thread will be created and used behind the scenes. To use
/// a specific Toktio runtime, use `DiskANNIndex::new_with_multi_thread_runtime()` or `DiskANNIndex::new_with_handle()`.
/// A default configured runtime that uses the current thread will be created and used behind the scenes. To use
/// a specific Tokio runtime, use `DiskANNIndex::new_with_multi_thread_runtime()` or `DiskANNIndex::new_with_handle()`.
pub fn new_with_current_thread_runtime(config: graph::Config, data_provider: DP) -> Self {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The doc comment for new_with_current_thread_runtime points callers to new_with_multi_thread_runtime() for using a “specific Tokio runtime”, but neither method accepts a caller-provided runtime. Consider rephrasing to point to new_with_handle() for an external runtime handle, and to the other constructor only for selecting the runtime flavor (multi-thread vs current-thread).

Copilot uses AI. Check for mistakes.
Comment on lines 58 to 62
/// Construct a synchronous `DiskANNIndex` with its own `tokio::runtime::Runtime`.
///
/// A default configured multi-threaded runtime will be created and used behind the scenes. To use
/// a specific Toktio runtime, use `DiskANNIndex::new_with_multi_thread_runtime()` or `DiskANNIndex::new_with_handle()`.
/// a specific Tokio runtime, use `DiskANNIndex::new_with_multi_thread_runtime()` or `DiskANNIndex::new_with_handle()`.
pub fn new_with_multi_thread_runtime(config: graph::Config, data_provider: DP) -> Self {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The doc comment for new_with_multi_thread_runtime says that to use a specific Tokio runtime you should call new_with_multi_thread_runtime() or new_with_handle(), but this method itself always creates a default runtime. Please update the wording to distinguish between (a) choosing the multi-thread vs current-thread default runtime and (b) supplying an externally-owned runtime via new_with_handle().

Copilot uses AI. Check for mistakes.
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.

4 participants