Skip to content

Commit

Permalink
TSDB: initialize conflicts map only when we need it.
Browse files Browse the repository at this point in the history
Suggested by @songjiayang.

Signed-off-by: Bryan Boreham <[email protected]>
  • Loading branch information
bboreham committed Nov 13, 2023
1 parent e6c0f69 commit 65a443e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tsdb/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65a443e

Please sign in to comment.