// gcphase == _GCmark.
var gcBlackenEnabled uint32
-// gcBlackenPromptly indicates that optimizations that may
-// hide work from the global work queue should be disabled.
-//
-// If gcBlackenPromptly is true, per-P gcWork caches should
-// be flushed immediately and new objects should be allocated black.
-//
-// There is a tension between allocating objects white and
-// allocating them black. If white and the objects die before being
-// marked they can be collected during this GC cycle. On the other
-// hand allocating them black will reduce _GCmarktermination latency
-// since more work is done in the mark phase. This tension is resolved
-// by allocating white until the mark phase is approaching its end and
-// then allocating black for the remainder of the mark phase.
-var gcBlackenPromptly bool
-
const (
_GCoff = iota // GC not running; sweeping in background, write barrier disabled
_GCmark // GC marking roots and workbufs: allocate black, write barrier ENABLED
// World is stopped.
// Start marktermination which includes enabling the write barrier.
atomic.Store(&gcBlackenEnabled, 0)
- gcBlackenPromptly = false
setGCPhase(_GCmarktermination)
work.heap1 = memstats.heap_live
casgstatus(gp, _Gwaiting, _Grunning)
})
- // If we are nearing the end of mark, dispose
- // of the cache promptly. We must do this
- // before signaling that we're no longer
- // working so that other workers can't observe
- // no workers and no work while we have this
- // cached, and before we compute done.
- if gcBlackenPromptly {
- _p_.gcw.dispose()
- }
-
// Account for time.
duration := nanotime() - startTime
switch _p_.gcMarkWorkerMode {
// will be more cache friendly.
gcw := &getg().m.p.ptr().gcw
workDone := gcDrainN(gcw, scanWork)
- // If we are near the end of the mark phase
- // dispose of the gcw.
- if gcBlackenPromptly {
- gcw.dispose()
- }
casgstatus(gp, _Gwaiting, _Grunning)
incnwait := atomic.Xadd(&work.nwait, +1)
if incnwait > work.nproc {
println("runtime: work.nwait=", incnwait,
- "work.nproc=", work.nproc,
- "gcBlackenPromptly=", gcBlackenPromptly)
+ "work.nproc=", work.nproc)
throw("work.nwait > work.nproc")
}
if obj, span, objIndex := findObject(b, 0, 0); obj != 0 {
gcw := &getg().m.p.ptr().gcw
greyobject(obj, 0, 0, span, gcw, objIndex)
- if gcphase == _GCmarktermination || gcBlackenPromptly {
+ if gcphase == _GCmarktermination {
// Ps aren't allowed to cache work during mark
// termination.
gcw.dispose()
//go:nowritebarrier
//go:nosplit
func gcmarknewobject(obj, size, scanSize uintptr) {
- if useCheckmark && !gcBlackenPromptly { // The world should be stopped so this should not happen.
+ if useCheckmark { // The world should be stopped so this should not happen.
throw("gcmarknewobject called while doing checkmark")
}
markBitsForAddr(obj).setMarked()
gcw := &getg().m.p.ptr().gcw
gcw.bytesMarked += uint64(size)
gcw.scanWork += int64(scanSize)
- if gcBlackenPromptly {
- // There shouldn't be anything in the work queue, but
- // we still need to flush stats.
- gcw.dispose()
- }
}
// gcMarkTinyAllocs greys all active tiny alloc blocks.
_, span, objIndex := findObject(c.tiny, 0, 0)
gcw := &p.gcw
greyobject(c.tiny, 0, 0, span, gcw, objIndex)
- if gcBlackenPromptly {
- gcw.dispose()
- }
}
}
// (preemption must be disabled)
// gcw := &getg().m.p.ptr().gcw
// .. call gcw.put() to produce and gcw.get() to consume ..
-// if gcBlackenPromptly {
-// gcw.dispose()
-// }
//
// It's important that any use of gcWork during the mark phase prevent
// the garbage collector from transitioning to mark termination since
// Mark the finalizer itself, since the
// special isn't part of the GC'd heap.
scanblock(uintptr(unsafe.Pointer(&s.fn)), sys.PtrSize, &oneptrmask[0], gcw)
- if gcBlackenPromptly {
- gcw.dispose()
- }
releasem(mp)
}
return true
func (b *wbBuf) reset() {
start := uintptr(unsafe.Pointer(&b.buf[0]))
b.next = start
- if gcBlackenPromptly || writeBarrier.cgo {
+ if writeBarrier.cgo {
// Effectively disable the buffer by forcing a flush
// on every barrier.
b.end = uintptr(unsafe.Pointer(&b.buf[wbBufEntryPointers]))
// Enqueue the greyed objects.
gcw.putBatch(ptrs[:pos])
- if gcphase == _GCmarktermination || gcBlackenPromptly {
+ if gcphase == _GCmarktermination {
// Ps aren't allowed to cache work during mark
// termination.
gcw.dispose()
// system stack.
gcw := &gp.m.p.ptr().gcw
scanstack(gp, gcw)
- if gcBlackenPromptly {
- gcw.dispose()
- }
gp.gcscandone = true
}
gp.preemptscan = false