Skip to content

perf(vector/search): Vec<Candidate> heap allocation grows on graph traversal — pre-size to ef_search #680

Description

@mosuka

Round-3 perf push sub-issue (tracked under umbrella #536).

[S] Vec<Candidate> heap allocation grows on graph traversal — pre-size to ef_search

  • Where: hnsw/searcher.rs:419-420BinaryHeap::new() × 2 with no with_capacity.
  • Current behavior: Heaps grow geometrically on push, reallocating O(log N) times.
  • Suggested direction: BinaryHeap::with_capacity(ef_search * 2) for the result heap;
    candidate heap can be sized similarly.
  • Risk / scope: Trivial.

ID: VS-37 — see ~/.claude/tasks/laurus/20260523_perf_round3_audit/task_list.md for the full Round-3 issue list.

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