Skip to content

HNSW: graph-size resolution is a lifetime id high-water mark — churn-heavy tables permanently over-provision build/search ef #2182

Open

Description

@kriszyp

Follow-up to #2180 / #2181, from the pre-push review's main finding.

Both HNSW auto-scales (search ef, and construction ef as of #2181) resolve graph size from the shared id counter — a lifetime high-water mark of allocated node ids. Deletes never decrement it, so a churn-heavy table (TTL eviction, delete-and-reinsert ingest) reads permanently high. On the search side that means a generous-but-capped ef. On the build side it means a table holding, say, 30K live vectors that has allocated 5M ids over its life resolves 5M → efConstruction pinned at the cap → every insert runs a 512-candidate connection search on a 30K-node graph, ~5x the base build CPU, inside the write transaction, forever — with zero recall benefit. Documented as an accepted caveat in DESIGN.md (bounded at AUTO_EFC_MAX, wastes CPU, never hurts recall), but the right fix is a count that tracks live nodes.

Sketch: a second slot in the shared next-id buffer maintained as a live count (increment on insert, decrement on remove). The hard parts are (a) re-seeding it O(1) after restart — the largest-id reverse seek that re-seeds the id counter has no live-count analogue, and an exact count is a full key scan; (b) mixed-version workers sharing the buffer during a rolling upgrade. A persisted periodically-checkpointed count (exact-on-rebuild, drift-bounded between checkpoints) may be the pragmatic middle.

Also worth considering alongside (from the same review): a "pinned build, auto search" configuration does not currently exist — setting efConstruction pins the search-side default too, so the escape hatch for the churn cost trades away search-ef auto-scaling.

Generated by Claude Fable 5.

Activity

  1. added a commit that references this issue on Sep 1, 2026
    25664ff
  2. added theissue type on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:performancePerformance, latency, throughputarea:searchVector search, HNSW, full-text searchenhancementNew feature or request

    Type

    Fields

    Priority

    P3

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions