// assistRatio is the ratio of allocated bytes to scan work
// that should be performed by mutator assists. This is
- // computed at the beginning of each cycle.
+ // computed at the beginning of each cycle and updated every
+ // time heap_scan is updated.
assistRatio float64
// fractionalUtilizationGoal is the fraction of wall clock
// at the end of of each cycle.
triggerRatio float64
- // reviseTimer is a timer that triggers periodic revision of
- // control variables during the cycle.
- reviseTimer timer
-
_ [_CacheLineSize]byte
// fractionalMarkWorkersNeeded is the number of fractional
" workers=", c.dedicatedMarkWorkersNeeded,
"+", c.fractionalMarkWorkersNeeded, "\n")
}
-
- // Set up a timer to revise periodically
- c.reviseTimer.f = func(interface{}, uintptr) {
- gcController.revise()
- }
- c.reviseTimer.period = 10 * 1000 * 1000
- c.reviseTimer.when = nanotime() + c.reviseTimer.period
- addtimer(&c.reviseTimer)
}
// revise updates the assist ratio during the GC cycle to account for
-// improved estimates. This should be called periodically during
-// concurrent mark.
+// improved estimates. This should be called either under STW or
+// whenever memstats.heap_scan is updated (with mheap_.lock held).
func (c *gcControllerState) revise() {
// Compute the expected scan work. This is a strict upper
// bound on the possible scan work in the current heap.
// transient changes. Values near 1 may be unstable.
const triggerGain = 0.5
- // Stop the revise timer
- deltimer(&c.reviseTimer)
-
// Compute next cycle trigger ratio. First, this computes the
// "error" for this cycle; that is, how far off the trigger
// was from what it should have been, accounting for both heap
memstats.tinyallocs += uint64(_g_.m.mcache.local_tinyallocs)
_g_.m.mcache.local_tinyallocs = 0
+ gcController.revise()
+
s := mHeap_AllocSpanLocked(h, npage)
if s != nil {
// Record span info, because gc needs to be
if acct != 0 {
memstats.heap_objects--
}
+ gcController.revise()
mHeap_FreeSpanLocked(h, s, true, true, 0)
if trace.enabled {
traceHeapAlloc()