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

Statsdreceiver optimizations #33683

Merged
merged 4 commits into from
Jun 22, 2024
Merged

Conversation

hardproblems
Copy link
Contributor

@hardproblems hardproblems commented Jun 20, 2024

Description:
Optimize statsdreceiver code to reduce heap usage
Also reduce failCnt increment to reduce memory footprint in cases of tons of malformed statsd messages

Link to tracking Issue:

Testing:

  • Tested internally and saw a 17% reduction in object allocation from our workloads (with ~2.5k/s statsd metrics input) mostly from reduction of strings.Split
    Screenshot is from go tool pprof -http:8081 -diff_base baseline.heap.gz optimized.heap.gz
    Screenshot 2024-06-20 at 12 45 17 PM

Note: I also saw lots of allocations from attribute.NewSet but idk the best way to go about reducing that. (Screenshot below is from unoptimized statsdreceiver)
Screenshot 2024-06-20 at 12 44 32 PM

I tried changing statsDMetricDescription's attrs field to map[string]any in the hopes of using attributes.FromRaw in buildGaugeMetric but it would require replacing statsDMetricDescription as the type of the map key in instruments.gauges, etc.

Documentation:

@jmacd @dmitryax

@hardproblems hardproblems requested a review from a team June 20, 2024 19:53
@github-actions github-actions bot added the receiver/statsd statsd related issues label Jun 20, 2024
@hardproblems hardproblems force-pushed the statsd-optimize branch 5 times, most recently from c9d26d1 to 6f02d29 Compare June 21, 2024 04:57
Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work.

@dmitryax dmitryax merged commit 46e828e into open-telemetry:main Jun 22, 2024
154 checks passed
@github-actions github-actions bot added this to the next release milestone Jun 22, 2024
martin-majlis-s1 pushed a commit to scalyr/opentelemetry-collector-contrib that referenced this pull request Jun 24, 2024
**Description:**
Optimize statsdreceiver code to reduce heap usage
Also reduce failCnt increment to reduce memory footprint in cases of
tons of malformed statsd messages

**Link to tracking Issue:** <Issue number if applicable>

**Testing:**
- Tested internally and saw a 17% reduction in object allocation from
our workloads (with ~2.5k/s statsd metrics input) mostly from reduction
of strings.Split
Screenshot is from `go tool pprof -http:8081 -diff_base baseline.heap.gz
optimized.heap.gz`
![Screenshot 2024-06-20 at 12 45
17 PM](https://github.com/open-telemetry/opentelemetry-collector-contrib/assets/142453/e8065097-2533-4934-9b78-c0e828e075ac)

Note: I also saw lots of allocations from attribute.NewSet but idk the
best way to go about reducing that. (Screenshot below is from
unoptimized statsdreceiver)
![Screenshot 2024-06-20 at 12 44
32 PM](https://github.com/open-telemetry/opentelemetry-collector-contrib/assets/142453/293553c0-92c8-465b-872a-ddb7b68299a0)

I tried changing statsDMetricDescription's attrs field to
`map[string]any` in the hopes of using attributes.FromRaw in
buildGaugeMetric but it would require replacing statsDMetricDescription
as the type of the map key in instruments.gauges, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
receiver/statsd statsd related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants