For #53821.
Change-Id: I1bd23cdbc371011ec2331fb0a37482ecf99a063b
Reviewed-on: https://go-review.googlesource.com/c/go/+/417778
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
unsafe.Offsetof(schedt{}.pollUntil),
unsafe.Offsetof(schedt{}.timeToRun),
unsafe.Offsetof(gcControllerState{}.bgScanCredit),
- unsafe.Offsetof(gcControllerState{}.maxStackScan),
unsafe.Offsetof(gcControllerState{}.dedicatedMarkTime),
unsafe.Offsetof(gcControllerState{}.dedicatedMarkWorkersNeeded),
unsafe.Offsetof(gcControllerState{}.fractionalMarkTime),
if c.heapMarked > trigger {
trigger = c.heapMarked
}
- c.maxStackScan = stackSize
+ c.maxStackScan.Store(stackSize)
c.globalsScan = globalsSize
c.heapLive.Store(trigger)
c.heapScan.Add(int64(float64(trigger-c.heapMarked) * scannableFrac))
print(" ms cpu, ",
work.heap0>>20, "->", work.heap1>>20, "->", work.heap2>>20, " MB, ",
gcController.lastHeapGoal>>20, " MB goal, ",
- atomic.Load64(&gcController.maxStackScan)>>20, " MB stacks, ",
+ gcController.maxStackScan.Load()>>20, " MB stacks, ",
gcController.globalsScan>>20, " MB globals, ",
work.maxprocs, " P")
if work.userForced {
// goroutine stack space is much harder to measure cheaply. By using
// allocated space, we make an overestimate; this is OK, it's better
// to conservatively overcount than undercount.
- //
- // Read and updated atomically.
- maxStackScan uint64
+ maxStackScan atomic.Uint64
// globalsScan is the total amount of global variable space
// that is scannable.
// needs to be performed in this GC cycle. Specifically, it represents
// the case where *all* scannable memory turns out to be live, and
// *all* allocated stack space is scannable.
- maxStackScan := atomic.Load64(&c.maxStackScan)
+ maxStackScan := c.maxStackScan.Load()
maxScanWork := int64(scan + maxStackScan + c.globalsScan)
if work > scanWorkExpected {
// We've already done more scan work than expected. Because our expectation
func (c *gcControllerState) addScannableStack(pp *p, amount int64) {
if pp == nil {
- atomic.Xadd64(&c.maxStackScan, amount)
+ c.maxStackScan.Add(amount)
return
}
pp.maxStackScanDelta += amount
if pp.maxStackScanDelta >= maxStackScanSlack || pp.maxStackScanDelta <= -maxStackScanSlack {
- atomic.Xadd64(&c.maxStackScan, pp.maxStackScanDelta)
+ c.maxStackScan.Add(pp.maxStackScanDelta)
pp.maxStackScanDelta = 0
}
}