From ba4dfa7172a00f8b104a75a4655fe3de1e4a94c9 Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Wed, 24 Feb 2021 11:55:02 -0800 Subject: Move //pkg/gate.Gate to //pkg/sync. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- pkg/tcpip/link/waitable/BUILD | 2 +- pkg/tcpip/link/waitable/waitable.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/tcpip/link') diff --git a/pkg/tcpip/link/waitable/BUILD b/pkg/tcpip/link/waitable/BUILD index 9b4602c1b..b8d417b7d 100644 --- a/pkg/tcpip/link/waitable/BUILD +++ b/pkg/tcpip/link/waitable/BUILD @@ -9,7 +9,7 @@ go_library( ], visibility = ["//visibility:public"], deps = [ - "//pkg/gate", + "//pkg/sync", "//pkg/tcpip", "//pkg/tcpip/header", "//pkg/tcpip/stack", diff --git a/pkg/tcpip/link/waitable/waitable.go b/pkg/tcpip/link/waitable/waitable.go index 20259b285..ce5113746 100644 --- a/pkg/tcpip/link/waitable/waitable.go +++ b/pkg/tcpip/link/waitable/waitable.go @@ -22,7 +22,7 @@ package waitable import ( - "gvisor.dev/gvisor/pkg/gate" + "gvisor.dev/gvisor/pkg/sync" "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/stack" @@ -30,10 +30,10 @@ import ( // Endpoint is a waitable link-layer endpoint. type Endpoint struct { - dispatchGate gate.Gate + dispatchGate sync.Gate dispatcher stack.NetworkDispatcher - writeGate gate.Gate + writeGate sync.Gate lower stack.LinkEndpoint } -- cgit v1.2.3