diff options
| author | Austin Clements <austin@google.com> | 2015-03-16 14:22:00 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2015-04-21 15:35:18 +0000 |
| commit | 4b2fde945a79657cf77b8a173c0143208e7b88b1 (patch) | |
| tree | c366e87ff8a6416cf539921f8a8a981bb318fd8c /src/runtime/malloc.go | |
| parent | 028f9728473c6e7590ecaa7d30b0288df4a5731a (diff) | |
| download | go-4b2fde945a79657cf77b8a173c0143208e7b88b1.tar.xz | |
runtime: proportional mutator assist
Currently, mutator allocation periodically assists the garbage
collector by performing a small, fixed amount of scanning work.
However, to control heap growth, mutators need to perform scanning
work *proportional* to their allocation rate.
This change implements proportional mutator assists. This uses the
scan work estimate computed by the garbage collector at the beginning
of each cycle to compute how much scan work must be performed per
allocation byte to complete the estimated scan work by the time the
heap reaches the goal size. When allocation triggers an assist, it
uses this ratio and the amount allocated since the last assist to
compute the assist work, then attempts to steal as much of this work
as possible from the background collector's credit, and then performs
any remaining scan work itself.
Change-Id: I98b2078147a60d01d6228b99afd414ef857e4fba
Reviewed-on: https://go-review.googlesource.com/8836
Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 5fe0b160e6..84a2ad71a4 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -686,13 +686,12 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer { if shouldtriggergc() { startGC(gcBackgroundMode) - } else if shouldhelpgc && atomicloaduint(&bggc.working) == 1 { - // bggc.lock not taken since race on bggc.working is benign. - // At worse we don't call gchelpwork. - // Delay the gchelpwork until the epilogue so that it doesn't - // interfere with the inner working of malloc such as - // mcache refills that might happen while doing the gchelpwork - systemstack(gchelpwork) + } else if gcphase == _GCmark { + // Assist garbage collector. We delay this until the + // epilogue so that it doesn't interfere with the + // inner working of malloc such as mcache refills that + // might happen while doing the gcAssistAlloc. + gcAssistAlloc(size, shouldhelpgc) } return x |
