aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mgc.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2021-03-31 22:55:06 +0000
committerMichael Knyszek <mknyszek@google.com>2021-04-13 23:42:29 +0000
commitf2d5bd1ad306e87804d600d92105dc37279af83f (patch)
tree3469c5e88ec761a320877fba1e3aed6e21f0ae7f /src/runtime/mgc.go
parent8c2a8b1771cd7ed2182f4d03b3c4bd09828315ce (diff)
downloadgo-f2d5bd1ad306e87804d600d92105dc37279af83f.tar.gz
go-f2d5bd1ad306e87804d600d92105dc37279af83f.zip
runtime: move internal GC statistics from memstats to gcController
This change moves certain important but internal-only GC statistics from memstats into gcController. These statistics are mainly used in pacing the GC, so it makes sense to keep them in the pacer's state. This CL was mostly generated via rf ' ex . { memstats.gc_trigger -> gcController.trigger memstats.triggerRatio -> gcController.triggerRatio memstats.heap_marked -> gcController.heapMarked memstats.heap_live -> gcController.heapLive memstats.heap_scan -> gcController.heapScan } ' except for a few special cases, like updating names in comments and when these fields are used within gcControllerState methods (at which point they're accessed through the reciever). For #44167. Change-Id: I6bd1602585aeeb80818ded24c07d8e6fec992b93 Reviewed-on: https://go-review.googlesource.com/c/go/+/306598 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.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 8831e27554..ff0618a053 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -158,12 +158,12 @@ func gcinit() {
mheap_.sweepDrained = 1
// Set a reasonable initial GC trigger.
- memstats.triggerRatio = 7 / 8.0
+ gcController.triggerRatio = 7 / 8.0
- // Fake a heap_marked value so it looks like a trigger at
- // heapMinimum is the appropriate growth from heap_marked.
+ // 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.
- memstats.heap_marked = uint64(float64(heapMinimum) / (1 + memstats.triggerRatio))
+ gcController.heapMarked = uint64(float64(heapMinimum) / (1 + gcController.triggerRatio))
// Set gcPercent from the environment. This will also compute
// and set the GC trigger and goal.
@@ -370,7 +370,7 @@ var work struct {
// program started if debug.gctrace > 0.
totaltime int64
- // initialHeapLive is the value of memstats.heap_live at the
+ // initialHeapLive is the value of gcController.heapLive at the
// beginning of this GC cycle.
initialHeapLive uint64
@@ -551,11 +551,11 @@ func (t gcTrigger) test() bool {
}
switch t.kind {
case gcTriggerHeap:
- // Non-atomic access to heap_live for performance. If
+ // Non-atomic access to gcController.heapLive for performance. If
// we are going to trigger on this, this thread just
- // atomically wrote heap_live anyway and we'll see our
+ // atomically wrote gcController.heapLive anyway and we'll see our
// own write.
- return memstats.heap_live >= memstats.gc_trigger
+ return gcController.heapLive >= gcController.trigger
case gcTriggerTime:
if gcPercent < 0 {
return false
@@ -651,7 +651,7 @@ func gcStart(trigger gcTrigger) {
// so it can't be more than ncpu, even if GOMAXPROCS is.
work.stwprocs = ncpu
}
- work.heap0 = atomic.Load64(&memstats.heap_live)
+ work.heap0 = atomic.Load64(&gcController.heapLive)
work.pauseNS = 0
work.mode = mode
@@ -915,7 +915,7 @@ func gcMarkTermination(nextTriggerRatio float64) {
// Start marktermination (write barrier remains enabled for now).
setGCPhase(_GCmarktermination)
- work.heap1 = memstats.heap_live
+ work.heap1 = gcController.heapLive
startTime := nanotime()
mp := acquirem()
@@ -1432,25 +1432,25 @@ func gcMark(start_time int64) {
}
// Update the marked heap stat.
- memstats.heap_marked = work.bytesMarked
+ gcController.heapMarked = work.bytesMarked
// Flush scanAlloc from each mcache since we're about to modify
- // heap_scan directly. If we were to flush this later, then scanAlloc
+ // heapScan directly. If we were to flush this later, then scanAlloc
// might have incorrect information.
for _, p := range allp {
c := p.mcache
if c == nil {
continue
}
- memstats.heap_scan += uint64(c.scanAlloc)
+ gcController.heapScan += uint64(c.scanAlloc)
c.scanAlloc = 0
}
// Update other GC heap size stats. This must happen after
// cachestats (which flushes local statistics to these) and
- // flushallmcaches (which modifies heap_live).
- memstats.heap_live = work.bytesMarked
- memstats.heap_scan = uint64(gcController.scanWork)
+ // flushallmcaches (which modifies gcController.heapLive).
+ gcController.heapLive = work.bytesMarked
+ gcController.heapScan = uint64(gcController.scanWork)
if trace.enabled {
traceHeapAlloc()
@@ -1543,7 +1543,7 @@ func gcResetMarkState() {
}
work.bytesMarked = 0
- work.initialHeapLive = atomic.Load64(&memstats.heap_live)
+ work.initialHeapLive = atomic.Load64(&gcController.heapLive)
}
// Hooks for other packages