]> Cypherpunks repositories - gostls13.git/commit
runtime: add background scavenger
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 17 Oct 2018 23:29:42 +0000 (23:29 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 9 May 2019 16:21:43 +0000 (16:21 +0000)
commitfe67ea32bf58fde5aae5609af12c71e547566513
treeb2c9e1bf8b9169f0547e12e43039388b78748f5d
parenteaa1c87b007ad4c19b09b5bd9fdd85a093075324
runtime: add background scavenger

This change adds a background scavenging goroutine whose pacing is
determined when the heap goal changes. The scavenger is paced to use
at most 1% of the mutator's time for most systems. Furthermore, the
scavenger's pacing is computed based on the estimated number of
scavengable huge pages to take advantage of optimizations provided by
the OS.

The purpose of this scavenger is to deal with a shrinking heap: if the
heap goal is falling over time, the scavenger should kick in and start
returning free pages from the heap to the OS.

Also, now that we have a pacing system, the credit system used by
scavengeLocked has become redundant. Replace it with a mechanism which
only scavenges on the allocation path if it makes sense to do so with
respect to the new pacing system.

Fixes #30333.

Change-Id: I6203f8dc84affb26c3ab04528889dd9663530edc
Reviewed-on: https://go-review.googlesource.com/c/go/+/142960
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/mgc.go
src/runtime/mgcscavenge.go [new file with mode: 0644]
src/runtime/mheap.go
src/runtime/runtime2.go