}
func gc(mode int) {
- // debug.gctrace variables
+ // Timing/utilization tracking
var stwprocs, maxprocs int32
var tSweepTerm, tScan, tInstallWB, tMark, tMarkTerm int64
+
+ // debug.gctrace variables
var heap0, heap1, heap2, heapGoal uint64
// memstats statistics
gcBgMarkStartWorkers()
}
now = nanotime()
- if debug.gctrace > 0 {
- stwprocs, maxprocs = gcprocs(), gomaxprocs
- tSweepTerm = now
- heap0 = memstats.heap_live
- }
+ stwprocs, maxprocs = gcprocs(), gomaxprocs
+ tSweepTerm = now
+ heap0 = memstats.heap_live
pauseStart = now
systemstack(stopTheWorldWithSema)
startTheWorldWithSema()
now = nanotime()
pauseNS += now - pauseStart
- if debug.gctrace > 0 {
- tScan = now
- }
+ tScan = now
gcscan_m()
// Enter mark phase.
- if debug.gctrace > 0 {
- tInstallWB = nanotime()
- }
+ tInstallWB = nanotime()
setGCPhase(_GCmark)
// Ensure all Ps have observed the phase
// change and have write barriers enabled
forEachP(func(*p) {})
})
// Concurrent mark.
- if debug.gctrace > 0 {
- tMark = nanotime()
- }
+ tMark = nanotime()
// Enable background mark workers and wait for
// background mark completion.
// Begin mark termination.
now = nanotime()
- if debug.gctrace > 0 {
- tMarkTerm = now
- }
+ tMarkTerm = now
pauseStart = now
systemstack(stopTheWorldWithSema)
// The gcphase is _GCmark, it will transition to _GCmarktermination
// such that mark termination scans all stacks.
gcResetGState()
- if debug.gctrace > 0 {
- t := nanotime()
- tScan, tInstallWB, tMark, tMarkTerm = t, t, t, t
- heapGoal = heap0
- }
+ t := nanotime()
+ tScan, tInstallWB, tMark, tMarkTerm = t, t, t, t
+ heapGoal = heap0
}
// World is stopped.
gcBlackenPromptly = false
setGCPhase(_GCmarktermination)
- if debug.gctrace > 0 {
- heap1 = memstats.heap_live
- }
-
+ heap1 = memstats.heap_live
startTime := nanotime()
mp := acquirem()
// need to switch to g0 so we can shrink the stack.
systemstack(func() {
gcMark(startTime)
- if debug.gctrace > 0 {
- heap2 = work.bytesMarked
- }
+ heap2 = work.bytesMarked
if debug.gccheckmark > 0 {
// Run a full stop-the-world mark using checkmark bits,
// to check that we didn't forget to mark anything during