Files
faiss/perf_tests
Tom Jackson a3a7627009 VisitedTable -> unordered_set if ntotal is large (#4735)
Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4735

`VisitedTable` accounts for a huge portion of `HNSW::search()` for unbatched searches of large indices.

As demonstrated in the benchmarks shown below, the vector-based implementation is much faster for smaller `ntotal` values, but at ~2M and above, it becomes slower, often significantly so. E.g.: At 64M slots, without batching, a workload of 1000 `set()`/`get()`s is >100x slower. Even with batching, this workload is still 3x slower with vectors.

This is a very likely explanation for the poor performance of HNSW in a 2023 USearch blog post (https://www.unum.cloud/blog/2023-11-07-scaling-vector-search-with-intel), which shows the same high throughput below 1M docs, and the same O(n) slowdown as the size grows beyond >2M:

Reviewed By: mnorris11, mdouze

Differential Revision: D89515309

fbshipit-source-id: 08bc4a54faa311eeb9946f2a43482ae52b61566e
2026-02-13 18:10:48 -08:00
..
2026-02-05 10:52:06 -08:00
2026-02-05 10:52:06 -08:00