-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net, internal/poll, runtime: remove mutex from UDP reads/writes #17520
Comments
Forgot to mention the Go version used:
|
We might be able to fall back to using the lock only in the blocking-on-fd path. |
Just skimmed runtime and internal/poll packages. It looks like we need to do two things: a) relax runtime.netpollblock for accommodating multiple IO wait requests from consumer goroutines using datagram protocols, b) replace the use of existing read/write{Lock,Unlock} methods of poll.fdMutex with new IO wait contact between runtime package. |
I can't recreate the slowdown on tip. This is what I see from
|
I don't see a clear advantage to modifying the runtime netpoll code to support multiple goroutines handling a single socket. The netpoll code is only really relevant if we have to wait for a packet, and if we have to wait for a packet then serializing the reads doesn't matter too much. For real cases we should be able to get a new goroutine ready to read in the time it takes a new packet to arrive anyhow. I think the interesting case is when there is a packet available already, which is what Russ's suggestions is intended to address. |
I can get a small speedup on this test case by calling So this requires more investigation to see if there is anything to be done. Moving to unplanned unless and until someone comes up with more information. |
Reads and writes on net.UDPConns are guarded by a mutex. Contention on the mutex makes it difficult to efficiently handle UDP requests concurrently. Or perhaps I'm overlooking the right way to do this.
The attached benchmark attempts to demonstrate the problem:
socks_test.go.txt
Annotated benchmark results from my desktop:
The text was updated successfully, but these errors were encountered: