]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix trigger for concurrent GC
authorRick Hudson <rlh@golang.org>
Tue, 13 Jan 2015 20:36:42 +0000 (15:36 -0500)
committerAustin Clements <austin@google.com>
Wed, 21 Jan 2015 16:19:48 +0000 (16:19 +0000)
Adujst triggergc so that we trigger when we have used 7/8
of the available memory.

Change-Id: I7ca02546d3084e6a04d60b09479e04a9a9837ae2
Reviewed-on: https://go-review.googlesource.com/3061
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/malloc.go

index 223220a570ee97d5ef307488c5cdfb305de08b6f..014b122b53491fbb65172a47cfb42366ccb71fff 100644 (file)
@@ -31,10 +31,12 @@ type pageID uintptr
 // base address for all 0-byte allocations
 var zerobase uintptr
 
+// triggers 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 = uint64(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 memstats.heap_alloc+memstats.heap_alloc/triggerratio >= memstats.next_gc && atomicloaduint(&bggc.working) == 0
 }
 
 // Allocate an object of size bytes.