• Austin Clements's avatar
    runtime: make assists preemptible · 45652830
    Austin Clements authored
    Currently, assists are non-preemptible, which means a heavily
    assisting G can block other Gs from running. At the beginning of a GC
    cycle, it can also delay scang, which will spin until the assist is
    done. Since scanning is currently done sequentially, this can
    seriously extend the length of the scan phase.
    
    Fix this by making assists preemptible. Since the assist holds work
    buffers and runs on the system stack, this must be done cooperatively:
    we make gcDrainN return on preemption, and make the assist return from
    the system stack and voluntarily Gosched.
    
    This is prerequisite to enlarging the work buffers. Without this
    change, the delays and spinning in scang increase significantly.
    
    This has no effect on the go1 benchmarks.
    
    name              old time/op  new time/op  delta
    XBenchGarbage-12  5.72ms ± 4%  5.37ms ± 5%  -6.11%  (p=0.000 n=20+20)
    
    Change-Id: I829e732a0f23b126da633516a1a9ec1a508fdbf1
    Reviewed-on: https://go-review.googlesource.com/15894Reviewed-by: default avatarRick Hudson <rlh@golang.org>
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    45652830
mgcmark.go 34.8 KB