aboutsummaryrefslogtreecommitdiff
path: root/weed/util/grace/pprof.go
diff options
context:
space:
mode:
authorBl1tz23 <alex3angle@gmail.com>2021-08-10 13:45:24 +0300
committerBl1tz23 <alex3angle@gmail.com>2021-08-10 13:45:24 +0300
commit1c94b3d01340baad000188550fcf2ccab6ca80e5 (patch)
tree12c3da17eb2d1a43fef78021a3d7c79110b0ff5f /weed/util/grace/pprof.go
parente6e57db530217ff57b3622b4672b03ebb6313e96 (diff)
parentf9cf9b93d32a2b01bc4d95ce7d24d86ef60be668 (diff)
downloadseaweedfs-1c94b3d01340baad000188550fcf2ccab6ca80e5.tar.xz
seaweedfs-1c94b3d01340baad000188550fcf2ccab6ca80e5.zip
merge master, resolve conflicts
Diffstat (limited to 'weed/util/grace/pprof.go')
-rw-r--r--weed/util/grace/pprof.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/weed/util/grace/pprof.go b/weed/util/grace/pprof.go
index 14686bfc8..28bf6d553 100644
--- a/weed/util/grace/pprof.go
+++ b/weed/util/grace/pprof.go
@@ -14,9 +14,30 @@ func SetupProfiling(cpuProfile, memProfile string) {
if err != nil {
glog.Fatal(err)
}
+ runtime.SetBlockProfileRate(1)
+ runtime.SetMutexProfileFraction(1)
pprof.StartCPUProfile(f)
OnInterrupt(func() {
pprof.StopCPUProfile()
+
+ // write block pprof
+ blockF, err := os.Create(cpuProfile + ".block")
+ if err != nil {
+ return
+ }
+ p := pprof.Lookup("block")
+ p.WriteTo(blockF, 0)
+ blockF.Close()
+
+ // write mutex pprof
+ mutexF, err := os.Create(cpuProfile + ".mutex")
+ if err != nil {
+ return
+ }
+ p = pprof.Lookup("mutex")
+ p.WriteTo(mutexF, 0)
+ mutexF.Close()
+
})
}
if memProfile != "" {