Skip to content

Commit 6def07c

Browse files
committed
[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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent fb0c3ee commit 6def07c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/cmd/link/internal/benchmark/bench.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ func (m *Metrics) closeMark() {
134134
return
135135
}
136136
m.curMark.endT = time.Now()
137-
runtime.ReadMemStats(&m.curMark.endM)
138-
if m.gc == GC {
139-
runtime.GC()
140-
runtime.ReadMemStats(&m.curMark.gcM)
141-
}
142137
if m.shouldPProf() {
143138
pprof.StopCPUProfile()
144139
m.pprofFile.Close()
145140
m.pprofFile = nil
146-
if m.gc == GC {
141+
}
142+
runtime.ReadMemStats(&m.curMark.endM)
143+
if m.gc == GC {
144+
runtime.GC()
145+
runtime.ReadMemStats(&m.curMark.gcM)
146+
if m.shouldPProf() {
147147
// Collect a profile of the live heap. Do a
148148
// second GC to force sweep completion so we
149149
// get a complete snapshot of the live heap at

0 commit comments

Comments
 (0)