Optimize the priority queue when selecting neighbor points #634
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.
Modify
In this function, first of all, pop all items from
top_candidates
one by one will generate an ordered sequence, ifqueue_closest
is only aim to get nearest from candidates, traversal this sequence reverse order also can do it. Its no need to build another priority queue with negative distance(because of results will put in top_candidates to return, pop all items is necessary). And also delete dist inreturn_list
(it's not use)./benchmark/cpp/
, it will build two binary, one is use local hnswlib, another is use origin master branch hnswlib, run them seperently can get performance compair results.Benifit
My performance test shows it will take 5%-10% time benifit during index building.
Because most of time spent on distance calculate, more data, less time benifit