]> Cypherpunks repositories - gostls13.git/commit
runtime: use inUse ranges to map in summary memory only as needed
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 18 Nov 2019 19:23:39 +0000 (19:23 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 11 Dec 2019 19:51:34 +0000 (19:51 +0000)
commit1b1fbb3192984624871ab92518499d4bd6e6e65c
treef1e93f188aecabe9aeb43cf82d70aea500314aed
parent6f2b8347b148bb7aab1a89423d18ec0cbca6ffb4
runtime: use inUse ranges to map in summary memory only as needed

Prior to this change, if the heap was very discontiguous (such as in
TestArenaCollision) it's possible we could map a large amount of memory
as R/W and commit it. We would use only the start and end to track what
should be mapped, and we would extend that mapping as needed to
accomodate a potentially fragmented address space.

After this change, we only map exactly the part of the summary arrays
that we need by using the inUse ranges from the previous change. This
reduces the GCSys footprint of TestArenaCollision from 300 MiB to 18
MiB.

Because summaries are no longer mapped contiguously, this means the
scavenger can no longer iterate directly. This change also updates the
scavenger to borrow ranges out of inUse and iterate over only the
parts of the heap which are actually currently in use. This is both an
optimization and necessary for correctness.

Fixes #35514.

Change-Id: I96bf0c73ed0d2d89a00202ece7b9d089a53bac90
Reviewed-on: https://go-review.googlesource.com/c/go/+/207758
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/export_test.go
src/runtime/mgcscavenge.go
src/runtime/mpagealloc.go
src/runtime/mpagealloc_64bit.go
src/runtime/mpagealloc_test.go
src/runtime/mranges.go