Skip to content

perf(vector/search): ahash for the pool doc_id->position maps probed per candidate in Flat/IVF searchers #855

Description

@mosuka

Background

#853 (PR #854) removed every per-candidate hash probe from the HNSW graph traversal by moving it to segment-local ordinals. The Phase 0b prototype gate for that work measured the probe cost directly: swapping the pool doc_id → position maps from std HashMap (SipHash) to ahash::AHashMap improved the HNSW store-level deletion benches by −30/−32% before any structural change (gate record).

The Flat and IVF searchers were out of #853's scope and still pay that SipHash probe per scanned candidate:

  • flat/searcher.rs — the int8 hot path resolves pool.field_position_index(field_name) once, then probes the inner HashMap<u64, u32> per candidate inside the scan closure.
  • ivf/searcher.rsparallel_scan over the probed clusters calls pool.get_record(*doc_id, field_name) per candidate, which probes the same map.
  • Map definitions (inner maps are std HashMap<u64, u32>): quantized_storage.rs, pq_storage.rs, pq_fastscan_storage.rs, rerank_storage.rs (field_index).

ahash is already a workspace dependency, and post-#853 the HNSW hot path no longer touches these maps at all — so the swap is low-risk and its benefit is confined to the Flat/IVF scan paths and cold lookups.

What to do

Swap the inner HashMap<u64, u32> (and the reader-side HashMap<u64, usize> prefetch map if convenient) to ahash::AHashMap in the four pool types, following the type through the few construction/return sites.

Acceptance criteria

References

Task list

  • A-side baseline (main): 2 rounds, A/A bands recorded
  • Implemented as specified (then reverted per the NO-GO verdict)
  • fmt / clippy (incl. 1.97 parity) / tests / wasm check — all clean pre-revert
  • B-side benches → NO-GO: neutral everywhere (see closing comment) → reverted
  • [~] PR — not opened (nothing to merge; closed as not planned)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions