HNSW index
A vector index written from scratch in Rust — the graph, the search, the distance kernels. This page is the index describing itself: it holds this project’s own source, and every number below is measured on the query you run, not quoted from a benchmark.
waking the index…
Run a search
Benchmarks
50,000 vectors · dim 128 · k=10From cargo run --release --example bench, clustered vectors, seeded and reproducible. Absolute numbers depend on hardware; the ratios hold.
| method | ef_search | latency/query | recall@10 | speedup |
|---|---|---|---|---|
| exhaustive scan | — | 5472 µs | 1.000 | 1.0× |
| HNSW | 10 | 49 µs | 0.980 | 112× |
| HNSW | 25 | 64 µs | 0.995 | 86× |
| HNSW | 50 | 106 µs | 1.000 | 52× |
| HNSW | 100 | 204 µs | 1.000 | 27× |
| HNSW | 200 | 379 µs | 1.000 | 14× |
Where it fails. On i.i.d. uniform vectors at dim 128 — a distribution real embeddings never follow — recall drops to 0.53 at ef=100 on the same corpus size. Uniform high-dimensional points sit at near-identical distances from each other, so there is no proximity structure for any graph to navigate; production implementations hit the same wall. BENCH_CLUSTERS=0 reproduces it.