improvement: performance of update vector #1289
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaces expensive dataset copy and knn search in update_vector for both HNSW and HGraph with direct neighbor retrieval APIs, reducing overhead and boosting performance. Sequence diagram for optimized neighbor retrieval in update_vectorsequenceDiagram
participant HNSW
participant HNSWLib
HNSW->>HNSWLib: get_linklist0(id)
HNSW->>HNSWLib: getListCount(linklist)
loop For each neighbor
HNSW->>HNSWLib: getDistanceByLabel(neighbor_id, new_base_vec)
end
Sequence diagram for optimized neighbor retrieval in HGraph::UpdateVectorsequenceDiagram
participant HGraph
participant BottomGraph
HGraph->>BottomGraph: GetNeighbors(inner_id, neighbors)
loop For each neighbor
HGraph->>HGraph: CalcDistanceById(new_base_vec, neighbor_id)
end
Class diagram for updated neighbor retrieval in HNSW and HGraphclassDiagram
class HNSW {
+update_vector(id, new_base, force_update)
}
class HNSWLib {
+get_linklist0(id)
+getListCount(linklist)
+getDistanceByLabel(id, vec)
}
HNSW --> HNSWLib
class HGraph {
+UpdateVector(id, new_base, force_update)
-bottom_graph_: BottomGraph
}
class BottomGraph {
+GetNeighbors(inner_id, neighbors)
}
HGraph --> BottomGraph
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello @ShawnShawnYou, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the performance of vector update operations within the HGraph and HNSW indexing algorithms. By streamlining the process of identifying existing neighbors, it significantly reduces computational overhead and improves the efficiency of updating vectors in the index. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to improve the performance of UpdateVector by replacing KNN search with direct neighbor retrieval from the graph. This is a good optimization.
My review has identified a critical issue in hnsw.cpp and a high-severity issue in hgraph.cpp. Both are related to incorrect handling of internal vs. external IDs, which could lead to incorrect behavior or crashes. Please see the detailed comments for suggestions on how to fix them.
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #1289 +/- ##
==========================================
+ Coverage 91.42% 92.02% +0.60%
==========================================
Files 318 320 +2
Lines 17622 17687 +65
==========================================
+ Hits 16111 16277 +166
+ Misses 1511 1410 -101
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:
|
|
@ShawnShawnYou this pull request cannot cherry-pick to the branch 0.16 (CONFLICT), please create a new pull request to the branch 0.16. |
Signed-off-by: zhongxiaoyao.zxy <zhongxiaoyao.zxy@antgroup.com>
close #1288
Summary by Sourcery
Enhancements: