aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2017-01-20 08:11:34 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2017-01-20 18:57:23 +0000
commite8d5989ed1272bed3600193003ebc9980bcb9275 (patch)
tree88364b9ec02ca496e3ba70b6d3bf6ce4084c6ad0
parentea7d9e6a52ca64c200dcc75621e75f209ceceace (diff)
downloadgo-e8d5989ed1272bed3600193003ebc9980bcb9275.tar.gz
go-e8d5989ed1272bed3600193003ebc9980bcb9275.zip
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: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
-rw-r--r--src/cmd/compile/internal/gc/util.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/util.go b/src/cmd/compile/internal/gc/util.go
index bb5cede5a6..c62bd00808 100644
--- a/src/cmd/compile/internal/gc/util.go
+++ b/src/cmd/compile/internal/gc/util.go
@@ -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)
}
})