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

Add a benchmark for histogram allocations #3635

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

MadVikingGod
Copy link
Contributor

This adds a simple histogram benchmark to measure the allocations done in collect().

The output from the benchmark is currently:

BenchmarkCollectHistograms/1-16          1166540              1023 ns/op             592 B/op          6 allocs/op
BenchmarkCollectHistograms/5-16           302680              3710 ns/op            2640 B/op         22 allocs/op
BenchmarkCollectHistograms/10-16          160407              6953 ns/op            5200 B/op         42 allocs/op
BenchmarkCollectHistograms/25-16           66810             17389 ns/op           13072 B/op        102 allocs/op

So from a linear regression we can see there is a baseline of 2 allocations of any number of histograms, from creating rm.ScopeMetrics and rm.ScopeMetrics.Metrics. 1
We can also see the slope of the regression is 4, so there are 4 allocations per histogram created. 2 of these are created by copying the bounds and the count slices. 2

This is just something to set our baseline for #3047.

Footnotes

  1. Not tested here, but we would expect this to be 1+ the number of scopes that produced metrics.

  2. This is also done for Delta Histograms.

@MadVikingGod MadVikingGod added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jan 31, 2023
@codecov
Copy link

codecov bot commented Feb 2, 2023

Codecov Report

Merging #3635 (8dbede3) into main (aa51224) will increase coverage by 0.0%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #3635   +/-   ##
=====================================
  Coverage   79.6%   79.7%           
=====================================
  Files        171     171           
  Lines      12673   12673           
=====================================
+ Hits       10099   10105    +6     
+ Misses      2361    2355    -6     
  Partials     213     213           
Impacted Files Coverage Δ
exporters/jaeger/jaeger.go 91.1% <0.0%> (+0.8%) ⬆️
sdk/trace/batch_span_processor.go 81.9% <0.0%> (+1.7%) ⬆️

@MrAlias MrAlias merged commit 5e8eb85 into open-telemetry:main Feb 2, 2023
@MrAlias MrAlias added this to the Metric v0.36.0 milestone Feb 8, 2023
@MadVikingGod MadVikingGod deleted the mvg/histo-benchmark branch February 21, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants