Commit ecc36596 authored by Austin Clements's avatar Austin Clements

runtime: avoid using STW GC mechanism for checkmarks mode

Currently, checkmarks mode uses the full STW GC infrastructure to
perform mark checking. We're about to remove that infrastructure and,
furthermore, since checkmarks is about doing the simplest thing
possible to check concurrent GC, it's valuable for it to be simpler.

Hence, this CL makes checkmarks even simpler by making it non-parallel
and divorcing it from the STW GC infrastructure (including the
gchelper mechanism).

Updates #26903. This is preparation for unifying STW GC and concurrent
GC.

Change-Id: Iad21158123e025e3f97d7986d577315e994bd43e
Reviewed-on: https://go-review.googlesource.com/c/134776
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent 918ed88e
...@@ -1513,12 +1513,16 @@ func gcMarkTermination(nextTriggerRatio float64) { ...@@ -1513,12 +1513,16 @@ func gcMarkTermination(nextTriggerRatio float64) {
systemstack(func() { systemstack(func() {
work.heap2 = work.bytesMarked work.heap2 = work.bytesMarked
if debug.gccheckmark > 0 { if debug.gccheckmark > 0 {
// Run a full stop-the-world mark using checkmark bits, // Run a full non-parallel, stop-the-world
// to check that we didn't forget to mark anything during // mark using checkmark bits, to check that we
// the concurrent mark process. // didn't forget to mark anything during the
// concurrent mark process.
gcResetMarkState() gcResetMarkState()
initCheckmarks() initCheckmarks()
gcMark(startTime) gcw := &getg().m.p.ptr().gcw
gcDrain(gcw, gcDrainNoBlock)
wbBufFlush1(getg().m.p.ptr())
gcw.dispose()
clearCheckmarks() clearCheckmarks()
} }
...@@ -1905,12 +1909,12 @@ func gcMark(start_time int64) { ...@@ -1905,12 +1909,12 @@ func gcMark(start_time int64) {
work.helperDrainBlock = false work.helperDrainBlock = false
} else { } else {
// There's marking work to do. This is the case during // There's marking work to do. This is the case during
// STW GC and in checkmark mode. Instruct GC workers // STW GC. Instruct GC workers
// to block in getfull until all GC workers are in getfull. // to block in getfull until all GC workers are in getfull.
// //
// TODO(austin): Move STW and checkmark marking out of // TODO(austin): Move STW marking out of
// mark termination and eliminate this code path. // mark termination and eliminate this code path.
if !useCheckmark && debug.gcstoptheworld == 0 && debug.gcrescanstacks == 0 { if debug.gcstoptheworld == 0 && debug.gcrescanstacks == 0 {
print("runtime: full=", hex(work.full), " nDataRoots=", work.nDataRoots, " nBSSRoots=", work.nBSSRoots, " nSpanRoots=", work.nSpanRoots, " nStackRoots=", work.nStackRoots, "\n") print("runtime: full=", hex(work.full), " nDataRoots=", work.nDataRoots, " nBSSRoots=", work.nBSSRoots, " nSpanRoots=", work.nSpanRoots, " nStackRoots=", work.nStackRoots, "\n")
panic("non-empty mark queue after concurrent mark") panic("non-empty mark queue after concurrent mark")
} }
......
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