Skip to content

Commit 09f016c

Browse files
committed
feat: optimizations and benchmark expansion
1 parent acd42a6 commit 09f016c

9 files changed

Lines changed: 1618 additions & 85 deletions

File tree

BENCHMARKS.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,82 @@ Previous benchmark runs are archived in `benchmarks/archive/`.
1818

1919
---
2020

21+
## HNSW Engine Comparison Benchmark (YAMS baseline + optional zvec)
22+
23+
This benchmark is implemented by `benchmarks/hnsw_engine_comparison_benchmark.cpp` and built as
24+
`hnsw_engine_comparison_benchmark`.
25+
26+
Current status for this report: **YAMS-only run** (zvec was not linked in this run).
27+
28+
### What it measures
29+
30+
- Index build time
31+
- Search latency and QPS at `ef_search` values 50, 100, 200
32+
- Recall@K against brute-force ground truth
33+
34+
### Build and run
35+
36+
From `third_party/sqlite-vec-cpp/`:
37+
38+
```bash
39+
meson setup builddir
40+
meson compile -C builddir
41+
42+
# YAMS baseline (default)
43+
./builddir/benchmarks/hnsw_engine_comparison_benchmark --corpus=10000 --dim=768
44+
```
45+
46+
Optional zvec-enabled comparison:
47+
48+
```bash
49+
# build zvec separately
50+
git clone https://github.com/alibaba/zvec.git /opt/zvec
51+
cd /opt/zvec && mkdir build && cd build
52+
cmake .. -DCMAKE_BUILD_TYPE=Release
53+
make -j$(nproc)
54+
55+
# reconfigure sqlite-vec-cpp with zvec headers
56+
cd /path/to/yams/third_party/sqlite-vec-cpp
57+
meson setup builddir -Dzvec-root=/opt/zvec --reconfigure
58+
meson compile -C builddir
59+
./builddir/benchmarks/hnsw_engine_comparison_benchmark --corpus=10000 --dim=768
60+
```
61+
62+
### Current run results (2026-02-16, Apple M3 Max)
63+
64+
Run: `./hnsw_engine_comparison_benchmark --corpus=10000 --dim=768`
65+
66+
| Engine | M | ef_search | Build (ms) | Latency (μs) | QPS | Recall@10 |
67+
|--------|---|-----------|------------|--------------|-----|-----------|
68+
| yams-hnsw | 16 | 50 | 50,709 | 693 | 1,443 | 54.1% |
69+
| yams-hnsw | 16 | 100 | 50,709 | 1,129 | 886 | 74.7% |
70+
| yams-hnsw | 16 | 200 | 50,709 | 1,819 | 550 | 92.9% |
71+
| yams-hnsw | 24 | 50 | 105,494 | 1,028 | 973 | 68.2% |
72+
| yams-hnsw | 24 | 100 | 105,494 | 1,529 | 654 | 86.9% |
73+
| yams-hnsw | 24 | 200 | 105,494 | 2,219 | 451 | 98.5% |
74+
| yams-hnsw | 32 | 50 | 177,331 | 1,119 | 894 | 76.8% |
75+
| yams-hnsw | 32 | 100 | 177,331 | 1,811 | 552 | 93.1% |
76+
| yams-hnsw | 32 | 200 | 177,331 | 2,405 | 416 | 99.5% |
77+
78+
Hardware note: Apple M3 Max, NEON + DotProd, FP32, single-threaded query loop.
79+
80+
### External zvec reference numbers (not measured in this run)
81+
82+
From zvec published benchmarks (<https://zvec.org/en/docs/benchmarks/>):
83+
84+
| Dataset | Config | QPS | Recall |
85+
|---------|--------|-----|--------|
86+
| Cohere 1M (768d) | INT8, M=15, ef_search=180 | ~16,000 | 95%+ |
87+
| Cohere 10M (768d) | INT8, M=50, ef_search=118, refiner | ~8,000 | 95%+ |
88+
89+
Key differences vs this run:
90+
91+
- zvec numbers use INT8 + refiner and multithreaded query load
92+
- this run uses FP32 and single-threaded query loop
93+
- hardware differs (cloud ECS vs local Apple Silicon)
94+
95+
---
96+
2197
## Batch Distance Benchmark
2298

2399
### 1. Sequential vs Batch Comparison
@@ -129,3 +205,9 @@ meson compile -C builddir-release
129205
```
130206

131207
Logs are stored under `benchmarks/logs/2026-01-19_release_neon/`.
208+
209+
For the HNSW engine comparison benchmark:
210+
211+
```bash
212+
./builddir-release/benchmarks/hnsw_engine_comparison_benchmark --corpus=10000 --dim=768
213+
```

0 commit comments

Comments
 (0)