• Rick Hudson's avatar
    runtime: reduce latency by aggressively ending mark phase · 90a19961
    Rick Hudson authored
    Some latency regressions have crept into our system over the past few
    weeks. This CL fixes those by having the mark phase more aggressively
    blacken objects so that the mark termination phase, a STW phase, has less
    work to do. Three approaches were taken when the mark phase believes
    it has no more work to do, ie all the work buffers are empty.
    If things have gone well the mark phase is correct and there is
    in fact little or no work. In that case the following items will
    take very little time. If the mark phase is wrong this CL will
    ferret that work out and give the mark phase a chance to deal with
    it concurrently before mark termination begins.
    
    When the mark phase first appears to be out of work, it does three things:
    1) It switches from allocating white to allocating black to reduce the
    number of unmarked objects reachable only from stacks.
    2) It flushes and disables per-P GC work caches so all work must be in
    globally visible work buffers.
    3) It rescans the global roots---the BSS and data segments---so there
    are fewer objects to blacken during mark termination. We do not rescan
    stacks at this point, though that could be done in a later CL.
    After these steps, it again drains the global work buffers.
    
    On a lightly loaded machine the garbage benchmark has reduced the
    number of GC cycles with latency > 10 ms from 83 out of 4083 cycles
    down to 2 out of 3995 cycles. Maximum latency was reduced from
    60+ msecs down to 20 ms.
    
    Change-Id: I152285b48a7e56c5083a02e8e4485dd39c990492
    Reviewed-on: https://go-review.googlesource.com/10590Reviewed-by: 's avatarAustin Clements <austin@google.com>
    90a19961
mgcwork.go 12.3 KB