multiformats / go-multistream

an implementation of the multistream protocol in go
MIT License
40 stars 27 forks source link

Lock contention in `findHandler` #38

Closed vyzo closed 5 years ago

vyzo commented 5 years ago

Observed in a busy relay:

     23430   runtime.gopark
             runtime.goparkunlock
             runtime.semacquire1
             sync.runtime_SemacquireMutex
             sync.(*Mutex).Lock
             github.com/multiformats/go-multistream.(*MultistreamMuxer).findHandler
             github.com/multiformats/go-multistream.(*MultistreamMuxer).NegotiateLazy
             github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).newStreamHandler
             github.com/libp2p/go-libp2p-swarm.(*Conn).start.func1.1
vyzo commented 5 years ago

also in the same lock:

      1422   runtime.gopark
             runtime.goparkunlock
             runtime.semacquire1
             sync.runtime_SemacquireMutex
             sync.(*Mutex).Lock
             github.com/multiformats/go-multistream.(*MultistreamMuxer).Protocols
             github.com/libp2p/go-libp2p/p2p/protocol/identify.(*IDService).populateMessage
             github.com/libp2p/go-libp2p/p2p/protocol/identify.(*IDService).requestHandler
             github.com/libp2p/go-libp2p/p2p/host/basic.(*BasicHost).SetStreamHandler.func1