From 6def07cf1ec9b4ac5ae8a4cbcddb603e0c3e982b Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 20 Mar 2020 16:54:10 -0400 Subject: [PATCH] [dev.link] cmd/link: finish phase CPU profile before running GC Currently, phase profiling runs GC at the end of a phase before stopping the CPU profile. Rearrange things so we stop the CPU profile right when we collect the end time-stamp and before dealing with GCs and heap profiles. Change-Id: I9a84b9b17c7db7f8cacf591147de15464298b6af Reviewed-on: https://go-review.googlesource.com/c/go/+/224620 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/cmd/link/internal/benchmark/bench.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/link/internal/benchmark/bench.go b/src/cmd/link/internal/benchmark/bench.go index 7b8492ec85..6c163c801e 100644 --- a/src/cmd/link/internal/benchmark/bench.go +++ b/src/cmd/link/internal/benchmark/bench.go @@ -134,16 +134,16 @@ func (m *Metrics) closeMark() { return } m.curMark.endT = time.Now() - runtime.ReadMemStats(&m.curMark.endM) - if m.gc == GC { - runtime.GC() - runtime.ReadMemStats(&m.curMark.gcM) - } if m.shouldPProf() { pprof.StopCPUProfile() m.pprofFile.Close() m.pprofFile = nil - if m.gc == GC { + } + runtime.ReadMemStats(&m.curMark.endM) + if m.gc == GC { + runtime.GC() + runtime.ReadMemStats(&m.curMark.gcM) + if m.shouldPProf() { // Collect a profile of the live heap. Do a // second GC to force sweep completion so we // get a complete snapshot of the live heap at -- 2.48.1