For #53821.
Change-Id: I772b58b21392855af95ee5b932cdd7a0b507e4e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/417781
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
unsafe.Offsetof(schedt{}.lastpoll),
unsafe.Offsetof(schedt{}.pollUntil),
unsafe.Offsetof(schedt{}.timeToRun),
- unsafe.Offsetof(gcControllerState{}.dedicatedMarkTime),
unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
unsafe.Offsetof(gcControllerState{}.fractionalMarkTime),
unsafe.Offsetof(gcControllerState{}.idleMarkTime),
sweepTermCpu := int64(work.stwprocs) * (work.tMark - work.tSweepTerm)
// We report idle marking time below, but omit it from the
// overall utilization here since it's "free".
- markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime + gcController.fractionalMarkTime
+ markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime
markTermCpu := int64(work.stwprocs) * (work.tEnd - work.tMarkTerm)
cycleCpu := sweepTermCpu + markCpu + markTermCpu
work.totaltime += cycleCpu
for i, ns := range []int64{
sweepTermCpu,
gcController.assistTime.Load(),
- gcController.dedicatedMarkTime + gcController.fractionalMarkTime,
+ gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime,
gcController.idleMarkTime,
markTermCpu,
} {
// written and read throughout the cycle.
assistTime atomic.Int64
- // dedicatedMarkTime is the nanoseconds spent in dedicated
- // mark workers during this cycle. This is updated atomically
- // at the end of the concurrent mark phase.
- dedicatedMarkTime int64
+ // dedicatedMarkTime is the nanoseconds spent in dedicated mark workers
+ // during this cycle. This is updated at the end of the concurrent mark
+ // phase.
+ dedicatedMarkTime atomic.Int64
// fractionalMarkTime is the nanoseconds spent in the
// fractional mark worker during this cycle. This is updated
c.globalsScanWork.Store(0)
c.bgScanCredit.Store(0)
c.assistTime.Store(0)
- c.dedicatedMarkTime = 0
+ c.dedicatedMarkTime.Store(0)
c.fractionalMarkTime = 0
c.idleMarkTime = 0
c.markStartTime = markStartTime
func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64) {
switch mode {
case gcMarkWorkerDedicatedMode:
- atomic.Xaddint64(&c.dedicatedMarkTime, duration)
+ c.dedicatedMarkTime.Add(duration)
atomic.Xaddint64(&c.dedicatedMarkWorkersNeeded, 1)
case gcMarkWorkerFractionalMode:
atomic.Xaddint64(&c.fractionalMarkTime, duration)