mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: run background mark helpers only if work is available
Prior to this CL whenever the GC marking was enabled and a P was looking for work we supplied a G to help the GC do its marking tasks. Once this G finished all the marking available it would release the P to find another available G. In the case where there was no work the P would drop into findrunnable which would execute the mark helper G which would immediately return and the P would drop into findrunnable again repeating the process. Since the P was always given a G to run it never blocks. This CL first checks if the GC mark helper G has available work and if not the P immediately falls through to its blocking logic. Fixes #10901 Change-Id: I94ac9646866ba64b7892af358888bc9950de23b5 Reviewed-on: https://go-review.googlesource.com/10189 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
f4d51eb2f5
commit
913db7685e
3 changed files with 20 additions and 1 deletions
|
|
@ -1479,7 +1479,7 @@ stop:
|
|||
// We have nothing to do. If we're in the GC mark phase and can
|
||||
// safely scan and blacken objects, run idle-time marking
|
||||
// rather than give up the P.
|
||||
if _p_ := _g_.m.p.ptr(); gcBlackenEnabled != 0 && _p_.gcBgMarkWorker != nil {
|
||||
if _p_ := _g_.m.p.ptr(); gcBlackenEnabled != 0 && _p_.gcBgMarkWorker != nil && gcMarkWorkAvailable(_p_) {
|
||||
_p_.gcMarkWorkerMode = gcMarkWorkerIdleMode
|
||||
gp := _p_.gcBgMarkWorker
|
||||
casgstatus(gp, _Gwaiting, _Grunnable)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue