Optimize sparse search by precomputing once the query info per posting#3327
Merged
Optimize sparse search by precomputing once the query info per posting#3327
Conversation
agourlay
commented
Jan 5, 2024
| // accumulate score for the current record id | ||
| if element.record_id == min_record_id { | ||
| score += | ||
| element.weight * self.query.values[posting_iterator.query_weight_offset]; |
Member
Author
There was a problem hiding this comment.
this is the hottest part
IvanPleshkov
approved these changes
Jan 8, 2024
generall
pushed a commit
that referenced
this pull request
Mar 5, 2024
HighBestCoder
pushed a commit
to HighBestCoder/qdrant
that referenced
this pull request
Dec 14, 2025
…Lists (qdrant#3327) Summary: Pull Request resolved: facebookresearch/faiss#3327 **Context** 1. [Issue 2621](facebookresearch/faiss#2621) discuss inconsistency between OnDiskInvertedList and InvertedList. OnDiskInvertedList is supposed to handle disk based multiple Index Shards. Thus, we should name it differently when merging invls from index shard. 2. [Issue 2876](facebookresearch/faiss#2876) provides usecase of shifting ids when merging invls from different shards. **In this diff**, 1. To address qdrant#1 above, I renamed the merge_from function to merge_from_multiple without touching merge_from base class. why so? To continue to allow merge invl from one index to ondiskinvl from other index. 2. To address qdrant#2 above, I have added support of shift_ids in merge_from_multiple to shift ids from different shards. This can be used when each shard has same set of ids but different data. This is not recommended if id is already unique across shards. Reviewed By: mdouze Differential Revision: D55482518 fbshipit-source-id: 95470c7449160488d2b45b024d134cbc037a2083
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.
This PR is a low hanging fruit I noticed while working on a larger optimization.
We currently fetch the query weight corresponding to a posting list iterator every time we score a point.
This small cost adds up and actually shows in profiling.
The proposed fix is to precompute for each posting list their corresponding query information.
The result is a consistent 3% gain on the inverted index search:
And 8% on the plain search: