Skip to content

feat: Implement thread-safe HNSW index with mmap storage - #8

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
  • Created HnswIndex in rag_engine::index with support for zero-allocation memory mapped storage
  • Implemented concurrent insertions using fine-grained locks (node_locks_) avoiding global contention
  • Ensured thread-safe reads using std::atomic_ref and memory_order barriers to prevent data races during graph traversal
  • Handled structural padding for Header to ensure alignas(64) compliance for cache line optimization
  • Implemented serialization and recovery from binary mmap files
  • Added comprehensive unit tests in test_hnsw.cpp (basic insertion, search, multi-threading, and persistence)
  • Updated TODO.md and patterns.md marking HNSW construction as complete
  • Evaluated and verified fixes based on rigorous static code review

- Created `HnswIndex` in `rag_engine::index` with support for zero-allocation memory mapped storage
- Implemented concurrent insertions using fine-grained locks (`node_locks_`) avoiding global contention
- Ensured thread-safe reads using `std::atomic_ref` and `memory_order` barriers to prevent data races during graph traversal
- Handled structural padding for `Header` to ensure `alignas(64)` compliance for cache line optimization
- Implemented serialization and recovery from binary `mmap` files
- Added comprehensive unit tests in `test_hnsw.cpp` (basic insertion, search, multi-threading, and persistence)
- Updated `TODO.md` and `patterns.md` marking HNSW construction as complete
- Evaluated and verified fixes based on rigorous static code review
@Lotargo
Lotargo merged commit c8f6fe2 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