inline scanning code for fast distance computations#4785
Closed
mdouze wants to merge 1 commit intofacebookresearch:mainfrom
Closed
inline scanning code for fast distance computations#4785mdouze wants to merge 1 commit intofacebookresearch:mainfrom
mdouze wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
Summary: After the ResultHandler diff landed there was a 1% performance regression on some critical codepath. It seems plausible that this regression was caused because the inner loop of the scanning code calls 2 virtual functions: - distance_to_code to compute a code distance - add_result to update the result structure whenever a better restlt is found It is probably the distance_to_code function that is the culprit because it is called for *all* the codes, when distance_to_code is called only if a better rresult is found. What this diff changes is that the scanning code is made available to the InvertedListScanner implementation so that the distance computation inlining can happen. This is applied to IndexIVFScalarQuantizer, IndexIVFFlat and IndexIVFRabitQ (it turns out that this one has a virtual function call inside its ditance_to_code so this update is unlikely to be significant). Reviewed By: junjieqi Differential Revision: D91830227
Contributor
Contributor
|
This pull request has been merged in 851ce24. |
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:
After the ResultHandler diff landed there was a 1% performance regression on some critical codepath.
It seems plausible that this regression was caused because the inner loop of the scanning code calls 2 virtual functions:
It is probably the distance_to_code function that is the culprit because it is called for all the codes, when distance_to_code is called only if a better rresult is found.
What this diff changes is that the scanning code is made available to the InvertedListScanner implementation so that the distance computation inlining can happen.
This is applied to IndexIVFScalarQuantizer, IndexIVFFlat and IndexIVFRabitQ (it turns out that this one has a virtual function call inside its ditance_to_code so this update is unlikely to be significant).
Reviewed By: junjieqi
Differential Revision: D91830227