Skip to content

perf(vector/index): HNSW per-level fixed-stride neighbour packing during build (M0 / M known up front) #641

Description

@mosuka

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

[S] HNSW per-level fixed-stride neighbour packing during build (M0 / M known up front)

  • Where: laurus/src/vector/index/hnsw/writer.rs:42-56,107-114.
  • Current behaviour: each per-level neighbour list is a
    variable-length Vec<u64>; growth triggers reallocations during
    pruning even though we know the max length per level (M0 or M).
  • Why it might be a bottleneck: extra Vec headers per layer
    (24 B), and the allocator pressure during pruning cycles. With M=16
    and 16 layers (max_level cap), 32 layers/node x N nodes of Vec
    headers is real RAM.
  • Suggested direction: use a single flat
    Vec<SmallVec<[u32; M0]>> per node, or per-layer
    [u32; M0] arrays packed inside a global arena. Pruning then
    truncates instead of dropping a Vec. Pairs with Fix examples #3.
  • Risk / scope: small, contained to writer; saves both heap and
    CPU during build.


ID: VI-23 — 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