]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert gcController.idleMarkTime to atomic type
authorMichael Pratt <mpratt@google.com>
Fri, 15 Jul 2022 20:49:50 +0000 (16:49 -0400)
committerMichael Pratt <mpratt@google.com>
Mon, 8 Aug 2022 14:12:13 +0000 (14:12 +0000)
For #53821.

Change-Id: I2f2b462908096dacb97fba9973798036ea1d9b68
Reviewed-on: https://go-review.googlesource.com/c/go/+/417783
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/align_runtime_test.go
src/runtime/mgc.go
src/runtime/mgcpacer.go

index 98e1622e7a95ef38b68183b7a8c3cf818055b183..cec0d76be2fee81bae599c6bf968472daff1fa79 100644 (file)
@@ -22,7 +22,6 @@ var AtomicFields = []uintptr{
        unsafe.Offsetof(schedt{}.pollUntil),
        unsafe.Offsetof(schedt{}.timeToRun),
        unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
-       unsafe.Offsetof(gcControllerState{}.idleMarkTime),
        unsafe.Offsetof(timeHistogram{}.underflow),
        unsafe.Offsetof(profBuf{}.overflow),
        unsafe.Offsetof(profBuf{}.overflowTime),
index 01eee16a4d3fcd704f971ca19590ac9817fff9f2..c3e91edb1fc7ad77fd168ea1a51d87b276edb0b8 100644 (file)
@@ -1106,7 +1106,7 @@ func gcMarkTermination() {
                        sweepTermCpu,
                        gcController.assistTime.Load(),
                        gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load(),
-                       gcController.idleMarkTime,
+                       gcController.idleMarkTime.Load(),
                        markTermCpu,
                } {
                        if i == 2 || i == 3 {
index d687ffb65730768fa030625874bcb582b873abc9..4e3538762ee697c7e6f73fd51ab27e8e8fddfca8 100644 (file)
@@ -281,10 +281,9 @@ type gcControllerState struct {
        // running.
        fractionalMarkTime atomic.Int64
 
-       // idleMarkTime is the nanoseconds spent in idle marking
-       // during this cycle. This is updated atomically throughout
-       // the cycle.
-       idleMarkTime int64
+       // idleMarkTime is the nanoseconds spent in idle marking during this
+       // cycle. This is updated throughout the cycle.
+       idleMarkTime atomic.Int64
 
        // markStartTime is the absolute start time in nanoseconds
        // that assists and background mark workers started.
@@ -420,7 +419,7 @@ func (c *gcControllerState) startCycle(markStartTime int64, procs int, trigger g
        c.assistTime.Store(0)
        c.dedicatedMarkTime.Store(0)
        c.fractionalMarkTime.Store(0)
-       c.idleMarkTime = 0
+       c.idleMarkTime.Store(0)
        c.markStartTime = markStartTime
 
        // 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) {
        }
        idleUtilization := 0.0
        if assistDuration > 0 {
-               idleUtilization = float64(c.idleMarkTime) / float64(assistDuration*int64(procs))
+               idleUtilization = float64(c.idleMarkTime.Load()) / float64(assistDuration*int64(procs))
        }
        // Determine the cons/mark ratio.
        //
@@ -910,7 +909,7 @@ func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64
        case gcMarkWorkerFractionalMode:
                c.fractionalMarkTime.Add(duration)
        case gcMarkWorkerIdleMode:
-               atomic.Xaddint64(&c.idleMarkTime, duration)
+               c.idleMarkTime.Add(duration)
                c.removeIdleMarkWorker()
        default:
                throw("markWorkerStop: unknown mark worker mode")