Commit e8d5989e authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: fix compilebench -alloc

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent ea7d9e6a
...@@ -57,8 +57,13 @@ func startProfile() { ...@@ -57,8 +57,13 @@ func startProfile() {
Fatalf("%v", err) Fatalf("%v", err)
} }
atExit(func() { atExit(func() {
runtime.GC() // profile all outstanding allocations // Profile all outstanding allocations.
if err := pprof.WriteHeapProfile(f); err != nil { 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) Fatalf("%v", err)
} }
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment