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

Metric histogram aggregator: Swap in SynchronizedMove to avoid allocations #1435

Merged
merged 7 commits into from Jan 14, 2021

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Jan 4, 2021

The target Aggregator of a SynchronizedMove (for synchronous instruments, typically ValueRecorder) has a reference to a slice that is effectively discarded. This PR avoids that by recycling the allocated slice when possible.

@jmacd jmacd added the area:metrics Part of OpenTelemetry Metrics label Jan 4, 2021
@codecov
Copy link

codecov bot commented Jan 4, 2021

Codecov Report

Merging #1435 (2381491) into master (c29c6fd) will decrease coverage by 0.2%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1435     +/-   ##
========================================
- Coverage    79.2%   78.9%   -0.3%     
========================================
  Files         128     128             
  Lines        6642    6672     +30     
========================================
+ Hits         5263    5269      +6     
- Misses       1124    1148     +24     
  Partials      255     255             
Impacted Files Coverage Δ
sdk/metric/aggregator/histogram/histogram.go 96.2% <100.0%> (+0.4%) ⬆️
sdk/export/metric/exportkind_string.go 57.1% <0.0%> (-42.9%) ⬇️
label/type_string.go 7.1% <0.0%> (-26.2%) ⬇️
metric/instrumentkind_string.go 10.0% <0.0%> (-23.4%) ⬇️
metric/number/kind_string.go 16.6% <0.0%> (-16.7%) ⬇️

// lock below.
o.clearState()
}

c.lock.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the SynchronizedMove function comment still true? "Since no locks are taken, there is a chance that the independent Sum, Count and Bucket Count are not consistent with each other."

@jmacd
Copy link
Contributor Author

jmacd commented Jan 5, 2021

@bogdandrutu Please review.

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Sam Xie <xsambundy@gmail.com>
@@ -38,7 +38,7 @@ type (
lock sync.Mutex
boundaries []float64
kind number.Kind
state state
state *state
Copy link
Member

Choose a reason for hiding this comment

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

State has only 40B, not sure you need to use pointer here.

@Aneurysm9 Aneurysm9 merged commit 207587b into open-telemetry:master Jan 14, 2021
@jmacd jmacd deleted the jmacd/swaphisto branch June 18, 2021 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants