]> Cypherpunks repositories - gostls13.git/commit
runtime: unify mutex code across OSes
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 2 Nov 2011 13:42:01 +0000 (16:42 +0300)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 2 Nov 2011 13:42:01 +0000 (16:42 +0300)
commitee24bfc0584f368284c2a4bef8e54056876677e9
treedcaa67cfa60dae107cb4478a0c67c4376d16c5fd
parent5e4e8f49c5a6a5850e808e2378103c6dd83420e7
runtime: unify mutex code across OSes
The change introduces 2 generic mutex implementations
(futex- and semaphore-based). Each OS chooses a suitable mutex
implementation and implements few callbacks (e.g. futex wait/wake).
The CL reduces code duplication, extends some optimizations available
only on Linux/Windows to other OSes and provides ground
for futher optimizations. Chan finalizers are finally eliminated.

(Linux/amd64, 8 HT cores)
benchmark                      old      new
BenchmarkChanContended         83.6     77.8 ns/op
BenchmarkChanContended-2       341      328 ns/op
BenchmarkChanContended-4       382      383 ns/op
BenchmarkChanContended-8       390      374 ns/op
BenchmarkChanContended-16      313      291 ns/op

(Darwin/amd64, 2 cores)
benchmark                      old      new
BenchmarkChanContended         159      172 ns/op
BenchmarkChanContended-2       6735     263 ns/op
BenchmarkChanContended-4       10384    255 ns/op
BenchmarkChanCreation          1174     407 ns/op
BenchmarkChanCreation-2        4007     254 ns/op
BenchmarkChanCreation-4        4029     246 ns/op

R=rsc, jsing, hectorchu
CC=golang-dev
https://golang.org/cl/5140043
src/pkg/runtime/Makefile
src/pkg/runtime/chan.c
src/pkg/runtime/darwin/thread.c
src/pkg/runtime/freebsd/thread.c
src/pkg/runtime/linux/thread.c
src/pkg/runtime/lock_futex.c [new file with mode: 0644]
src/pkg/runtime/lock_sema.c [new file with mode: 0644]
src/pkg/runtime/openbsd/thread.c
src/pkg/runtime/plan9/thread.c
src/pkg/runtime/runtime.h
src/pkg/runtime/windows/thread.c