diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2018-10-31 19:36:21 +0100 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2018-11-02 13:38:56 +0000 |
commit | 56421f26ef8526427e034639510a162f3b40d825 (patch) | |
tree | ced86de8c5a70d40766b4a726179d2975b9a7800 /src/runtime/netpoll.go | |
parent | cdad4080695f09d79c403fd3827ef0ba50c399a8 (diff) | |
download | go-56421f26ef8526427e034639510a162f3b40d825.tar.gz go-56421f26ef8526427e034639510a162f3b40d825.zip |
runtime: use StorepNoWB instead of atomicstorep in netpoll
We only need the memory barrier from these stores,
and we only store nil over nil or over a static function value.
The write barrier is unnecessary.
name old time/op new time/op delta
TCP4OneShotTimeout-6 17.0µs ± 0% 17.0µs ± 0% -0.43% (p=0.032 n=5+5)
SetReadDeadline-6 205ns ± 1% 205ns ± 1% ~ (p=0.683 n=5+5)
Update #25729
Change-Id: I66c097a1db7188697ddfc381f31acec053dfed2c
Reviewed-on: https://go-review.googlesource.com/c/146345
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/netpoll.go')
-rw-r--r-- | src/runtime/netpoll.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index 7e6e93d6c3..4f4abfcd2c 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -260,7 +260,7 @@ func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { // If we set the new deadline in the past, unblock currently pending IO if any. var rg, wg *g if pd.rd < 0 || pd.wd < 0 { - atomicstorep(unsafe.Pointer(&wg), nil) // full memory barrier between stores to rd/wd and load of rg/wg in netpollunblock + atomic.StorepNoWB(noescape(unsafe.Pointer(&wg)), nil) // full memory barrier between stores to rd/wd and load of rg/wg in netpollunblock if pd.rd < 0 { rg = netpollunblock(pd, 'r', false) } @@ -287,7 +287,7 @@ func poll_runtime_pollUnblock(pd *pollDesc) { pd.rseq++ pd.wseq++ var rg, wg *g - atomicstorep(unsafe.Pointer(&rg), nil) // full memory barrier between store to closing and read of rg/wg in netpollunblock + atomic.StorepNoWB(noescape(unsafe.Pointer(&rg)), nil) // full memory barrier between store to closing and read of rg/wg in netpollunblock rg = netpollunblock(pd, 'r', false) wg = netpollunblock(pd, 'w', false) if pd.rt.f != nil { @@ -437,7 +437,7 @@ func netpolldeadlineimpl(pd *pollDesc, seq uintptr, read, write bool) { throw("runtime: inconsistent read deadline") } pd.rd = -1 - atomicstorep(unsafe.Pointer(&pd.rt.f), nil) // full memory barrier between store to rd and load of rg in netpollunblock + atomic.StorepNoWB(unsafe.Pointer(&pd.rt.f), nil) // full memory barrier between store to rd and load of rg in netpollunblock rg = netpollunblock(pd, 'r', false) } var wg *g @@ -446,7 +446,7 @@ func netpolldeadlineimpl(pd *pollDesc, seq uintptr, read, write bool) { throw("runtime: inconsistent write deadline") } pd.wd = -1 - atomicstorep(unsafe.Pointer(&pd.wt.f), nil) // full memory barrier between store to wd and load of wg in netpollunblock + atomic.StorepNoWB(unsafe.Pointer(&pd.wt.f), nil) // full memory barrier between store to wd and load of wg in netpollunblock wg = netpollunblock(pd, 'w', false) } unlock(&pd.lock) |