Contention profile in BenchmarkTCPOneShot (Core 2 Quad):
Before
Total: 80.285 seconds
44.743 55.7% 55.7% 44.743 55.7% runtime.chanrecv1
31.995 39.9% 95.6% 31.995 39.9% sync.(*Mutex).Lock
3.547 4.4% 100.0% 3.547 4.4% runtime.chansend1
After
Total: 48.341 seconds
45.810 94.8% 94.8% 45.810 94.8% runtime.chanrecv1
2.530 5.2% 100.0% 2.530 5.2% runtime.chansend1
0.001 0.0% 100.0% 0.001 0.0% sync.(*Mutex).Lock
R=golang-dev, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/
6845119
func (fd *netFD) Close() error {
fd.pollServer.Lock() // needed for both fd.incref(true) and pollserver.Evict
- defer fd.pollServer.Unlock()
if err := fd.incref(true); err != nil {
+ fd.pollServer.Unlock()
return err
}
// Unblock any I/O. Once it all unblocks and returns,
// fairly quickly, since all the I/O is non-blocking, and any
// attempts to block in the pollserver will return errClosing.
fd.pollServer.Evict(fd)
+ fd.pollServer.Unlock()
fd.decref()
return nil
}
}
if err = fd.connect(ursa); err != nil {
closesocket(s)
- fd.Close()
return nil, err
}
fd.isConnected = true