]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/pprof: allow "seconds" parameters to most profiles
authorHana (Hyang-Ah) Kim <hyangah@gmail.com>
Wed, 22 Apr 2020 20:24:30 +0000 (16:24 -0400)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Wed, 22 Apr 2020 21:08:58 +0000 (21:08 +0000)
golang.org/cl/147598 added the support for delta computation for mutex
and block profiles. In fact, this delta computation makes sense for
other types of profiles.

For example, /debug/pprof/allocs?seconds=x will provide how much allocation
was made during the specified period. /debug/pprof/goroutine?seconds=x will
provide the changes in the list of goroutines. This also makes sense for
custom profiles.

Update #23401
Update google/pprof#526

Change-Id: I45e9073eb001ea5b3f3d16e5a57f635193610656
Reviewed-on: https://go-review.googlesource.com/c/go/+/229537
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
src/net/http/pprof/pprof.go
src/net/http/pprof/pprof_test.go

index 36b0af452dd2f5ff36972300eab2ff2aad747920..4fd19eb539d282e0143bac48e0430c1373807402 100644 (file)
@@ -334,8 +334,12 @@ func collectProfile(p *pprof.Profile) (*profile.Profile, error) {
 }
 
 var profileSupportsDelta = map[handler]bool{
-       "block": true,
-       "mutex": true,
+       "allocs":       true,
+       "block":        true,
+       "goroutine":    true,
+       "heap":         true,
+       "mutex":        true,
+       "threadcreate": true,
 }
 
 var profileDescriptions = map[string]string{
index 49c4c81caa003687f6827e82a6c76a4dd9810186..f6f9ef5b041c42eef2fccf779b46f78784c1081c 100644 (file)
@@ -49,6 +49,7 @@ func TestHandlers(t *testing.T) {
                {"/debug/pprof/trace", Trace, http.StatusOK, "application/octet-stream", `attachment; filename="trace"`, nil},
                {"/debug/pprof/mutex", Index, http.StatusOK, "application/octet-stream", `attachment; filename="mutex"`, nil},
                {"/debug/pprof/block?seconds=1", Index, http.StatusOK, "application/octet-stream", `attachment; filename="block-delta"`, nil},
+               {"/debug/pprof/goroutine?seconds=1", Index, http.StatusOK, "application/octet-stream", `attachment; filename="goroutine-delta"`, nil},
                {"/debug/pprof/", Index, http.StatusOK, "text/html; charset=utf-8", "", []byte("Types of profiles available:")},
        }
        for _, tc := range testCases {