• Dmitry Vyukov's avatar
    runtime: per-P contexts for race detector · caa21475
    Dmitry Vyukov authored
    Race runtime also needs local malloc caches and currently uses
    a mix of per-OS-thread and per-goroutine caches. This leads to
    increased memory consumption. But more importantly cache of
    synchronization objects is per-goroutine and we don't always
    have goroutine context when feeing memory in GC. As the result
    synchronization object descriptors leak (more precisely, they
    can be reused if another synchronization object is recreated
    at the same address, but it does not always help). For example,
    the added BenchmarkSyncLeak has effectively runaway memory
    consumption (based on a real long running server).
    
    This change updates race runtime with support for per-P contexts.
    BenchmarkSyncLeak now stabilizes at ~1GB memory consumption.
    
    Long term, this will allow us to remove race runtime dependency
    on glibc (as malloc is the main cornerstone).
    
    I've also implemented a different scheme to pass P context to
    race runtime: scheduler notified race runtime about association
    between G and P by calling procwire(g, p)/procunwire(g, p).
    But it turned out to be very messy as we have lots of places
    where the association changes (e.g. syscalls). So I dropped it
    in favor of the current scheme: race runtime asks scheduler
    about the current P.
    
    Fixes #14533
    
    Change-Id: Iad10d2f816a44affae1b9fed446b3580eafd8c69
    Reviewed-on: https://go-review.googlesource.com/19970Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    caa21475
Name
Last commit
Last update
..
testdata Loading commit data...
README Loading commit data...
doc.go Loading commit data...
output_test.go Loading commit data...
race.go Loading commit data...
race_darwin_amd64.syso Loading commit data...
race_freebsd_amd64.syso Loading commit data...
race_linux_amd64.syso Loading commit data...
race_test.go Loading commit data...
race_unix_test.go Loading commit data...
race_windows_amd64.syso Loading commit data...
sched_test.go Loading commit data...