-
Notifications
You must be signed in to change notification settings - Fork 529
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
store-gateway: reduce overhead in fetching postings from cache #4978
Merged
dimitarvdimitrov
merged 20 commits into
main
from
dimitar/st-gw/postigns-fetching-reduce-optimize
May 12, 2023
Merged
store-gateway: reduce overhead in fetching postings from cache #4978
dimitarvdimitrov
merged 20 commits into
main
from
dimitar/st-gw/postigns-fetching-reduce-optimize
May 12, 2023
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
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
pracucci
approved these changes
May 11, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, LGTM!
Co-authored-by: Marco Pracucci <marco@pracucci.com>
dimitarvdimitrov
deleted the
dimitar/st-gw/postigns-fetching-reduce-optimize
branch
May 12, 2023 15:58
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 significantly reduces additional data structures when fetching postings from the cache. These can have comparable memory footprint to the actual posting lists when the lists themselves are small (lists in the index cache are diff-varint-encoded and snappy compressed).
Context
A simplified version of the current interface for fetching postings from the cache is below
The existing
RemoteIndexCache.FetchMultiPostings
creates some auxiliary data structures in order to do its job:string
keys that it passes to the dskit cache implementationlabel.Label
to astring
keylabel.Label
to a[]byte
that it got from the cache; this map is built with the help of the map above and the map of results that the cache returnsWhat this PR does
Result Iterator
This PR removes the two maps and changes the interface of the cache. The new interface returns an iterator where the order of elements is the same as the order of requested
labels.Label
keys.By doing this we can avoid having to build maps, which is faster and needs less memory. The change is non-invasive because the consumer of
FetchMultiPostings
already iterates the result in the same order as requested keys.Cache keys
This PR does another small, but impactful change: it avoids hashing each
labels.Label
key if the length of the key is shorter than the hash. Instead of hashing it base64-encodes the label itself.Benchmarks
Details
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]