diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-09-24 16:06:07 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2021-10-20 20:38:59 +0000 |
commit | 75b73d68b332a90e05cf45fa2c850667b3a0f777 (patch) | |
tree | b8e4177c263125f304fda127ee5210458489a7e1 /src/runtime/mgcpacer.go | |
parent | 3ec8d4b5ed5db74f84f8d493e4160e97481e436d (diff) | |
download | go-75b73d68b332a90e05cf45fa2c850667b3a0f777.tar.gz go-75b73d68b332a90e05cf45fa2c850667b3a0f777.zip |
runtime: use atomic.Float64 for assist ratio
Change-Id: Ie7f09a7c9545ef9dd1860b1e332c4edbcbf8165e
Reviewed-on: https://go-review.googlesource.com/c/go/+/356170
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/mgcpacer.go')
-rw-r--r-- | src/runtime/mgcpacer.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 9338359de7..342ea419fe 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -222,24 +222,14 @@ type gcControllerState struct { // bytes that should be performed by mutator assists. This is // computed at the beginning of each cycle and updated every // time heapScan is updated. - // - // Stored as a uint64, but it's actually a float64. Use - // float64frombits to get the value. - // - // Read and written atomically. - assistWorkPerByte uint64 + assistWorkPerByte atomic.Float64 // assistBytesPerWork is 1/assistWorkPerByte. // - // Stored as a uint64, but it's actually a float64. Use - // float64frombits to get the value. - // - // Read and written atomically. - // // Note that because this is read and written independently // from assistWorkPerByte users may notice a skew between // the two values, and such a state should be safe. - assistBytesPerWork uint64 + assistBytesPerWork atomic.Float64 // fractionalUtilizationGoal is the fraction of wall clock // time that should be spent in the fractional mark worker on @@ -333,7 +323,7 @@ func (c *gcControllerState) startCycle() { c.revise() if debug.gcpacertrace > 0 { - assistRatio := float64frombits(atomic.Load64(&c.assistWorkPerByte)) + assistRatio := c.assistWorkPerByte.Load() print("pacer: assist ratio=", assistRatio, " (scan ", gcController.heapScan>>20, " MB in ", work.initialHeapLive>>20, "->", @@ -439,8 +429,8 @@ func (c *gcControllerState) revise() { // cycle. assistWorkPerByte := float64(scanWorkRemaining) / float64(heapRemaining) assistBytesPerWork := float64(heapRemaining) / float64(scanWorkRemaining) - atomic.Store64(&c.assistWorkPerByte, float64bits(assistWorkPerByte)) - atomic.Store64(&c.assistBytesPerWork, float64bits(assistBytesPerWork)) + c.assistWorkPerByte.Store(assistWorkPerByte) + c.assistBytesPerWork.Store(assistBytesPerWork) } // endCycle computes the trigger ratio for the next cycle. |