TSDB: initialize conflicts map only when we need it.

Suggested by @songjiayang.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2023-11-13 16:20:04 +00:00
parent e6c0f69f98
commit 65a443e6e3

View file

@ -1707,6 +1707,9 @@ func (m seriesHashmap) set(hash uint64, s *memSeries) {
m.unique[hash] = s
return
}
if m.conflicts == nil {
m.conflicts = make(map[uint64][]*memSeries)
}
l := m.conflicts[hash]
for i, prev := range l {
if labels.Equal(prev.lset, s.lset) {
@ -1786,7 +1789,7 @@ func newStripeSeries(stripeSize int, seriesCallback SeriesLifecycleCallback) *st
for i := range s.hashes {
s.hashes[i] = seriesHashmap{
unique: map[uint64]*memSeries{},
conflicts: map[uint64][]*memSeries{},
conflicts: nil, // Initialized on demand in set().
}
}
return s