mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 00:53:12 +00:00
Storage: reduce memory allocations when merging series sets (#12938)
Instead of setting to nil and allocating a new slice every time the merge is advanced, re-use the previous slice. This is safe because the `currentSets` member is only used inside member functions, and explicitly copied in `At()`, the only place it leaves the struct. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
b8f8c3c277
commit
a5a4eab679
@ -347,7 +347,7 @@ func (c *genericMergeSeriesSet) Next() bool {
|
||||
}
|
||||
|
||||
// Now, pop items of the heap that have equal label sets.
|
||||
c.currentSets = nil
|
||||
c.currentSets = c.currentSets[:0]
|
||||
c.currentLabels = c.heap[0].At().Labels()
|
||||
for len(c.heap) > 0 && labels.Equal(c.currentLabels, c.heap[0].At().Labels()) {
|
||||
set := heap.Pop(&c.heap).(genericSeriesSet)
|
||||
|
Loading…
Reference in New Issue
Block a user