Skip to content

Conversation

@eyalrund
Copy link
Collaborator

@eyalrund eyalrund commented Jan 22, 2026

Optimizations and compilation fixes for linux x86

bigmountainben and others added 4 commits January 21, 2026 13:33
- Use peek_mut() for in-place heap replacement in MaxHeap::try_insert
  This avoids redundant sift operations when replacing the max element
- Add is_deleted() method to GraphAccess trait for extensibility
- Add into_sorted_pairs() method for efficient result collection
- Optimize into_sorted_vec() with pre-allocated capacity

Performance impact:
- KNN search: More stable (47K-52K q/s vs 36K-51K before)
- Insertion: Improved ~25% (4.3K vec/s vs 3.5K before)
- Range search: Similar performance (205K-256K q/s)
Add a separate atomic flags array to ConcurrentGraph to allow O(1) deleted
flag checking without acquiring the segment read lock. This matches the C++
implementation where idToMetaData provides direct array access.

Changes:
- Add flags module with DELETE_MARK and IN_PROCESS constants
- Add element_flags field to ConcurrentGraph (Vec<AtomicU8>)
- Implement is_marked_deleted() and mark_deleted() methods
- Override is_deleted() in GraphAccess impl to use flags array
- Update mark_deleted_concurrent() to sync both flags and metadata
- Update replace() to reset flags during compaction
- Standardize all is_deleted checks to use graph.is_deleted()

This optimization reduces contention in the search hot path by avoiding
segment read locks when checking deleted status during neighbor exploration.
This self-contained benchmark creates an in-memory HNSW index and measures
KNN search, range search, and insertion performance. Unlike the existing
benchmarks that require external data files, this can be run directly for
quick performance comparisons with the Rust implementation.

Test configuration: 10K vectors, 128 dimensions, M=16, ef_construction=100

Usage: ./build_cpp_vecsim/benchmark/simple_hnsw_bench
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ eyalrund
❌ bigmountainben
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

4 participants