-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
Codecov Report
@@ 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
|
// lock below. | ||
o.clearState() | ||
} | ||
|
||
c.lock.Lock() |
There was a problem hiding this comment.
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."
@bogdandrutu Please review. |
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 |
There was a problem hiding this comment.
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.
The target Aggregator of a
SynchronizedMove
(for synchronous instruments, typicallyValueRecorder
) has a reference to a slice that is effectively discarded. This PR avoids that by recycling the allocated slice when possible.