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

Optimize dpgSignature function in Prometheus receiver #2945

Merged
merged 1 commit into from
Apr 19, 2021

Conversation

x13n
Copy link
Contributor

@x13n x13n commented Apr 15, 2021

Description:

dpgSignature is invoked very often, which leads to high CPU usage when
collecting Prometheus metrics.

Benchmark results on my machine show 3x less CPU and almost 4x less
memory used. Since I'm also changing the format of returned values
(dropping superfluous characters), it will reduce overall memory usage
of the receiver, because they are used as map keys.

Benchmark result before this change:

Benchmark_dpgSignature-6 1284531 969.6 ns/op 120 B/op 7 allocs/op

Benchmark result after this change:

Benchmark_dpgSignature-6 3515179 313.9 ns/op 32 B/op 2 allocs/op

Testing: Added benchmark and updated unit tests.

@x13n x13n requested a review from a team April 15, 2021 14:37
@codecov
Copy link

codecov bot commented Apr 15, 2021

Codecov Report

Merging #2945 (82dced9) into main (90b2dec) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2945   +/-   ##
=======================================
  Coverage   91.58%   91.58%           
=======================================
  Files         312      312           
  Lines       15351    15356    +5     
=======================================
+ Hits        14059    14064    +5     
  Misses        883      883           
  Partials      409      409           
Impacted Files Coverage Δ
...iver/prometheusreceiver/internal/metricsbuilder.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 90b2dec...82dced9. Read the comment docs.

@x13n x13n force-pushed the dpgsignature branch 2 times, most recently from 8df19b8 to d64f1c7 Compare April 16, 2021 07:03
@x13n
Copy link
Contributor Author

x13n commented Apr 16, 2021

Just rebased this to HEAD, but contrib_tests keep on failing. Anything else I should be doing about this? The error is not related to this change.

This function is invoked very often, which leads to high CPU usage when
collecting Prometheus metrics.

Benchmark results on my machine show 3x less CPU and almost 4x less
memory used. Since I'm also changing the format of returned values
(dropping superfluous characters), it will reduce overall memory usage
of the receiver, because they are used as map keys.

Benchmark result before this change:

Benchmark_dpgSignature-6   	 1284531	       969.6 ns/op	     120 B/op	       7 allocs/op

Benchmark result after this change:

Benchmark_dpgSignature-6   	 3515179	       313.9 ns/op	      32 B/op	       2 allocs/op
@x13n
Copy link
Contributor Author

x13n commented Apr 19, 2021

Ok, looks like another rebase solved the problem.

@bogdandrutu bogdandrutu merged commit 5db1af0 into open-telemetry:main Apr 19, 2021
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
…lfx-agent (open-telemetry#2945)

* Bump github.com/prometheus/common in /pkg/signalfx-agent

Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.39.0 to 0.42.0.
- [Release notes](https://github.com/prometheus/common/releases)
- [Commits](prometheus/common@v0.39.0...v0.42.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/common
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* make tidy

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants