• Rhys Hiltner's avatar
    runtime: reduce GC assist extra credit · ccca9c9c
    Rhys Hiltner authored
    Mutator goroutines that allocate memory during the concurrent mark
    phase are required to spend some time assisting the garbage
    collector. The magnitude of this mandatory assistance is proportional
    to the goroutine's allocation debt and subject to the assistance
    ratio as calculated by the pacer.
    
    When assisting the garbage collector, a mutator goroutine will go
    beyond paying off its allocation debt. It will build up extra credit
    to amortize the overhead of the assist.
    
    In fast-allocating applications with high assist ratios, building up
    this credit can take the affected goroutine's entire time slice.
    Reduce the penalty on each goroutine being selected to assist the GC
    in two ways, to spread the responsibility more evenly.
    
    First, do a consistent amount of extra scan work without regard for
    the pacer's assistance ratio. Second, reduce the magnitude of the
    extra scan work so it can be completed within a few hundred
    microseconds.
    
    Commentary on gcOverAssistWork is by Austin Clements, originally in
    https://golang.org/cl/24704
    
    Updates #14812
    Fixes #16432
    
    Change-Id: I436f899e778c20daa314f3e9f0e2a1bbd53b43e1
    Reviewed-on: https://go-review.googlesource.com/25155
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarAustin Clements <austin@google.com>
    Reviewed-by: default avatarRick Hudson <rlh@golang.org>
    Reviewed-by: default avatarChris Broadfoot <cbro@golang.org>
    ccca9c9c
mgc.go 62.9 KB