Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
query/store: memoize PromLabels() call (#7767)
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]>
- Loading branch information