diff options
author | Dmitriy Vyukov <dvyukov@google.com> | 2014-01-22 11:27:16 +0400 |
---|---|---|
committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-01-22 11:27:16 +0400 |
commit | ae581f12543ef0621a2df0a68a0de791bff3488e (patch) | |
tree | 156df93fb5e99d2b3012f888b72b8c89763b6d3a /src/pkg/runtime/atomic_arm.c | |
parent | 56680424de0744f459214398ac90658a531c9c8a (diff) | |
download | go-ae581f12543ef0621a2df0a68a0de791bff3488e.tar.gz |
runtime: remove locks from netpoll hotpaths
Introduces two-phase goroutine parking mechanism -- prepare to park, commit park.
This mechanism does not require backing mutex to protect wait predicate.
Use it in netpoll. See comment in netpoll.goc for details.
This slightly reduces contention between reader, writer and read/write io notifications;
and just eliminates a bunch of mutex operations from hotpaths, thus making then faster.
benchmark old ns/op new ns/op delta
BenchmarkTCP4ConcurrentReadWrite 2109 1945 -7.78%
BenchmarkTCP4ConcurrentReadWrite-2 1162 1113 -4.22%
BenchmarkTCP4ConcurrentReadWrite-4 798 755 -5.39%
BenchmarkTCP4ConcurrentReadWrite-8 803 748 -6.85%
BenchmarkTCP4Persistent 9411 9240 -1.82%
BenchmarkTCP4Persistent-2 5888 5813 -1.27%
BenchmarkTCP4Persistent-4 4016 3968 -1.20%
BenchmarkTCP4Persistent-8 3943 3857 -2.18%
R=golang-codereviews, mikioh.mikioh, gobot, iant, rsc
CC=golang-codereviews, khr
https://codereview.appspot.com/45700043
Diffstat (limited to 'src/pkg/runtime/atomic_arm.c')
-rw-r--r-- | src/pkg/runtime/atomic_arm.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/runtime/atomic_arm.c b/src/pkg/runtime/atomic_arm.c index b1e97b27d..87e88d756 100644 --- a/src/pkg/runtime/atomic_arm.c +++ b/src/pkg/runtime/atomic_arm.c @@ -42,6 +42,19 @@ runtime·xchg(uint32 volatile* addr, uint32 v) } #pragma textflag NOSPLIT +void* +runtime·xchgp(void* volatile* addr, void* v) +{ + void *old; + + for(;;) { + old = *addr; + if(runtime·cas(addr, old, v)) + return old; + } +} + +#pragma textflag NOSPLIT void runtime·procyield(uint32 cnt) { |