runtime: convert gcController.heapLive to atomic type

Atomic operations are used even during STW for consistency.

For #53821.

Change-Id: Ibe7afe5cf893b1288ce24fc96b7691b1f81754ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/417775
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Michael Pratt 2022-07-15 14:21:02 -04:00
parent 5405df09af
commit 3a9281ff61
6 changed files with 34 additions and 44 deletions

View file

@ -1324,7 +1324,7 @@ func (c *GCController) StartCycle(stackSize, globalsSize uint64, scannableFrac f
}
c.maxStackScan = stackSize
c.globalsScan = globalsSize
c.heapLive = trigger
c.heapLive.Store(trigger)
c.heapScan += uint64(float64(trigger-c.heapMarked) * scannableFrac)
c.startCycle(0, gomaxprocs, gcTrigger{kind: gcTriggerHeap})
}
@ -1338,7 +1338,7 @@ func (c *GCController) HeapGoal() uint64 {
}
func (c *GCController) HeapLive() uint64 {
return c.heapLive
return c.heapLive.Load()
}
func (c *GCController) HeapMarked() uint64 {
@ -1358,7 +1358,7 @@ type GCControllerReviseDelta struct {
}
func (c *GCController) Revise(d GCControllerReviseDelta) {
c.heapLive += uint64(d.HeapLive)
c.heapLive.Add(d.HeapLive)
c.heapScan += uint64(d.HeapScan)
c.heapScanWork.Add(d.HeapScanWork)
c.stackScanWork.Add(d.StackScanWork)