• Austin Clements's avatar
    runtime: only trigger forced GC if GC is not running · 01baf13b
    Austin Clements authored
    Currently, sysmon triggers a forced GC solely based on
    memstats.last_gc. However, memstats.last_gc isn't updated until mark
    termination, so once sysmon starts triggering forced GC, it will keep
    triggering them until GC finishes. The first of these actually starts
    a GC; the remainder up to the last print "GC forced", but gcStart
    returns immediately because gcphase != _GCoff; then the last may start
    another GC if the previous GC finishes (and sets last_gc) between
    sysmon triggering it and gcStart checking the GC phase.
    
    Fix this by expanding the condition for starting a forced GC to also
    require that no GC is currently running. This, combined with the way
    forcegchelper blocks until the GC cycle is started, ensures sysmon
    only starts one GC when the time exceeds the forced GC threshold.
    
    Fixes #13458.
    
    Change-Id: Ie6cf841927f6085136be3f45259956cd5cf10d23
    Reviewed-on: https://go-review.googlesource.com/17819
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    01baf13b
proc.go 115 KB