diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-04-01 18:01:46 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2021-04-14 03:15:24 +0000 |
commit | 9bce7b70fde8572880e7a47bc2a4df8fb7b2c286 (patch) | |
tree | 7a871bfca6321ce996fba160fcf988586e8d2153 /src/runtime/mgc.go | |
parent | 2d4ba2601b91e2e69712861c654e4ddaf4355f49 (diff) | |
download | go-9bce7b70fde8572880e7a47bc2a4df8fb7b2c286.tar.gz go-9bce7b70fde8572880e7a47bc2a4df8fb7b2c286.zip |
runtime: create initializer for gcControllerState
Now that gcControllerState contains almost all of the pacer state,
create an initializer for it instead of haphazardly setting some fields.
For #44167.
Change-Id: I4ce1d5dd82003cb7c263fa46697851bb22a32544
Reviewed-on: https://go-review.googlesource.com/c/go/+/306601
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mgc.go')
-rw-r--r-- | src/runtime/mgc.go | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index b0d46d0060..f65402e94c 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -153,22 +153,12 @@ func gcinit() { if unsafe.Sizeof(workbuf{}) != _WorkbufSize { throw("size of Workbuf is suboptimal") } - gcController.heapMinimum = defaultHeapMinimum - // No sweep on the first cycle. mheap_.sweepDrained = 1 - // Set a reasonable initial GC trigger. - gcController.triggerRatio = 7 / 8.0 - - // Fake a heapMarked value so it looks like a trigger at - // heapMinimum is the appropriate growth from heapMarked. - // This will go into computing the initial GC goal. - gcController.heapMarked = uint64(float64(gcController.heapMinimum) / (1 + gcController.triggerRatio)) - - // Set gcPercent from the environment. This will also compute - // and set the GC trigger and goal. - _ = setGCPercent(readGOGC()) + // Initialize GC pacer state. + // Use the environment variable GOGC for the initial gcPercent value. + gcController.init(readGOGC()) work.startSema = 1 work.markDoneSema = 1 |