]> Cypherpunks repositories - gostls13.git/commit
runtime: multi-threaded, utilization-scheduled background mark
authorAustin Clements <austin@google.com>
Tue, 24 Mar 2015 01:07:33 +0000 (21:07 -0400)
committerAustin Clements <austin@google.com>
Tue, 21 Apr 2015 15:35:32 +0000 (15:35 +0000)
commit8d03acce544a2301eecec83a88396e568f4c8c75
treee837faa078df50739c14929f73726e2d03dce873
parentaf060c3086941299c399604fe0dc29388f4a6302
runtime: multi-threaded, utilization-scheduled background mark

Currently, the concurrent mark phase is performed by the main GC
goroutine. Prior to the previous commit enabling preemption, this
caused marking to always consume 1/GOMAXPROCS of the available CPU
time. If GOMAXPROCS=1, this meant background GC would consume 100% of
the CPU (effectively a STW). If GOMAXPROCS>4, background GC would use
less than the goal of 25%. If GOMAXPROCS=4, background GC would use
the goal 25%, but if the mutator wasn't using the remaining 75%,
background marking wouldn't take advantage of the idle time. Enabling
preemption in the previous commit made GC miss CPU targets in
completely different ways, but set us up to bring everything back in
line.

This change replaces the fixed GC goroutine with per-P background mark
goroutines. Once started, these goroutines don't go in the standard
run queues; instead, they are scheduled specially such that the time
spent in mutator assists and the background mark goroutines totals 25%
of the CPU time available to the program. Furthermore, this lets
background marking take advantage of idle Ps, which significantly
boosts GC performance for applications that under-utilize the CPU.

This requires also changing how time is reported for gctrace, so this
change splits the concurrent mark CPU time into assist/background/idle
scanning.

This also requires increasing the size of the StackRecord slice used
in a GoroutineProfile test.

Change-Id: I0936ff907d2cee6cb687a208f2df47e8988e3157
Reviewed-on: https://go-review.googlesource.com/8850
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mgc.go
src/runtime/mgcmark.go
src/runtime/proc1.go
src/runtime/runtime2.go
src/runtime/runtime_unix_test.go
src/runtime/traceback.go