// Use maxprocs instead of stwprocs here because the total time
// computed in the CPU stats is based on maxprocs, and we want them
// to be comparable.
- work.cpuStats.accumulateGCPauseTime(nanotime()-work.tSweepTerm, work.maxprocs)
+ work.cpuStats.accumulateGCPauseTime(nanotime()-stw.finishedStopping, work.maxprocs)
// Concurrent mark.
systemstack(func() {
now = startTheWorldWithSema(0, stw)
- work.pauseNS += now - stw.start
+ work.pauseNS += now - stw.startedStopping
work.tMark = now
// Release the CPU limiter.
getg().m.preemptoff = ""
systemstack(func() {
now := startTheWorldWithSema(0, stw)
- work.pauseNS += now - stw.start
+ work.pauseNS += now - stw.startedStopping
})
semrelease(&worldsema)
goto top
now := nanotime()
sec, nsec, _ := time_now()
unixNow := sec*1e9 + int64(nsec)
- work.pauseNS += now - stw.start
+ work.pauseNS += now - stw.startedStopping
work.tEnd = now
atomic.Store64(&memstats.last_gc_unix, uint64(unixNow)) // must be Unix time to make sense to user
atomic.Store64(&memstats.last_gc_nanotime, uint64(now)) // monotonic time for us
//
// Pass gcMarkPhase=true to accumulate so we can get all the latest GC CPU stats
// in there too.
- work.cpuStats.accumulateGCPauseTime(work.tEnd-work.tMarkTerm, work.maxprocs)
+ work.cpuStats.accumulateGCPauseTime(now-stw.finishedStopping, work.maxprocs)
work.cpuStats.accumulate(now, true)
// Compute overall GC CPU utilization.
// worldStop provides context from the stop-the-world required by the
// start-the-world.
type worldStop struct {
- reason stwReason
- start int64
+ reason stwReason
+ startedStopping int64
+ finishedStopping int64
}
// Temporary variable for stopTheWorld, when it can't write to the stack.
}
}
- startTime := nanotime() - start
+ finish := nanotime()
+ startTime := finish - start
if reason.isGC() {
sched.stwStoppingTimeGC.record(startTime)
} else {
worldStopped()
- return worldStop{reason: reason, start: start}
+ return worldStop{reason: reason, startedStopping: start, finishedStopping: finish}
}
// reason is the same STW reason passed to stopTheWorld. start is the start
if now == 0 {
now = nanotime()
}
- totalTime := now - w.start
+ totalTime := now - w.startedStopping
if w.reason.isGC() {
sched.stwTotalTimeGC.record(totalTime)
} else {