aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mstats.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-09-03 19:54:32 +0000
committerMichael Knyszek <mknyszek@google.com>2019-09-25 22:15:39 +0000
commit9b30811280427a6d50d2558f316d62210e948656 (patch)
treeecffe597a49cb2dfc77f54f812e8f17ed1fe2e02 /src/runtime/mstats.go
parent78baea836d9f4312972e50e17dcff15ff63d155b (diff)
downloadgo-9b30811280427a6d50d2558f316d62210e948656.tar.gz
go-9b30811280427a6d50d2558f316d62210e948656.zip
runtime: redefine scavenge goal in terms of heap_inuse
This change makes it so that the scavenge goal is defined primarily in terms of heap_inuse at the end of the last GC rather than next_gc. The reason behind this change is that next_gc doesn't take into account fragmentation, and we can fall into situation where the scavenger thinks it should have work to do but there's no free and unscavenged memory available. In order to ensure the scavenge goal still tracks next_gc, we multiply heap_inuse by the ratio between the current heap goal and the last heap goal, which describes whether the heap is growing or shrinking, and by how much. Finally, this change updates the documentation for scavenging and elaborates on why the scavenge goal is defined the way it is. Fixes #34048. Updates #32828. Change-Id: I8deaf87620b5dc12a40ab8a90bf27932868610da Reviewed-on: https://go-review.googlesource.com/c/go/+/193040 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/mstats.go')
-rw-r--r--src/runtime/mstats.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index 421580eec3..09dbb26735 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -79,6 +79,8 @@ type mstats struct {
last_gc_nanotime uint64 // last gc (monotonic time)
tinyallocs uint64 // number of tiny allocations that didn't cause actual allocation; not exported to go directly
+ last_next_gc uint64 // next_gc for the previous GC
+ last_heap_inuse uint64 // heap_inuse at mark termination of the previous GC
// triggerRatio is the heap growth ratio that triggers marking.
//