Commit 12e23f05 authored by Austin Clements's avatar Austin Clements

runtime: eliminate mark completion in scheduler

Currently, findRunnableGCWorker will perform mark completion if there
is no remaining work and no running workers. This used to be necessary
to resolve a race in the transition from mark 1 to mark 2 where we
would enter mark 2 with no mark work (and no dedicated workers), so no
workers would run, so no worker would signal mark completion.

However, we're about to make mark completion also perform the entire
follow-on process, which includes mark termination. We really don't
want to do that in the scheduler if it happens to detect completion.

Conveniently, this hack is no longer necessary because we always
enqueue root scanning work at the beginning of both mark 1 and mark 2,
so a mark worker will always run. Hence, we can simply eliminate it.

Change-Id: I3fc8f27c8da632f0fb732c9f6425e1f457f5652e
Reviewed-on: https://go-review.googlesource.com/16358Reviewed-by: default avatarRick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 20f276e2
......@@ -631,28 +631,6 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
// the end of the mark phase when there are still
// assists tapering off. Don't bother running a worker
// now because it'll just return immediately.
if work.nwait == work.nproc {
// There are also no workers, which
// means we've reached a completion point.
// There may not be any workers to
// signal it, so signal it here.
readied := false
if gcBlackenPromptly {
if work.bgMark1.done == 0 {
throw("completing mark 2, but bgMark1.done == 0")
}
readied = work.bgMark2.complete()
} else {
readied = work.bgMark1.complete()
}
if readied {
// complete just called ready,
// but we're inside the
// scheduler. Let it know that
// that's okay.
resetspinning()
}
}
return nil
}
......@@ -1167,6 +1145,10 @@ func gc(mode gcMode) {
// Rescan global data and BSS. Bump "jobs"
// down before "next" so workers won't try
// running root jobs until we set "next".
//
// This also ensures there will be queued mark
// work, which ensures some mark worker will
// run and signal mark 2 completion.
atomicstore(&work.markrootJobs, uint32(fixedRootCount+work.nDataRoots+work.nBSSRoots))
atomicstore(&work.markrootNext, fixedRootCount)
})
......
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