Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hybrid search latency

How fast is search over your documents? The hybrid_latency example answers that for your machine. It fills one SQLite file with chunks that carry 384-dimension vectors, then times hybrid_search calls that ask for 8 results. It measures four index setups: brute force and HNSW, each with f32 and i8 vectors.

The vectors are clustered, 100 clusters with a spread of 0.05, the same data the index benchmarks use. Clustered data is closer to real embeddings than uniform noise.

Run it

cargo run --release -p troupekit --features knowledge --example hybrid_latency -- 50000 2000

Both arguments are optional. The first is the number of chunks, 50 000 by default, and the second the number of queries, 2 000 by default.

Output

The example prints one header line and a Markdown table, one row per index kind and quantization:

chunks={chunks} dims={DIMS} queries={queries} top_k={TOP_K}
| index | quant | p50 us | p99 us |
|---|---|---|---|

A single run tells you little. Run it once on a quiet machine and once while the machine is busy, and you get the best and the worst case your users will see.

Knowledge explains the index kinds and quantization.