Skip to content

Refactor(diskann-benchmark): consolidate disk search config under DiskSearchMode#1232

Open
dyhyfu wants to merge 3 commits into
mainfrom
u/yaohongdeng/fixDiskModeBenchmarkCfg
Open

Refactor(diskann-benchmark): consolidate disk search config under DiskSearchMode#1232
dyhyfu wants to merge 3 commits into
mainfrom
u/yaohongdeng/fixDiskModeBenchmarkCfg

Conversation

@dyhyfu

@dyhyfu dyhyfu commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Consolidates disk-index search configuration under DiskSearchMode and decouples the benchmark's JSON input schema from the optional diskann-disk backend.

Previously, the input schema both defined the config and constructed diskann_disk::SearchMode, forcing several #[cfg(feature = "disk-index")] gates and scattering related fields (vector_filters_file, post_processor) across DiskSearchPhase. This PR moves the backend-specific construction into the search execution path and groups the search-mode fields together.

Changes

  • Move SearchMode construction to the backend. The match logic that builds diskann_disk::SearchMode now lives in a build_search_mode helper in the search execution module, so the input schema is pure config data with no dependency on the disk backend's SearchMode type.
  • Consolidate fields into DiskSearchMode. vector_filters_file and post_processor are nested inside DiskSearchMode alongside is_flat_search and adaptive_l. Validation and Display moved accordingly.
  • Remove unnecessary feature gates. DiskSearchMode and its fields no longer need #[cfg(feature = "disk-index")]. The only remaining gates are for QuantizationType, which is a diskann-disk type (intentionally left as-is — see below).
  • Migrate JSON fixtures (examples and perf test inputs) to the nested search_mode format.

@dyhyfu dyhyfu requested review from a team and Copilot July 7, 2026 09:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the diskann-benchmark disk-index benchmark input schema to consolidate disk search configuration under DiskSearchMode, and moves diskann_disk::SearchMode construction out of the JSON schema layer into the disk search execution path.

Changes:

  • Nested vector_filters_file and post_processor under DiskSearchMode, alongside is_flat_search and adaptive_l, and moved validation accordingly.
  • Added a build_search_mode helper in disk_index/search.rs to construct backend SearchMode at execution time.
  • Updated benchmark JSON fixtures (examples + perf inputs) to the new nested search_mode format.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
diskann-benchmark/src/inputs/disk.rs Refactors disk-index JSON schema to centralize mode-specific config/validation in DiskSearchMode.
diskann-benchmark/src/disk_index/search.rs Builds backend SearchMode during execution using new helper; updates access paths to nested config.
diskann-benchmark/perf_test_inputs/wikipedia-100K-disk-index.json Migrates perf input to nested search_mode object.
diskann-benchmark/perf_test_inputs/openai-100K-disk-index.json Migrates perf input to nested search_mode object.
diskann-benchmark/example/disk-index.json Migrates example input to nested search_mode object.
diskann-benchmark/example/disk-index-filter.json Migrates filter example to nested search_mode.vector_filters_file.
diskann-benchmark/example/disk-index-determinant-diversity.json Migrates post-processor example to nested search_mode.post_processor.

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

Comment on lines 112 to 116
pub(crate) recall_at: u32,
#[cfg(feature = "disk-index")]
#[serde(default)]
pub(crate) search_mode: DiskSearchMode,
// Backward compatibility for older benchmark inputs that used
// `is_flat_search` directly at the search-phase level.
#[cfg(feature = "disk-index")]
#[serde(default, skip_serializing)]
pub(crate) is_flat_search: Option<bool>,
#[cfg(not(feature = "disk-index"))]
pub(crate) is_flat_search: bool,
pub(crate) distance: SimilarityMeasure,
pub(crate) vector_filters_file: Option<InputFile>,
pub(crate) num_nodes_to_cache: Option<usize>,
Comment on lines 218 to 221

#[cfg(feature = "disk-index")]
if let Some(is_flat_search) = self.is_flat_search {
self.search_mode.is_flat_search = is_flat_search;
}

#[cfg(feature = "disk-index")]
self.search_mode
.validate(checker)
.context("invalid disk search mode")?;
Comment on lines +322 to 326
let has_filter = search_params.search_mode.vector_filters_file.is_some();
let mode: SearchMode<'_> = build_search_mode(
&search_params.search_mode,
has_filter,
vf,
@codecov-commenter

codecov-commenter commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.02%. Comparing base (e5b5f2b) to head (6fe7448).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
diskann-benchmark/src/inputs/disk.rs 0.00% 11 Missing ⚠️

❌ Your patch status has failed because the patch coverage (15.38%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main    #1232    +/-   ##
========================================
  Coverage   90.01%   90.02%            
========================================
  Files         501      504     +3     
  Lines       95584    95976   +392     
========================================
+ Hits        86044    86404   +360     
- Misses       9540     9572    +32     
Flag Coverage Δ
miri 90.02% <15.38%> (+<0.01%) ⬆️
unittests 89.69% <15.38%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
diskann-benchmark/src/main.rs 91.64% <100.00%> (+0.10%) ⬆️
diskann-benchmark/src/inputs/disk.rs 1.37% <0.00%> (-0.07%) ⬇️

... and 36 files with indirect coverage changes

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

@@ -6,27 +6,18 @@
use std::{fmt, num::NonZeroUsize, path::Path};

use anyhow::Context;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One request I have (either in this PR or in a follow-up) is that running

cargo test --package diskann-benchmark --features disk-index --profile ci

generates the following files

diskann-benchmark/siftsmall_index_filter_flat_disk.index
diskann-benchmark/siftsmall_index_filter_flat_pq_compressed.bin
diskann-benchmark/siftsmall_index_filter_flat_pq_pivots.bin
diskann-benchmark/siftsmall_index_filter_graph_disk.index
diskann-benchmark/siftsmall_index_filter_graph_pq_compressed.bin
diskann-benchmark/siftsmall_index_filter_graph_pq_pivots.bin

Can this be fixed to properly use a tempdir or a virtual file system to avoid polluting the workspace? Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks for discovering this problem.

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