mirror of https://github.com/prometheus/prometheus
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>pull/12944/head
parent
b8f8c3c277
commit
a5a4eab679
|
@ -347,7 +347,7 @@ func (c *genericMergeSeriesSet) Next() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, pop items of the heap that have equal label sets.
|
// 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()
|
c.currentLabels = c.heap[0].At().Labels()
|
||||||
for len(c.heap) > 0 && labels.Equal(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)
|
set := heap.Pop(&c.heap).(genericSeriesSet)
|
||||||
|
|
Loading…
Reference in New Issue