perf(ann): batched bulk build, parallel with the parallel feature
Profiling the build showed 90% of all distance evaluations are in back-link pruning (40.8M of 44.9M at 10K): every overflow re-runs the diversity heuristic pairwise over ~max_conn candidates. The bulk build now inserts in batches: plan every node's neighbours against the graph as it stood when the batch began (read-only, so plans are independent), link, then prune each overflowing list once. A node gaining several back-links in a batch is pruned once rather than once per link, so this is faster even single-threaded (10K: 1676 -> 1074 ms). With `parallel`, planning and pruning use rayon (10K: 388 ms; 100K: ~21 s -> 5.9 s on 16 cores). Batches start at one node and are capped at 1/16 of the linked graph and 512 nodes; a node that raises the top layer gets a batch to itself. The result is deterministic and identical with or without the feature (one code path; test compares two builds byte for byte). Parallelising within a single insert was tried first: 1.45x on 16 cores, tasks too small. Incremental insert() stays sequential. Recall on clustered data is unchanged or slightly better; uniform random data dips slightly (10K, ef=64: 0.474 -> 0.444). clawhdf5-agent's `parallel` feature now passes through to the index. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
41db450c92
commit
c19199f3eb
@@ -243,6 +243,28 @@ results.
|
||||
| 10000 | 104 | 1487 | 33.8 | 13.7 | 13.9 | 0.49 | 0.51 | 2020.9 |
|
||||
| 100000 | 1376 | 20285 | 728.9 | 353.1 | 142.2 | 4.65 | 4.78 | 214.7 |
|
||||
|
||||
### After: batched bulk build (optionally parallel); deletions handled in search
|
||||
|
||||
Profiling showed **90% of a build's distance evaluations are in back-link
|
||||
pruning**. The bulk build now inserts in batches: plan each node's neighbours
|
||||
against the graph as it stood at the start of the batch, link, then prune every
|
||||
overflowing list once. That is less work even single-threaded (a node gaining
|
||||
several back-links in a batch is pruned once), and with the `parallel` feature
|
||||
planning and pruning run on a thread pool. The graph is deterministic and the
|
||||
same with or without the feature. Parallelising *within* one insert was tried
|
||||
first and gave only 1.45x on 16 cores (tasks too small).
|
||||
|
||||
| build | 1K | 10K | 100K |
|
||||
|---|---:|---:|---:|
|
||||
| v2.4.0 | 116 ms | 1676 ms | ~21 s |
|
||||
| batched | 83 ms | 1074 ms | 19.2 s |
|
||||
| batched + `parallel` (16 cores) | 34 ms | 388 ms | 5.9 s |
|
||||
|
||||
Recall on clustered data is unchanged or slightly better (100K, `ef = 64`:
|
||||
0.984 -> 0.9945). On uniform random data it dips slightly (10K, `ef = 64`:
|
||||
0.474 -> 0.444), the cost of batch members not seeing each other while
|
||||
planning; batches are capped at 1/16 of the graph and 512 nodes.
|
||||
|
||||
## Vector Search Latency
|
||||
|
||||
Brute-force cosine similarity over 384-dimensional embeddings (OpenAI text-embedding-3-small size).
|
||||
|
||||
Reference in New Issue
Block a user