• Michael Anthony Knyszek's avatar
    runtime: use inUse ranges to map in summary memory only as needed · 1b1fbb31
    Michael Anthony Knyszek authored
    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: default avatarAustin Clements <austin@google.com>
    1b1fbb31
mpagealloc_64bit.go 6.5 KB