-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve query performance #47
Merged
Merged
Conversation
This file contains 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
Not relevant for single query, but for concurrent ones
Also gets ride of sync.WaitGroup
…ock" This reverts commit cc86f2c.
For now we check this by computing the length. In the future we could pass a flag if it's already known whether a vector is normalized, which is the case for many embedding models.
Greatly reduces number of allocations. For a query of 5,000 documents from ~5000 allocations to ~50. Number of allocations are also now constant, i.e. 50 for querying 100,000 documents.
…known" This reverts commit ff28a38.
philippgille
force-pushed
the
query-perf
branch
from
March 16, 2024 14:21
fb2d415
to
bffa34a
Compare
- Normalizes only once instead of each time - Embedding creation takes time anyway, while query should be as fast as possible
philippgille
force-pushed
the
query-perf
branch
from
March 16, 2024 14:23
bffa34a
to
579fd46
Compare
philippgille
force-pushed
the
query-perf
branch
from
March 16, 2024 18:27
1e3525a
to
1410612
Compare
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.
We added benchmarks in #46.
Now we used them + CPU and memory profiles gathered with them to improve the performance.
Each individual improvement is a separate commit. The overall improvement is 60-80% reduction in query duration and > 99% reduction in memory allocations:
Benchmarked on Framework Laptop 13 (first generation).
Benchmarked before the first commit of this PR, and after.
Benchmarked with:
go test -benchmem -run=^$ -count 6 -bench .
(6 counts becausebenchstat
(used for printing the diff shown ⬆️ ) asks for it).