mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
tsdb: Save allocations on labels by re-using label array
Signed-off-by: Frederic Branczyk <fbranczyk@gmail.com>
This commit is contained in:
parent
ed6ce7ac98
commit
e0cf219f0d
|
@ -375,14 +375,13 @@ type blockBaseSeriesSet struct {
|
||||||
currLabels labels.Labels
|
currLabels labels.Labels
|
||||||
|
|
||||||
bufChks []chunks.Meta
|
bufChks []chunks.Meta
|
||||||
|
bufLbls labels.Labels
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *blockBaseSeriesSet) Next() bool {
|
func (b *blockBaseSeriesSet) Next() bool {
|
||||||
var lbls labels.Labels
|
|
||||||
|
|
||||||
for b.p.Next() {
|
for b.p.Next() {
|
||||||
if err := b.index.Series(b.p.At(), &lbls, &b.bufChks); err != nil {
|
if err := b.index.Series(b.p.At(), &b.bufLbls, &b.bufChks); err != nil {
|
||||||
// Postings may be stale. Skip if no underlying series exists.
|
// Postings may be stale. Skip if no underlying series exists.
|
||||||
if errors.Cause(err) == storage.ErrNotFound {
|
if errors.Cause(err) == storage.ErrNotFound {
|
||||||
continue
|
continue
|
||||||
|
@ -443,7 +442,10 @@ func (b *blockBaseSeriesSet) Next() bool {
|
||||||
if trimBack {
|
if trimBack {
|
||||||
intervals = intervals.Add(tombstones.Interval{Mint: b.maxt + 1, Maxt: math.MaxInt64})
|
intervals = intervals.Add(tombstones.Interval{Mint: b.maxt + 1, Maxt: math.MaxInt64})
|
||||||
}
|
}
|
||||||
b.currLabels = lbls
|
|
||||||
|
b.currLabels = make(labels.Labels, len(b.bufLbls))
|
||||||
|
copy(b.currLabels, b.bufLbls)
|
||||||
|
|
||||||
b.currIterFn = func() *populateWithDelGenericSeriesIterator {
|
b.currIterFn = func() *populateWithDelGenericSeriesIterator {
|
||||||
return newPopulateWithDelGenericSeriesIterator(b.chunks, chks, intervals)
|
return newPopulateWithDelGenericSeriesIterator(b.chunks, chks, intervals)
|
||||||
}
|
}
|
||||||
|
@ -665,6 +667,7 @@ func newBlockSeriesSet(i IndexReader, c ChunkReader, t tombstones.Reader, p inde
|
||||||
p: p,
|
p: p,
|
||||||
mint: mint,
|
mint: mint,
|
||||||
maxt: maxt,
|
maxt: maxt,
|
||||||
|
bufLbls: make(labels.Labels, 0, 10),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -696,6 +699,7 @@ func newBlockChunkSeriesSet(i IndexReader, c ChunkReader, t tombstones.Reader, p
|
||||||
p: p,
|
p: p,
|
||||||
mint: mint,
|
mint: mint,
|
||||||
maxt: maxt,
|
maxt: maxt,
|
||||||
|
bufLbls: make(labels.Labels, 0, 10),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue