mirror of
https://github.com/golang/go
synced 2024-11-12 07:00:21 -07:00
cmd/link: write memprofile in legacy format for compilebench
compilebench depends on the legacy heap profile format to read the allocation stats of build tools. We're adding a benchmark for the linker to compilebench, so we need the linker to emit the heap profile in the legacy format. This is the linker equivalent of CL 35484, which did this for the compiler. Change-Id: I16ad60c4f0fd80b4b6d608a5677ebe04e1fb5e5a Reviewed-on: https://go-review.googlesource.com/c/go/+/176057 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
d21c7b7282
commit
7498e8f5a2
@ -319,8 +319,13 @@ func startProfile() {
|
||||
log.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 {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user