@@ -281,10 +281,9 @@ type gcControllerState struct {
281
281
// running.
282
282
fractionalMarkTime atomic.Int64
283
283
284
- // idleMarkTime is the nanoseconds spent in idle marking
285
- // during this cycle. This is updated atomically throughout
286
- // the cycle.
287
- idleMarkTime int64
284
+ // idleMarkTime is the nanoseconds spent in idle marking during this
285
+ // cycle. This is updated throughout the cycle.
286
+ idleMarkTime atomic.Int64
288
287
289
288
// markStartTime is the absolute start time in nanoseconds
290
289
// that assists and background mark workers started.
@@ -420,7 +419,7 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int, trigger g
420
419
c .assistTime .Store (0 )
421
420
c .dedicatedMarkTime .Store (0 )
422
421
c .fractionalMarkTime .Store (0 )
423
- c .idleMarkTime = 0
422
+ c .idleMarkTime . Store ( 0 )
424
423
c .markStartTime = markStartTime
425
424
426
425
// TODO(mknyszek): This is supposed to be the actual trigger point for the heap, but
@@ -671,7 +670,7 @@ func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) {
671
670
}
672
671
idleUtilization := 0.0
673
672
if assistDuration > 0 {
674
- idleUtilization = float64 (c .idleMarkTime ) / float64 (assistDuration * int64 (procs ))
673
+ idleUtilization = float64 (c .idleMarkTime . Load () ) / float64 (assistDuration * int64 (procs ))
675
674
}
676
675
// Determine the cons/mark ratio.
677
676
//
@@ -910,7 +909,7 @@ func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64
910
909
case gcMarkWorkerFractionalMode :
911
910
c .fractionalMarkTime .Add (duration )
912
911
case gcMarkWorkerIdleMode :
913
- atomic . Xaddint64 ( & c .idleMarkTime , duration )
912
+ c .idleMarkTime . Add ( duration )
914
913
c .removeIdleMarkWorker ()
915
914
default :
916
915
throw ("markWorkerStop: unknown mark worker mode" )
0 commit comments