From d0b6d01d6be7ace2ee5c7cdf53eca7b4db539c0e Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Tue, 18 Apr 2017 10:00:09 -0700 Subject: [PATCH] pkg/debugutil: add 'mutex' profiler (Go 1.8+) Signed-off-by: Gyu-Ho Lee --- pkg/debugutil/pprof.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/debugutil/pprof.go b/pkg/debugutil/pprof.go index 2e87124b827d..2df13a7352cd 100644 --- a/pkg/debugutil/pprof.go +++ b/pkg/debugutil/pprof.go @@ -17,10 +17,16 @@ package debugutil import ( "net/http" "net/http/pprof" + "runtime" ) const HTTPPrefixPProf = "/debug/pprof" +func init() { + // 1 out of 5 mutex events are reported, on average + runtime.SetMutexProfileFraction(5) +} + // PProfHandlers returns a map of pprof handlers keyed by the HTTP path. func PProfHandlers() map[string]http.Handler { m := make(map[string]http.Handler) @@ -34,6 +40,7 @@ func PProfHandlers() map[string]http.Handler { m[HTTPPrefixPProf+"/goroutine"] = pprof.Handler("goroutine") m[HTTPPrefixPProf+"/threadcreate"] = pprof.Handler("threadcreate") m[HTTPPrefixPProf+"/block"] = pprof.Handler("block") + m[HTTPPrefixPProf+"/mutex"] = pprof.Handler("mutex") return m }