-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
query/store: memoize PromLabels() call #7767
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
We use the stringlabels call so some allocations are inevitable but we can be much smarter about it: ``` func (s *storeSeriesSet) At() (labels.Labels, []*storepb.AggrChunk) { return s.series[s.i].PromLabels(), s.series[s.i].Chunks <--- not memoized, new alloc on every At() call; need to memoize because of stringlabel. One alloc is inevitable. } ``` ``` lset, chks := s.SeriesSet.At() if s.peek == nil { s.peek = &Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset), Chunks: chks} <-- converting back to labelpb ? continue } ``` ``` if labels.Compare(lset, s.peek.PromLabels()) != 0 { <--- PromLabels() called; we can avoid this call s.lset, s.chunks = s.peek.PromLabels(), s.peek.Chunks <- PromLabels() called; we can avoid this s.peek = &Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset), Chunks: chks} <--- converting back to labelpb; we can avoid this return true } ``` Signed-off-by: Giedrius Statkevičius <[email protected]>
GiedriusS
force-pushed
the
cache_promlabels
branch
from
September 20, 2024 09:25
edbd64f
to
4e2f47e
Compare
pedro-stanaka
approved these changes
Sep 20, 2024
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.
lg
GiedriusS
added a commit
that referenced
this pull request
Oct 1, 2024
This reverts commit 735db72. Signed-off-by: Giedrius Statkevičius <[email protected]>
GiedriusS
added a commit
that referenced
this pull request
Oct 1, 2024
* Revert "store: add chunk pooling (#7771)" This reverts commit a2113fd. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "query/store: memoize PromLabels() call (#7767)" This reverts commit 735db72. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "store: compare labels directly (#7766)" This reverts commit 30f453e. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "store: don't create intermediate labels (#7762)" This reverts commit 8cd3fae. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: build with stringlabels (#7745)" This reverts commit 883fade. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: enable gRPC pooling (#7742)" This reverts commit ca8ab90. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: switch to vtprotobuf (#7721)" This reverts commit a8e7109. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: removing gogoproto extensions (#7718)" This reverts commit 97710f4. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: rm ZLabels (#7675)" This reverts commit 8c8a88e. Signed-off-by: Giedrius Statkevičius <[email protected]> --------- Signed-off-by: Giedrius Statkevičius <[email protected]>
jnyi
pushed a commit
to jnyi/thanos
that referenced
this pull request
Oct 17, 2024
We use the stringlabels call so some allocations are inevitable but we can be much smarter about it: ``` func (s *storeSeriesSet) At() (labels.Labels, []*storepb.AggrChunk) { return s.series[s.i].PromLabels(), s.series[s.i].Chunks <--- not memoized, new alloc on every At() call; need to memoize because of stringlabel. One alloc is inevitable. } ``` ``` lset, chks := s.SeriesSet.At() if s.peek == nil { s.peek = &Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset), Chunks: chks} <-- converting back to labelpb ? continue } ``` ``` if labels.Compare(lset, s.peek.PromLabels()) != 0 { <--- PromLabels() called; we can avoid this call s.lset, s.chunks = s.peek.PromLabels(), s.peek.Chunks <- PromLabels() called; we can avoid this s.peek = &Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset), Chunks: chks} <--- converting back to labelpb; we can avoid this return true } ``` Signed-off-by: Giedrius Statkevičius <[email protected]>
jnyi
pushed a commit
to jnyi/thanos
that referenced
this pull request
Oct 17, 2024
* Revert "store: add chunk pooling (thanos-io#7771)" This reverts commit a2113fd. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "query/store: memoize PromLabels() call (thanos-io#7767)" This reverts commit 735db72. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "store: compare labels directly (thanos-io#7766)" This reverts commit 30f453e. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "store: don't create intermediate labels (thanos-io#7762)" This reverts commit 8cd3fae. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: build with stringlabels (thanos-io#7745)" This reverts commit 883fade. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: enable gRPC pooling (thanos-io#7742)" This reverts commit ca8ab90. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: switch to vtprotobuf (thanos-io#7721)" This reverts commit a8e7109. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: removing gogoproto extensions (thanos-io#7718)" This reverts commit 97710f4. Signed-off-by: Giedrius Statkevičius <[email protected]> * Revert "*: rm ZLabels (thanos-io#7675)" This reverts commit 8c8a88e. Signed-off-by: Giedrius Statkevičius <[email protected]> --------- Signed-off-by: Giedrius Statkevičius <[email protected]>
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 use the stringlabels call so some allocations are inevitable but we can be much smarter about it: