diff options
author | Jamie Liu <jamieliu@google.com> | 2021-02-24 11:55:02 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-02-24 11:56:56 -0800 |
commit | ba4dfa7172a00f8b104a75a4655fe3de1e4a94c9 (patch) | |
tree | 36b7f2f85e34cf12b89f91e9f48c5a0881fe2c98 /pkg/sync/BUILD | |
parent | 8f6274404a87aa6adb2c8f322b9ee7aae2589fba (diff) |
Move //pkg/gate.Gate to //pkg/sync.
- Use atomic add rather than CAS in every Gate method, which is slightly
faster in most cases.
- Implement Close wakeup using gopark/goready to avoid channel allocation.
New benchmarks:
name old time/op new time/op delta
GateEnterLeave-12 16.7ns ± 1% 10.3ns ± 1% -38.44% (p=0.000 n=9+8)
GateClose-12 50.2ns ± 8% 42.4ns ± 6% -15.44% (p=0.000 n=10+10)
GateEnterLeaveAsyncClose-12 972ns ± 2% 640ns ± 7% -34.15% (p=0.000 n=9+10)
PiperOrigin-RevId: 359336344
Diffstat (limited to 'pkg/sync/BUILD')
-rw-r--r-- | pkg/sync/BUILD | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/sync/BUILD b/pkg/sync/BUILD index 2e2395807..b2c5229e7 100644 --- a/pkg/sync/BUILD +++ b/pkg/sync/BUILD @@ -52,6 +52,7 @@ go_library( "aliases.go", "checklocks_off_unsafe.go", "checklocks_on_unsafe.go", + "gate_unsafe.go", "goyield_go113_unsafe.go", "goyield_unsafe.go", "mutex_unsafe.go", @@ -69,6 +70,7 @@ go_library( stateify = False, visibility = ["//:sandbox"], deps = [ + "//pkg/gohacks", "//pkg/goid", ], ) @@ -77,6 +79,7 @@ go_test( name = "sync_test", size = "small", srcs = [ + "gate_test.go", "mutex_test.go", "rwmutex_test.go", "seqcount_test.go", |