datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

pkg/trace/api: create pool for traces

Open knusbaum opened this issue 1 year ago • 4 comments
trafficstars

What does this PR do?

The decoder regularly allocates space for traces and then discards it. Reducing this should reduce garbage and GC pressure.

Motivation

Additional Notes

For this one, I was not able to make a Go Benchmark work. Instead, I'll attach this image from a profile showing significant reduction in allocations from a local test:

image

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

knusbaum avatar May 31 '24 20:05 knusbaum

Benchmarks

Benchmark execution time: 2024-05-31 20:42:20

Comparing candidate commit c0a2592fc61ed3c85fbef8678d4de0979986d47f in PR branch knusbaum/pool-traces with baseline commit bba6f6d17eb5b0ca7549d63134f837533ce87562 in branch main.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 1 unstable metrics.

scenario:BenchmarkAgentTraceProcessing-24

  • 🟩 allocated_mem [-1.907MB; -1.680MB] or [-45.647%; -40.214%]

pr-commenter[bot] avatar May 31 '24 20:05 pr-commenter[bot]

The profile in the description was not normalized, and it doesn't appear that there's a huge difference. Need to look into this more.

knusbaum avatar May 31 '24 20:05 knusbaum

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=35621324 --os-family=ubuntu

pr-commenter[bot] avatar May 31 '24 21:05 pr-commenter[bot]

Codecov Report

Attention: Patch coverage is 73.09942% with 46 lines in your changes missing coverage. Please review.

Project coverage is 62.27%. Comparing base (9f39b07) to head (c0a2592). Report is 1913 commits behind head on main.

Files with missing lines Patch % Lines
pkg/trace/writer/trace.go 73.91% 20 Missing and 4 partials :warning:
comp/trace/agent/agent_mock.go 0.00% 9 Missing :warning:
pkg/trace/agent/agent.go 66.66% 4 Missing :warning:
...mp/otelcol/otlp/components/statsprocessor/agent.go 62.50% 3 Missing :warning:
pkg/trace/writer/sender.go 78.57% 3 Missing :warning:
pkg/trace/stats/concentrator.go 50.00% 2 Missing :warning:
pkg/trace/writer/stats.go 87.50% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #26205       +/-   ##
===========================================
+ Coverage   45.17%   62.27%   +17.09%     
===========================================
  Files        2346      242     -2104     
  Lines      270606    21085   -249521     
===========================================
- Hits       122246    13130   -109116     
+ Misses     138710     7394   -131316     
+ Partials     9650      561     -9089     
Flag Coverage Δ
amzn_aarch64 62.64% <73.09%> (+16.64%) :arrow_up:
centos_x86_64 62.66% <73.09%> (+16.74%) :arrow_up:
ubuntu_aarch64 62.66% <73.09%> (+16.65%) :arrow_up:
ubuntu_x86_64 62.69% <73.09%> (+16.69%) :arrow_up:
windows_amd64 60.66% <73.09%> (+9.26%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 31 '24 21:05 codecov[bot]