Skip to content

feat: Implemented zero-allocation memory-mapped HNSW graph - #9

Merged
Lotargo merged 1 commit into
mainfrom
feat-hnsw-index-7237617367634644120
Mar 9, 2026
Merged

Lotargo merged 1 commit into
mainfrom
feat-hnsw-index-7237617367634644120

Conversation

@Lotargo

@Lotargo Lotargo commented Mar 9, 2026

Copy link
Copy Markdown
Owner
  • Developed a custom HNSW index storing vectors, levels, and neighborhood links in fixed-stride flat arrays using POSIX mmap backing (storage::MmapFile), avoiding dynamic allocation overhead during construction and query execution.
  • Added strict padding to Header to enforce alignas(64) boundaries, ensuring contiguous memory segments are cache line optimized for SIMD instruction dispatching.
  • Established fine-grained node-level concurrency using off-heap Spinlock arrays, enabling wait-free topological insertion without global lock contention or storing locking primitives in the persistent .bin file.
  • Ensured thread-safe search traversals using std::atomic_ref and strict memory barriers (memory_order_acquire/memory_order_release), nullifying the data-race when appending neighbors in concurrent threads.
  • Added double-checked locking mechanisms when promoting the global graph entry point (entry_point_) and maximum tree height (max_level_).
  • Introduced Google Tests validating HNSW constraints, including accuracy (Recall), multi-threaded stress-testing inserts, and zero-downtime persistence mapping.
  • Updated documentation (TODO.md, patterns.md) specifying Tombstone Roaring Bitmaps for O(1) delete logic as the next priority, fulfilling the LSM-Compaction architectural pattern to mitigate graph fragmentation caused by index holes.

- Developed a custom HNSW index storing vectors, levels, and neighborhood links in fixed-stride flat arrays using POSIX `mmap` backing (`storage::MmapFile`), avoiding dynamic allocation overhead during construction and query execution.
- Added strict padding to `Header` to enforce `alignas(64)` boundaries, ensuring contiguous memory segments are cache line optimized for SIMD instruction dispatching.
- Established fine-grained node-level concurrency using off-heap `Spinlock` arrays, enabling wait-free topological insertion without global lock contention or storing locking primitives in the persistent `.bin` file.
- Ensured thread-safe search traversals using `std::atomic_ref` and strict memory barriers (`memory_order_acquire`/`memory_order_release`), nullifying the data-race when appending neighbors in concurrent threads.
- Added double-checked locking mechanisms when promoting the global graph entry point (`entry_point_`) and maximum tree height (`max_level_`).
- Introduced Google Tests validating HNSW constraints, including accuracy (`Recall`), multi-threaded stress-testing inserts, and zero-downtime persistence mapping.
- Updated documentation (`TODO.md`, `patterns.md`) specifying Tombstone Roaring Bitmaps for O(1) delete logic as the next priority, fulfilling the LSM-Compaction architectural pattern to mitigate graph fragmentation caused by index holes.
@Lotargo
Lotargo merged commit 51d7dd5 into main Mar 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant