Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-aggregation] return the MetricSampleBatch to the pool only once done with it #17728

Merged
merged 5 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion comp/dogstatsd/server/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func (b *batcher) flushSamplesWithTs() {
tlmChannel.Observe(float64(t2.Sub(t1).Nanoseconds()), "late_metrics")

b.samplesWithTsCount = 0
b.metricSamplePool.PutBatch(b.samplesWithTs)
b.samplesWithTs = b.metricSamplePool.GetBatch()
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/aggregator/demultiplexer_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func initAgentDemultiplexer(log log.Component, sharedForwarder forwarder.Forward
noAggSerializer = serializer.NewSerializer(sharedForwarder, orchestratorForwarder)
noAggWorker = newNoAggregationStreamWorker(
config.Datadog.GetInt("dogstatsd_no_aggregation_pipeline_batch_size"),
metricSamplePool,
noAggSerializer,
agg.flushAndSerializeInParallel,
)
Expand Down
8 changes: 7 additions & 1 deletion pkg/aggregator/no_aggregation_stream_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type noAggregationStreamWorker struct {
flushConfig FlushAndSerializeInParallel
maxMetricsPerPayload int

// pointer to the shared MetricSamplePool stored in the Demultiplexer.
metricSamplePool *metrics.MetricSamplePool

seriesSink *metrics.IterableSeries
sketchesSink *metrics.IterableSketches

Expand Down Expand Up @@ -73,7 +76,8 @@ func init() {
noaggExpvars.Set("Flush", &expvarNoAggFlush)
}

func newNoAggregationStreamWorker(maxMetricsPerPayload int, serializer serializer.MetricSerializer, flushConfig FlushAndSerializeInParallel) *noAggregationStreamWorker {
func newNoAggregationStreamWorker(maxMetricsPerPayload int, metricSamplePool *metrics.MetricSamplePool,
serializer serializer.MetricSerializer, flushConfig FlushAndSerializeInParallel) *noAggregationStreamWorker {
return &noAggregationStreamWorker{
serializer: serializer,
flushConfig: flushConfig,
Expand Down Expand Up @@ -216,6 +220,8 @@ func (w *noAggregationStreamWorker) run() {
tlmNoAggSamplesProcessedUnsupportedType.Add(float64(countUnsupportedType))
expvarNoAggSamplesProcessedUnsupportedType.Add(int64(countUnsupportedType))

w.metricSamplePool.PutBatch(samples) // return the sample batch back to the pool for reuse

if serializedSamples > w.maxMetricsPerPayload {
tlmNoAggFlush.Add(1)
break mainloop // end `Serialize` call and trigger a flush to the forwarder
Expand Down