From a51905fa04fafaa8284d5a4585a81da249f9d8fd Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 23 Oct 2015 15:55:03 -0400 Subject: runtime: decentralize sweep termination and mark transition This moves all of GC initialization, sweep termination, and the transition to concurrent marking in to the off->mark transition function. This means it's now handled on the goroutine that detected the state exit condition. As a result, malloc no longer needs to Gosched() at the beginning of the GC cycle to prevent over-allocation while the GC is starting up because it will now *help* the GC to start up. The Gosched hack is still necessary during GC shutdown (this is easy to test by enabling gctrace and hitting Ctrl-S to block the gctrace output). At this point, the GC coordinator still handles later phases. This requires a small tweak to how we start the GC coordinator. Currently, starting the GC coordinator is best-effort and may fail if the coordinator is about to park from the previous cycle but hasn't yet. We fix this by replacing the park/ready to wake up the coordinator with a semaphore. This is temporary since the coordinator will be going away in a few commits. Updates #11970. Change-Id: I2c6a11c91e72dfbc59c2d8e7c66146dee9a444fe Reviewed-on: https://go-review.googlesource.com/16357 Reviewed-by: Rick Hudson Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot --- src/runtime/malloc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime/malloc.go') diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 230849609f..45ebe712ba 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -737,7 +737,7 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer { if shouldhelpgc && gcShouldStart(false) { gcStart(gcBackgroundMode, false) } else if shouldhelpgc && bggc.working != 0 && gcBlackenEnabled == 0 { - // The GC is starting up or shutting down, so we can't + // The GC shutting down, so we can't // assist, but we also can't allocate unabated. Slow // down this G's allocation and help the GC stay // scheduled by yielding. -- cgit v1.3-5-g9baa