]> Cypherpunks repositories - gostls13.git/commit
net: add special netFD mutex
authorDmitriy Vyukov <dvyukov@google.com>
Fri, 9 Aug 2013 17:43:00 +0000 (21:43 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Fri, 9 Aug 2013 17:43:00 +0000 (21:43 +0400)
commit23e15f72538381dab83d02b3bf543cf95230d3e8
tree94478343c2fb40cfd7762f594adfe3f933fa79ba
parent89b5c6c0af854c53ba16da8bc8394853e04e6bb0
net: add special netFD mutex
The mutex, fdMutex, handles locking and lifetime of sysfd,
and serializes Read and Write methods.
This allows to strip 2 sync.Mutex.Lock calls,
2 sync.Mutex.Unlock calls, 1 defer and some amount
of misc overhead from every network operation.

On linux/amd64, Intel E5-2690:
benchmark                             old ns/op    new ns/op    delta
BenchmarkTCP4Persistent                    9595         9454   -1.47%
BenchmarkTCP4Persistent-2                  8978         8772   -2.29%
BenchmarkTCP4ConcurrentReadWrite           4900         4625   -5.61%
BenchmarkTCP4ConcurrentReadWrite-2         2603         2500   -3.96%

In general it strips 70-500 ns from every network operation depending
on processor model. On my relatively new E5-2690 it accounts to ~5%
of network op cost.

Fixes #6074.

R=golang-dev, bradfitz, alex.brainman, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12418043
25 files changed:
src/pkg/net/fd_mutex.go [new file with mode: 0644]
src/pkg/net/fd_mutex_test.go [new file with mode: 0644]
src/pkg/net/fd_poll_runtime.go
src/pkg/net/fd_unix.go
src/pkg/net/fd_windows.go
src/pkg/net/sendfile_freebsd.go
src/pkg/net/sendfile_linux.go
src/pkg/net/sendfile_windows.go
src/pkg/net/sockopt_posix.go
src/pkg/net/sockoptip_bsd.go
src/pkg/net/sockoptip_linux.go
src/pkg/net/sockoptip_posix.go
src/pkg/net/sockoptip_windows.go
src/pkg/net/tcpsockopt_darwin.go
src/pkg/net/tcpsockopt_openbsd.go
src/pkg/net/tcpsockopt_posix.go
src/pkg/net/tcpsockopt_unix.go
src/pkg/net/tcpsockopt_windows.go
src/pkg/runtime/mgc0.c
src/pkg/runtime/mprof.goc
src/pkg/runtime/netpoll.goc
src/pkg/runtime/proc.c
src/pkg/runtime/race.c
src/pkg/runtime/runtime.h
src/pkg/runtime/sema.goc