Commit 1be3e76e authored by Austin Clements's avatar Austin Clements

runtime: simplify heap profile flushing

Currently the heap profile is flushed by *either* gcSweep in STW mode
or by gcMarkTermination in concurrent mode. Simplify this by making
gcMarkTermination always flush the heap profile and by making gcSweep
do one extra flush (instead of two) in STW mode.

Change-Id: I62147afb2a128e1f3d92ef4bb8144c8a345f53c4
Reviewed-on: https://go-review.googlesource.com/37715
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent eee85fc5
......@@ -1302,23 +1302,17 @@ func gcMarkTermination() {
sweep.nbgsweep = 0
sweep.npausesweep = 0
// If gcSweep didn't do it, finish the current heap profiling
// cycle and start a new heap profiling cycle. We do this
// before starting the world so events don't leak into the
// wrong cycle.
needProfCycle := _ConcurrentSweep && work.mode != gcForceBlockMode
if needProfCycle {
// Finish the current heap profiling cycle and start a new
// heap profiling cycle. We do this before starting the world
// so events don't leak into the wrong cycle.
mProf_NextCycle()
}
systemstack(startTheWorldWithSema)
// Flush the heap profile so we can start a new cycle next GC.
// This is relatively expensive, so we don't do it with the
// world stopped.
if needProfCycle {
mProf_Flush()
}
// Free stack spans. This must be done between GC cycles.
systemstack(freeStackSpans)
......@@ -1763,10 +1757,9 @@ func gcSweep(mode gcMode) {
for sweepone() != ^uintptr(0) {
sweep.npausesweep++
}
// All "free" events are now real, so flush everything
// into the published profile.
mProf_NextCycle()
mProf_Flush()
// All "free" events for this mark/sweep cycle have
// now happened, so we can make this profile cycle
// available immediately.
mProf_NextCycle()
mProf_Flush()
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment