runtime: convert gcController.dedicatedMarkTime to atomic type

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>
This commit is contained in:
Michael Pratt 2022-07-15 16:44:57 -04:00
parent ba89d59a3a
commit 9463638ca8
3 changed files with 8 additions and 9 deletions

View file

@ -21,7 +21,6 @@ var AtomicFields = []uintptr{
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),

View file

@ -1009,7 +1009,7 @@ func gcMarkTermination() {
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
@ -1105,7 +1105,7 @@ func gcMarkTermination() {
for i, ns := range []int64{
sweepTermCpu,
gcController.assistTime.Load(),
gcController.dedicatedMarkTime + gcController.fractionalMarkTime,
gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime,
gcController.idleMarkTime,
markTermCpu,
} {

View file

@ -270,10 +270,10 @@ type gcControllerState struct {
// 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
@ -418,7 +418,7 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int, trigger g
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
@ -905,7 +905,7 @@ func (c *gcControllerState) resetLive(bytesMarked uint64) {
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)