1
0
mirror of https://github.com/golang/go synced 2024-09-30 06:14:31 -06:00

runtime: convert gcController.idleMarkTime to atomic type

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>
This commit is contained in:
Michael Pratt 2022-07-15 16:49:50 -04:00
parent fe406c8b11
commit dcd10375bc
3 changed files with 7 additions and 9 deletions

View File

@ -22,7 +22,6 @@ var AtomicFields = []uintptr{
unsafe.Offsetof(schedt{}.pollUntil), unsafe.Offsetof(schedt{}.pollUntil),
unsafe.Offsetof(schedt{}.timeToRun), unsafe.Offsetof(schedt{}.timeToRun),
unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded), unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
unsafe.Offsetof(gcControllerState{}.idleMarkTime),
unsafe.Offsetof(timeHistogram{}.underflow), unsafe.Offsetof(timeHistogram{}.underflow),
unsafe.Offsetof(profBuf{}.overflow), unsafe.Offsetof(profBuf{}.overflow),
unsafe.Offsetof(profBuf{}.overflowTime), unsafe.Offsetof(profBuf{}.overflowTime),

View File

@ -1106,7 +1106,7 @@ func gcMarkTermination() {
sweepTermCpu, sweepTermCpu,
gcController.assistTime.Load(), gcController.assistTime.Load(),
gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load(), gcController.dedicatedMarkTime.Load() + gcController.fractionalMarkTime.Load(),
gcController.idleMarkTime, gcController.idleMarkTime.Load(),
markTermCpu, markTermCpu,
} { } {
if i == 2 || i == 3 { if i == 2 || i == 3 {

View File

@ -281,10 +281,9 @@ type gcControllerState struct {
// running. // running.
fractionalMarkTime atomic.Int64 fractionalMarkTime atomic.Int64
// idleMarkTime is the nanoseconds spent in idle marking // idleMarkTime is the nanoseconds spent in idle marking during this
// during this cycle. This is updated atomically throughout // cycle. This is updated throughout the cycle.
// the cycle. idleMarkTime atomic.Int64
idleMarkTime int64
// markStartTime is the absolute start time in nanoseconds // markStartTime is the absolute start time in nanoseconds
// that assists and background mark workers started. // 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.assistTime.Store(0)
c.dedicatedMarkTime.Store(0) c.dedicatedMarkTime.Store(0)
c.fractionalMarkTime.Store(0) c.fractionalMarkTime.Store(0)
c.idleMarkTime = 0 c.idleMarkTime.Store(0)
c.markStartTime = markStartTime c.markStartTime = markStartTime
// TODO(mknyszek): This is supposed to be the actual trigger point for the heap, but // 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 idleUtilization := 0.0
if assistDuration > 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. // Determine the cons/mark ratio.
// //
@ -910,7 +909,7 @@ func (c *gcControllerState) markWorkerStop(mode gcMarkWorkerMode, duration int64
case gcMarkWorkerFractionalMode: case gcMarkWorkerFractionalMode:
c.fractionalMarkTime.Add(duration) c.fractionalMarkTime.Add(duration)
case gcMarkWorkerIdleMode: case gcMarkWorkerIdleMode:
atomic.Xaddint64(&c.idleMarkTime, duration) c.idleMarkTime.Add(duration)
c.removeIdleMarkWorker() c.removeIdleMarkWorker()
default: default:
throw("markWorkerStop: unknown mark worker mode") throw("markWorkerStop: unknown mark worker mode")