Skip to content
This repository was archived by the owner on Aug 30, 2019. It is now read-only.

Commit 47278f4

Browse files
committed
cmd/trace-agent: only export bucket when needed in concentrator
This change moves the `bucket.Export` call to after the precondition where it is needed in an attempt to save some memory and CPU.
1 parent f6a2848 commit 47278f4

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

cmd/trace-agent/concentrator.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,14 @@ func (c *Concentrator) flushNow(now int64) []model.StatsBucket {
144144

145145
c.mu.Lock()
146146
for ts, srb := range c.buckets {
147-
bucket := srb.Export()
148-
149147
// Always keep `bufferLen` buckets (default is 2: current + previous one).
150148
// This is a trade-off: we accept slightly late traces (clock skew and stuff)
151149
// but we delay flushing by at most `bufferLen` buckets.
152150
if ts > now-int64(c.bufferLen)*c.bsize {
153151
continue
154152
}
155-
156153
log.Debugf("flushing bucket %d", ts)
157-
sb = append(sb, bucket)
154+
sb = append(sb, srb.Export())
158155
delete(c.buckets, ts)
159156
}
160157

0 commit comments

Comments
 (0)