Refactor(diskann-benchmark): consolidate disk search config under DiskSearchMode - #1232
Refactor(diskann-benchmark): consolidate disk search config under DiskSearchMode#1232dyhyfu wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
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_fileandpost_processorunderDiskSearchMode, alongsideis_flat_searchandadaptive_l, and moved validation accordingly. - Added a
build_search_modehelper indisk_index/search.rsto construct backendSearchModeat execution time. - Updated benchmark JSON fixtures (examples + perf inputs) to the new nested
search_modeformat.
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.
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (42.46%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1232 +/- ##
==========================================
- Coverage 91.46% 91.44% -0.03%
==========================================
Files 516 516
Lines 98276 98340 +64
==========================================
+ Hits 89891 89928 +37
- Misses 8385 8412 +27
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (2)
diskann-benchmark/src/inputs/disk.rs:72
DiskSearchModedoes not use#[serde(deny_unknown_fields)], so typos or legacy keys inside the nestedsearch_modeobject (e.g.{ "mode": "graph", "is_flat_search": true }) will be silently ignored by Serde. This undermines the intent of adding#[serde(deny_unknown_fields)]onDiskSearchPhaseto hard-fail old schemas.
Consider denying unknown fields on DiskSearchMode as well so invalid/legacy keys under search_mode are rejected deterministically.
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "mode", rename_all = "kebab-case")]
pub(crate) enum DiskSearchMode {
diskann-benchmark/src/inputs/disk.rs:138
DiskSearchMode::Graphcurrently allows specifying bothadaptive_landpost_processor, butbuild_search_modewill always pick the determinant-diversitySearchMode::{diverse_graph,_}whenpost_processoris set, effectively ignoringadaptive_l. Sincediskann_disk::search::search_mode::SearchMode::DiverseGraphhas noadaptive_lsupport, this should be rejected (or at least made explicit) rather than silently dropping part of the config.
Self::Graph {
adaptive_l,
vector_filters_file,
post_processor,
} => {
if let Some(adaptive_l) = adaptive_l.as_mut() {
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (3)
diskann-benchmark/src/main.rs:721
- Using
save_path.to_str().unwrap()can panic on non-UTF-8 temp paths (e.g., if TMPDIR contains non-UTF-8). Since this is only for test JSON rewriting, preferto_string_lossy()to avoid spurious test failures on such environments.
let save_path = tempdir.path().join(format!("disk_index_filter_job_{i}"));
job["content"]["source"]["save_path"] =
serde_json::Value::String(save_path.to_str().unwrap().to_string());
diskann-benchmark/src/inputs/disk.rs:72
DiskSearchModedoes not deny unknown fields, so typos or legacy fields nested undersearch_mode(e.g.{ "mode": "graph", "is_flat_search": true }) may be silently ignored during deserialization. Addingdeny_unknown_fieldshere would make the JSON schema stricter and align with the intent of rejecting legacy/unknown parameters.
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "mode", rename_all = "kebab-case")]
pub(crate) enum DiskSearchMode {
diskann-benchmark/src/disk_index/search.rs:165
- The doc comment for
build_search_modesays the post-processor is supplied at search time, but the post-processor now comes from the JSON-drivenDiskSearchModeconfig (only the vector filter is per-query). Updating this comment would avoid confusion about where the post-processor is sourced.
/// Construct the disk [`SearchMode`] from the JSON-driven [`DiskSearchMode`]
/// config plus the per-query filter and post-processor supplied at search time.
fn build_search_mode<'a>(
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (3)
diskann-benchmark/src/inputs/disk.rs:133
DiskSearchMode::Graphallows bothadaptive_landpost_processorto be set, but the search execution path currently ignoresadaptive_lwhenever apost_processoris present (seebuild_search_modeindisk_index/search.rs, which matches determinant-diversity first and discards the computedadaptive_l). This makes part of the JSON config silently ineffective. Consider rejecting this combination during validation (or otherwise making the precedence explicit).
Self::Graph {
adaptive_l,
vector_filters_file,
post_processor,
} => {
diskann-benchmark/src/disk_index/search.rs:165
- Doc comment for
build_search_modesays the post-processor is "supplied at search time", but the function signature only takesmodeandvector_filter(the post-processor comes fromDiskSearchMode::Graph { post_processor, .. }). This is misleading when reading the code and debugging configuration-driven behavior.
/// Construct the disk [`SearchMode`] from the JSON-driven [`DiskSearchMode`]
/// config plus the per-query filter and post-processor supplied at search time.
fn build_search_mode<'a>(
diskann-benchmark/src/inputs/disk.rs:80
- Doc comment for
DiskSearchMode::Graphsays it can be used with adaptive-L, vector filters, and/or a post-processor. However the backendSearchModedoes not support combining determinant-diversity post-processing withadaptive_l(andbuild_search_modecurrently dropsadaptive_lwhenpost_processoris set). If you enforce mutual exclusivity in validation, this comment should be updated to avoid implying the combination is supported.
This issue also appears on line 129 of the same file.
/// Greedy graph search, optionally with inline adaptive-L, a per-query
/// vector filter, and/or a top-k post-processor.
Graph {
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (4)
diskann-benchmark/src/inputs/disk.rs:88
DiskSearchModedoes not deny unknown fields, so serde will silently ignore unexpected keys (e.g.,{"mode":"flat","adaptive_l":...}would deserialize asFlatand dropadaptive_l). That undermines the goal of making invalid combinations unrepresentable and makes typos easy to miss; consider denying unknown fields for the enum variants.
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "mode", rename_all = "kebab-case")]
pub(crate) enum DiskSearchMode {
/// Brute-force flat scan, optionally restricted by a per-query vector filter.
Flat {
diskann-benchmark/src/inputs/disk.rs:144
DiskSearchMode::Graphcurrently allowsadaptive_landpost_processorto be set together, butbuild_search_modewill always pickSearchMode::DiverseGraphwhen a post-processor is present, silently ignoringadaptive_l. Consider rejecting this combination during validation to avoid surprising config behavior.
Self::Graph {
adaptive_l,
vector_filters_file,
post_processor,
} => {
diskann-benchmark/src/main.rs:721
- This test builds a JSON string path via
save_path.to_str().unwrap(), which can panic on non-UTF8 paths. Usingto_string_lossy()avoids a hard panic and is consistent with other path-to-string conversions in the benchmark code.
for (i, job) in jobs.iter_mut().enumerate() {
let save_path = tempdir.path().join(format!("disk_index_filter_job_{i}"));
job["content"]["source"]["save_path"] =
serde_json::Value::String(save_path.to_str().unwrap().to_string());
diskann-benchmark/src/disk_index/search.rs:165
- The doc comment for
build_search_modesays the post-processor is supplied at search time, but the implementation reads it fromDiskSearchMode::Graph { post_processor, .. }(JSON config). Updating the comment would avoid confusion about where this value comes from.
/// Construct the disk [`SearchMode`] from the JSON-driven [`DiskSearchMode`]
/// config plus the per-query filter and post-processor supplied at search time.
fn build_search_mode<'a>(
Summary
Consolidates disk-index search configuration under
DiskSearchModeand decouples the benchmark's JSON input schema from the optionaldiskann-diskbackend.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) acrossDiskSearchPhase. This PR moves the backend-specific construction into the search execution path and groups the search-mode fields together.Changes
SearchModeconstruction to the backend. The match logic that buildsdiskann_disk::SearchModenow lives in abuild_search_modehelper in the search execution module, so the input schema is pure config data with no dependency on the disk backend'sSearchModetype.DiskSearchMode.vector_filters_fileandpost_processorare nested insideDiskSearchModealongsideis_flat_searchandadaptive_l. Validation andDisplaymoved accordingly.DiskSearchModeand its fields no longer need#[cfg(feature = "disk-index")]. The only remaining gates are forQuantizationType, which is adiskann-disktype (intentionally left as-is — see below).search_modeformat.