Skip to content

Commit fe406c8

Browse files
committed
runtime: convert gcController.fractionalMarkTime to atomic type
For #53821. Change-Id: Ic54bda422b87ee9365090fe6b42b82df7b25d2a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/417782 Run-TryBot: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 3ea3d0e commit fe406c8

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/runtime/align_runtime_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var AtomicFields = []uintptr{
2222
unsafe.Offsetof(schedt{}.pollUntil),
2323
unsafe.Offsetof(schedt{}.timeToRun),
2424
unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
25-
unsafe.Offsetof(gcControllerState{}.fractionalMarkTime),
2625
unsafe.Offsetof(gcControllerState{}.idleMarkTime),
2726
unsafe.Offsetof(timeHistogram{}.underflow),
2827
unsafe.Offsetof(profBuf{}.overflow),

src/runtime/mgc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ func gcMarkTermination() {
10091009
sweepTermCpu := int64(work.stwprocs) * (work.tMark - work.tSweepTerm)
10101010
// We report idle marking time below, but omit it from the
10111011
// overall utilization here since it's "free".
1012-
markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime
1012+
markCpu := gcController.assistTime.Load() + gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load()
10131013
markTermCpu := int64(work.stwprocs) * (work.tEnd - work.tMarkTerm)
10141014
cycleCpu := sweepTermCpu + markCpu + markTermCpu
10151015
work.totaltime += cycleCpu
@@ -1105,7 +1105,7 @@ func gcMarkTermination() {
11051105
for i, ns := range []int64{
11061106
sweepTermCpu,
11071107
gcController.assistTime.Load(),
1108-
gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime,
1108+
gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load(),
11091109
gcController.idleMarkTime,
11101110
markTermCpu,
11111111
} {

src/runtime/mgcpacer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ type gcControllerState struct {
275275
// phase.
276276
dedicatedMarkTime atomic.Int64
277277

278-
// fractionalMarkTime is the nanoseconds spent in the
279-
// fractional mark worker during this cycle. This is updated
280-
// atomically throughout the cycle and will be up-to-date if
281-
// the fractional mark worker is not currently running.
282-
fractionalMarkTime int64
278+
// fractionalMarkTime is the nanoseconds spent in the fractional mark
279+
// worker during this cycle. This is updated throughout the cycle and
280+
// will be up-to-date if the fractional mark worker is not currently
281+
// running.
282+
fractionalMarkTime atomic.Int64
283283

284284
// idleMarkTime is the nanoseconds spent in idle marking
285285
// during this cycle. This is updated atomically throughout
@@ -419,7 +419,7 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int, trigger g
419419
c.bgScanCredit.Store(0)
420420
c.assistTime.Store(0)
421421
c.dedicatedMarkTime.Store(0)
422-
c.fractionalMarkTime = 0
422+
c.fractionalMarkTime.Store(0)
423423
c.idleMarkTime = 0
424424
c.markStartTime = markStartTime
425425

@@ -908,7 +908,7 @@ func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64
908908
c.dedicatedMarkTime.Add(duration)
909909
atomic.Xaddint64(&c.dedicatedMarkWorkersNeeded, 1)
910910
case gcMarkWorkerFractionalMode:
911-
atomic.Xaddint64(&c.fractionalMarkTime, duration)
911+
c.fractionalMarkTime.Add(duration)
912912
case gcMarkWorkerIdleMode:
913913
atomic.Xaddint64(&c.idleMarkTime, duration)
914914
c.removeIdleMarkWorker()

0 commit comments

Comments
 (0)