Skip to content

Commit

Permalink
Change float series custom trackers into maps as well
Browse files Browse the repository at this point in the history
  • Loading branch information
zenador committed Aug 29, 2023
1 parent fa984d2 commit 278add9
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions pkg/ingester/activeseries/active_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type seriesStripe struct {
mu sync.RWMutex
refs map[storage.SeriesRef]seriesEntry
active uint32 // Number of active entries in this stripe. Only decreased during purge or clear.
activeMatching []uint32 // Number of active entries in this stripe matching each matcher of the configured Matchers.
activeMatching map[uint16]uint32 // Number of active entries in this stripe matching each matcher of the configured Matchers.
activeNativeHistograms uint32 // Number of active entries (only native histograms) in this stripe. Only decreased during purge or clear.
activeMatchingNativeHistograms map[uint16]uint32 // Number of active entries (only native histograms) in this stripe matching each matcher of the configured Matchers.
activeNativeHistogramBuckets uint32 // Number of buckets in active native histogram entries in this stripe. Only decreased during purge or clear.
Expand Down Expand Up @@ -375,9 +375,7 @@ func (s *seriesStripe) clear() {
s.active = 0
s.activeNativeHistograms = 0
s.activeNativeHistogramBuckets = 0
for i := range s.activeMatching {
s.activeMatching[i] = 0
}
s.activeMatching = reinitMap()
s.activeMatchingNativeHistograms = reinitMap()
s.activeMatchingNativeHistogramBuckets = reinitMap()
}
Expand All @@ -394,7 +392,7 @@ func (s *seriesStripe) reinitialize(asm *Matchers, deleted *deletedSeries) {
s.activeNativeHistograms = 0
s.activeNativeHistogramBuckets = 0
s.matchers = asm
s.activeMatching = resizeAndClear(len(asm.MatcherNames()), s.activeMatching)
s.activeMatching = reinitMap()
s.activeMatchingNativeHistograms = reinitMap()
s.activeMatchingNativeHistogramBuckets = reinitMap()
}
Expand All @@ -412,7 +410,7 @@ func (s *seriesStripe) purge(keepUntil time.Time) {
s.active = 0
s.activeNativeHistograms = 0
s.activeNativeHistogramBuckets = 0
s.activeMatching = resizeAndClear(len(s.activeMatching), s.activeMatching)
s.activeMatching = reinitMap()
s.activeMatchingNativeHistograms = reinitMap()
s.activeMatchingNativeHistogramBuckets = reinitMap()

Expand Down Expand Up @@ -488,21 +486,6 @@ func (s *seriesStripe) remove(ref storage.SeriesRef) {
delete(s.refs, ref)
}

func resizeAndClear(l int, prev []uint32) []uint32 {
if cap(prev) < l {
if l == 0 {
return nil
}
return make([]uint32, l)
}

p := prev[:l]
for i := 0; i < l; i++ {
p[i] = 0
}
return p
}

func reinitMap() map[uint16]uint32 {
return make(map[uint16]uint32)
}
Expand Down

0 comments on commit 278add9

Please sign in to comment.