perf(hnsw): deduplicate neighbor updates and fix error handling#9664
Open
shaunpatterson wants to merge 2 commits intodgraph-io:mainfrom
Open
perf(hnsw): deduplicate neighbor updates and fix error handling#9664shaunpatterson wants to merge 2 commits intodgraph-io:mainfrom
shaunpatterson wants to merge 2 commits intodgraph-io:mainfrom
Conversation
…sertHelper Deduplicate addNeighbors calls by iterating over inboundEdgesAllLayersMap keys instead of nnUidArray, which could contain duplicate UIDs when the same neighbor appears across multiple layers. Also fix two bugs: (1) err from addNeighbors for the inserted node was checked after the neighbor loop instead of immediately, and (2) searchPersistentLayer errors were silently swallowed by returning the uninitialized layerErr variable instead of err. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
addNeighborscalls: ReplacennUidArray(which accumulated duplicate UIDs when the same neighbor appeared across multiple HNSW layers) with direct iteration overinboundEdgesAllLayersMapkeys, ensuring each neighbor is processed exactly onceaddNeighbors(inUuid, ...): The error was previously checked after the neighbor loop instead of immediately, allowing unnecessary work on failuresearchPersistentLayererrors were returned aslayerErr(alwaysnil) instead oferr, masking real failuresTest plan
go test ./tok/hnsw/...)addNeighborsis called once per unique neighbor UID (no redundant writes)searchPersistentLayeris no longer swallowed🤖 Generated with Claude Code