-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
pkg/debugutil: add 'mutex' profiler (Go 1.8+) #7765
Conversation
pkg/debugutil/pprof.go
Outdated
) | ||
|
||
const HTTPPrefixPProf = "/debug/pprof" | ||
|
||
func init() { | ||
// 1 out of 5 mutex events are reported, on average | ||
runtime.SetMutexProfileFraction(5) |
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.
This will enable mutex profiling even if it's not exposed via http.
Calling it in PProfHandlers
would avoid the unconditional enable. Also, maybe also check if it's already been set so it won't clobber any existing settings:
if runtime.SetMutexProfileFraction(-1) != 0 {
// 1 out of 5 mutex events are reported, on average
runtime.SetMutexProfileFraction(5)
}
Signed-off-by: Gyu-Ho Lee <[email protected]>
@heyitsanthony PTAL. And did you mean? if runtime.SetMutexProfileFraction(-1) == 0 {
// 1 out of 5 mutex events are reported, on average
runtime.SetMutexProfileFraction(5)
}
|
lgtm. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #7765 +/- ##
==========================================
- Coverage 75.79% 75.61% -0.18%
==========================================
Files 331 331
Lines 26050 26053 +3
==========================================
- Hits 19744 19700 -44
- Misses 4878 4917 +39
- Partials 1428 1436 +8
Continue to review full report at Codecov.
|
Sample output