diff options
| author | Rick Hudson <rlh@golang.org> | 2015-01-13 15:36:42 -0500 |
|---|---|---|
| committer | Rick Hudson <rlh@golang.org> | 2015-01-21 21:30:46 +0000 |
| commit | 34bc85f6f3b02ebcd490b40f4d32907ff2e69af3 (patch) | |
| tree | 7d41b9ea383e89631267d0ed1e09f9c665ec8269 /src/runtime/malloc.go | |
| parent | fe40cdd756763982db6815ee87318f418218fcf5 (diff) | |
| download | go-34bc85f6f3b02ebcd490b40f4d32907ff2e69af3.tar.xz | |
runtime: fix trigger for concurrent GC
Adjust triggergc so that we trigger when we have used 7/8
of the available heap memory. Do first collection when we
exceed 4Mbytes.
Change-Id: I467b4335e16dc9cd1521d687fc1f99a51cc7e54b
Reviewed-on: https://go-review.googlesource.com/3149
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 223220a570..69eb090706 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -31,10 +31,12 @@ type pageID uintptr // base address for all 0-byte allocations var zerobase uintptr +// Trigger the concurrent GC when 1/triggerratio memory is available to allocate. +// Adjust this ratio as part of a scheme to ensure that mutators have enough +// memory to allocate in durring a concurrent GC cycle. +var triggerratio = int64(8) + // Determine whether to initiate a GC. -// Currently the primitive heuristic we use will start a new -// concurrent GC when approximately half the available space -// made available by the last GC cycle has been used. // If the GC is already working no need to trigger another one. // This should establish a feedback loop where if the GC does not // have sufficient time to complete then more memory will be @@ -44,7 +46,7 @@ var zerobase uintptr // A false negative simple does not start a GC, a false positive // will start a GC needlessly. Neither have correctness issues. func shouldtriggergc() bool { - return memstats.heap_alloc+memstats.heap_alloc*3/4 >= memstats.next_gc && atomicloaduint(&bggc.working) == 0 + return triggerratio*(int64(memstats.next_gc)-int64(memstats.heap_alloc)) <= int64(memstats.next_gc) && atomicloaduint(&bggc.working) == 0 } // Allocate an object of size bytes. |
