]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix compilebench -alloc
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 20 Jan 2017 16:11:34 +0000 (08:11 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 20 Jan 2017 18:57:23 +0000 (18:57 +0000)
pprof.WriteHeapProfile is shorthand for
pprof.Lookup("heap").WriteTo(f, 0).
The second parameter is debug.
If it is non-zero, pprof writes legacy-format
pprof output, which compilebench can parse.

Fixes #18641

Change-Id: Ica69adeb9809e9b5933aed943dcf4a07910e43fc
Reviewed-on: https://go-review.googlesource.com/35484
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/util.go

index bb5cede5a60da75f700594c4aede4dacfa39ae01..c62bd00808f21c625343a495cebc31aab4747b30 100644 (file)
@@ -57,8 +57,13 @@ func startProfile() {
                        Fatalf("%v", err)
                }
                atExit(func() {
-                       runtime.GC() // profile all outstanding allocations
-                       if err := pprof.WriteHeapProfile(f); err != nil {
+                       // Profile all outstanding allocations.
+                       runtime.GC()
+                       // compilebench parses the memory profile to extract memstats,
+                       // which are only written in the legacy pprof format.
+                       // See golang.org/issue/18641 and runtime/pprof/pprof.go:writeHeap.
+                       const writeLegacyFormat = 1
+                       if err := pprof.Lookup("heap").WriteTo(f, writeLegacyFormat); err != nil {
                                Fatalf("%v", err)
                        }
                })