return out
}
-// 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.
// If the GC is already working no need to trigger another one.
// This should establish a feedback loop where if the GC does not
// 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 triggerratio*(int64(memstats.next_gc)-int64(memstats.heap_live)) <= int64(memstats.next_gc) && atomicloaduint(&bggc.working) == 0
+ return memstats.heap_live >= memstats.next_gc && atomicloaduint(&bggc.working) == 0
}
var work struct {
cachestats()
- // compute next_gc
+ // Trigger the next GC cycle when the allocated heap has
+ // reached 7/8ths of the growth allowed by gcpercent.
memstats.heap_live = work.bytesMarked
- memstats.next_gc = memstats.heap_live + memstats.heap_live*uint64(gcpercent)/100
+ memstats.next_gc = memstats.heap_live + (memstats.heap_live*uint64(gcpercent)/100)*7/8
if memstats.next_gc < heapminimum {
memstats.next_gc = heapminimum
}