]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: finish phase CPU profile before running GC
authorAustin Clements <austin@google.com>
Fri, 20 Mar 2020 20:54:10 +0000 (16:54 -0400)
committerAustin Clements <austin@google.com>
Sat, 21 Mar 2020 13:48:38 +0000 (13:48 +0000)
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 <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/benchmark/bench.go

index 7b8492ec85f9d68783c2f65c74ef3a9df3acda72..6c163c801ee8d67ac2c5d8384a9475bc2e4ca505 100644 (file)
@@ -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