Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vdarulis committed May 2, 2022
1 parent cbc4a9e commit af3cade
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
4 changes: 3 additions & 1 deletion src/aggregator/aggregation/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@ func (c *Counter) Annotation() []byte {
}

// Close closes the counter.
func (c *Counter) Close() {}
func (c *Counter) Close() {
c.annotation = nil
}
4 changes: 3 additions & 1 deletion src/aggregator/aggregation/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,6 @@ func (g *Gauge) Annotation() []byte {
}

// Close closes the gauge.
func (g *Gauge) Close() {}
func (g *Gauge) Close() {
g.annotation = nil
}
5 changes: 4 additions & 1 deletion src/aggregator/aggregation/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ func (t *Timer) Annotation() []byte {
}

// Close closes the timer.
func (t *Timer) Close() { t.stream.Close() }
func (t *Timer) Close() {
t.annotation = nil
t.stream.Close()
}
30 changes: 7 additions & 23 deletions src/aggregator/aggregator/elem_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ func newParsedPipeline(pipeline applied.Pipeline) (parsedPipeline, error) {
}, nil
}

// placeholder to make compiler happy about generic elem base
// Placeholder to make compiler happy about generic elem base.
// NB: lockedAggregationFromPool and not newLockedAggregation to avoid yet another rename hack in makefile
func lockedAggregationFromPool(
aggregation typeSpecificAggregation,
Expand All @@ -757,21 +757,13 @@ func lockedCounterAggregationFromPool(
l := lockedCounterAggregationPool.Get().(*lockedCounterAggregation)
l.aggregation = aggregation
l.sourcesSeen = sourcesSeen
l.lastUpdatedAt = 0
l.dirty = false
l.closed = false
l.resendEnabled = false

return l
}

func (l *lockedCounterAggregation) close() {
l.aggregation.Close()
l.aggregation = counterAggregation{}
l.sourcesSeen = nil
l.lastUpdatedAt = 0
l.dirty = false
l.closed = false
l.resendEnabled = false
*l = lockedCounterAggregation{}
lockedCounterAggregationPool.Put(l)
}

Expand All @@ -784,17 +776,13 @@ func lockedGaugeAggregationFromPool(
l := lockedGaugeAggregationPool.Get().(*lockedGaugeAggregation)
l.aggregation = aggregation
l.sourcesSeen = sourcesSeen

return l
}

func (l *lockedGaugeAggregation) close() {
l.aggregation.Close()
l.aggregation = gaugeAggregation{}
l.sourcesSeen = nil
l.lastUpdatedAt = 0
l.dirty = false
l.closed = false
l.resendEnabled = false
*l = lockedGaugeAggregation{}
lockedGaugeAggregationPool.Put(l)
}

Expand All @@ -807,16 +795,12 @@ func lockedTimerAggregationFromPool(
l := lockedTimerAggregationPool.Get().(*lockedTimerAggregation)
l.aggregation = aggregation
l.sourcesSeen = sourcesSeen

return l
}

func (l *lockedTimerAggregation) close() {
l.aggregation.Close()
l.aggregation = timerAggregation{}
l.sourcesSeen = nil
l.lastUpdatedAt = 0
l.dirty = false
l.closed = false
l.resendEnabled = false
*l = lockedTimerAggregation{}
lockedTimerAggregationPool.Put(l)
}
6 changes: 5 additions & 1 deletion src/aggregator/aggregator/generic_elem.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,11 @@ func (e *GenericElem) findOrCreate(
sourcesSeen = make(map[uint32]*bitset.BitSet)
}
}
// lockedAggregation will be returned to pool on timedAggregation close
// NB(vytenis): lockedAggregation will be returned to pool on timedAggregation close.
// this is a bit different from regular pattern of using a pool object due to codegen with Genny limitations,
// so we can avoid writing more boilerplate.
// timedAggregation itself is always pass-by-value, but lockedAggregation incurs an expensive allocation on heap
// in the critical path (30%+, depending on workload as of 2020-05-01): see https://github.com/m3db/m3/pull/4109
timedAgg = timedAggregation{
startAt: alignedStart,
lockedAgg: lockedAggregationFromPool(
Expand Down

0 comments on commit af3cade

Please sign in to comment.