fix(hnsw): backport parallel add synchronization to 0.16#1807
Conversation
Prevent concurrent inserts from dropping neighbor updates by making neighbor-side read-modify-write atomic, keep new points invisible until linking completes, and align lock ordering to remove the TSAN-reported inversion. Signed-off-by: jinjiabao.jjb <jinjiabao.jjb@antgroup.com> (cherry picked from commit 7b89a7a)
There was a problem hiding this comment.
Code Review
This pull request introduces thread-safety improvements and refactors locking mechanisms within the HNSW algorithm. Specifically, it adds "NoLock" variants for neighbor management functions to allow for more granular control over locking. It also adds a mutex to protect the random level generator and ensures consistent lock ordering in the "addPoint" method to prevent potential deadlocks. I have no feedback to provide.
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## 0.16 #1807 +/- ##
==========================================
- Coverage 92.16% 91.98% -0.19%
==========================================
Files 295 295
Lines 15718 15734 +16
==========================================
- Hits 14487 14473 -14
- Misses 1231 1261 +30
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary
size_tAPI while porting the no-lock helper declarationsTest Plan
7b89a7aa39dd88a836fcee6e5afd6ac0b8389026src/algorithm/hnswlib/hnswalg.h