Commit 99cc35e
Create benchmarks for the flat index (full-precision in-memory implementation) (microsoft#1170)
Establishes a baseline benchmark for `FlatIndex::knn_search`, enabling
evaluation of new capabilities and innovations in DiskANN's flat-scan
implementation.
### Why Add Flat Index Benchmarks if Exhaustive Exists?
**Exhaustive benchmarks** are lightweight benchmarks focused on
quantizer speed and accuracy: they measure compress + distance
performance in isolation, without involving the `FlatIndex` machinery or
any data provider. They operate entirely outside the DiskANN
provider/index abstraction.
**Flat benchmarks** are end-to-end benchmarks that exercise `FlatIndex`
with different strategy configurations. They exercise `FlatIndex`
through the actual provider and search strategy abstractions, so they
capture realistic runtime behavior, and integration overhead that
exhaustive benchmarks intentionally skip.
This PR enables full-precision in-memory flat search. Future work may
add:
- Quantized flat search
- Quantized flat search with reranking (disk-based or in-memory)
- Batched SIMD scan
- Integration with diversity search
### Changes
- New `diskann-benchmark/src/flat` benchmark module with:
- `InMemProvider` wrapping `FastMemoryVectorProviderAsync`
(cache-line-aligned vector storage) with identity `DataProvider` mapping
- `FlatScanStrategy` and `FlatVisitor` implementing
`SearchStrategy`/`DistancesUnordered`
- `FlatSearcher` implementing the `Search` trait from `benchmark_core`
- Input schema (`diskann-benchmark/src/inputs/flat.rs`) with dataset,
distance metric, queries, groundtruth, k, thread counts, and reps
- Integration test (`flat_search_integration`) and example input
(`diskann-benchmark/example/flat-index.json`)
- Performance test input for wikipedia-100K dataset
(`diskann-benchmark/perf_test_inputs/wikipedia-100K-flat-index.json`)
- Unrelated fix: renamed temp file in `run_integration_test` from
`graph-index.json` to `input.json` - the helper is shared by all
backends, not just graph-index
Follows established patterns from the graph-index and exhaustive
backends.
## Output example:
```
cargo run --package diskann-benchmark --release -- run --input-file diskann-benchmark\perf_test_inputs\wikipedia-100K-flat-index.json --output-file ./target/tmp/flat-index-output.json
######################
# Running Job 1 of 1 #
######################
Data: target/tmp\wikipedia_cohere/wikipedia_base.bin.crop_nb_100000
Data Type: float32
Distance: inner_product
Queries: target/tmp\wikipedia_cohere/wikipedia_query.bin
Groundtruth: target/tmp\wikipedia_cohere/wikipedia-100K
K: 100
Threads: 4, 8
Reps: 1
Loading dataset...
Loaded 100000 vectors of dimension 768
Queries: 5000, Groundtruth: 5000x100
K, Avg cmps, QPS - mean(max), Avg Latency, p99 Latency, Recall, Threads
===================================================================================================================
100, 100000, 123.0 (123.0), 32430.0us (32430.0us), 35711.0us (35711us), 0.9999899999999999, 4
100, 100000, 250.4 (250.4), 31909.2us (31909.2us), 33323.0us (33323us), 0.9999899999999999, 8
```1 parent 7b92797 commit 99cc35e
9 files changed
Lines changed: 831 additions & 3 deletions
File tree
- diskann-benchmark-core/src
- diskann-benchmark
- example
- perf_test_inputs
- src
- flat
- inputs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments