]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.13] runtime: redefine scavenge goal in terms of heap_inuse
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 3 Sep 2019 19:54:32 +0000 (19:54 +0000)
committerAndrew Bonventre <andybons@golang.org>
Fri, 4 Oct 2019 16:55:09 +0000 (16:55 +0000)
commitcd951aeec4e658b3a1f05362c9655791427d6de6
tree5433bc8f62b8bbebcb3b20aefd27bfbe3ac7f055
parent951dbb1e5b264a253fe99fe5543c6e626ea33f96
[release-branch.go1.13] 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 #34149

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>
(cherry picked from commit 9b30811280427a6d50d2558f316d62210e948656)
Reviewed-on: https://go-review.googlesource.com/c/go/+/198487
Run-TryBot: Andrew Bonventre <andybons@golang.org>
src/runtime/mgc.go
src/runtime/mgcscavenge.go
src/runtime/mstats.go