mirror of
https://github.com/golang/go
synced 2024-11-18 09:54:57 -07:00
runtime: update heap profile stats after world is started
Updating the heap profile stats is one of the most expensive parts of mark termination other than stack rescanning, but there's really no need to do this with the world stopped. Move it to right after we've started the world back up. This creates a *very* small window where allocations from the next cycle can slip into the profile, but the exact point where mark termination happens is so non-deterministic already that a slight reordering here is unimportant. Change-Id: I2f76f22c70329923ad6a594a2c26869f0736d34e Reviewed-on: https://go-review.googlesource.com/31363 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
9429aab999
commit
5b7497f327
@ -1276,6 +1276,18 @@ func gcMarkTermination() {
|
|||||||
|
|
||||||
systemstack(startTheWorldWithSema)
|
systemstack(startTheWorldWithSema)
|
||||||
|
|
||||||
|
// Update heap profile stats if gcSweep didn't do it. This is
|
||||||
|
// relatively expensive, so we don't want to do it while the
|
||||||
|
// world is stopped, but it needs to happen ASAP after
|
||||||
|
// starting the world to prevent too many allocations from the
|
||||||
|
// next cycle leaking in. It must happen before releasing
|
||||||
|
// worldsema since there are applications that do a
|
||||||
|
// runtime.GC() to update the heap profile and then
|
||||||
|
// immediately collect the profile.
|
||||||
|
if _ConcurrentSweep && work.mode != gcForceBlockMode {
|
||||||
|
mProf_GC()
|
||||||
|
}
|
||||||
|
|
||||||
// Free stack spans. This must be done between GC cycles.
|
// Free stack spans. This must be done between GC cycles.
|
||||||
systemstack(freeStackSpans)
|
systemstack(freeStackSpans)
|
||||||
|
|
||||||
@ -1714,7 +1726,6 @@ func gcSweep(mode gcMode) {
|
|||||||
ready(sweep.g, 0, true)
|
ready(sweep.g, 0, true)
|
||||||
}
|
}
|
||||||
unlock(&sweep.lock)
|
unlock(&sweep.lock)
|
||||||
mProf_GC()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func gcCopySpans() {
|
func gcCopySpans() {
|
||||||
|
Loading…
Reference in New Issue
Block a user