Skip to content

Commit

Permalink
[aggregator] Cap length of sample for reusal (m3db#3536)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdarulis authored Jun 3, 2021
1 parent e54033f commit feba416
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/aggregator/aggregation/quantile/cm/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package cm

const _maxSamplesToReuse = 2048

var (
emptySampleList sampleList
)
Expand Down Expand Up @@ -49,8 +51,13 @@ func (l *sampleList) Reset() {
for i := range l.samples {
l.samples[i].next, l.samples[i].prev = nil, nil
}

l.samples = l.samples[:0]
l.free = l.free[:0]
if cap(l.samples) > _maxSamplesToReuse || cap(l.free) > _maxSamplesToReuse {
l.samples = nil
l.free = nil
}
l.head, l.tail = nil, nil
}

Expand Down

0 comments on commit feba416

Please sign in to comment.