-
Notifications
You must be signed in to change notification settings - Fork 48
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
check if we make unnecessary syscalls with UDP #51
Comments
Good news: I don't see the repeated I checked with:
Trying to match reads up with epoll returns gets confusing because tokio/mio apparently use an integer that's not not the file descriptor to represent the socket. so you have to mentally do an extra mapping. The simpler way is to check for any given
|
When using
Transport::Udp
,<Session as futures::Stream>::poll_next
calls intopoll_udp
, which ultimately polls each UDP socket:retina/src/client/mod.rs
Line 1739 in 1145ed0
retina/src/client/mod.rs
Line 1778 in 1145ed0
poll_next
is (intended to be) called any time theStream
was awakened for any reason: any one of the sockets or the keepalive timeout.I suspect these are actually turning into extra
recv
syscalls on each socket (even ones thatepoll_wait
hasn't said are ready sincerecv
last returnedEWOULDBLOCK
) until we hit the one that actually is ready. (This thought was inspired by reading about performance problems with tokio'sFuturesUnordered
in this discussion. We're doing things in a round-robin order rather than usingFuturesUnordered
, but the effect is probably similar.)There are typically about five sockets involved when using UDP (RTSP TCP socket, and (RTP, RTCP) x (video, audio)), and syscalls are expensive, so making up to 5X as many syscalls as necessary is bad.
We should check for this. Maybe just by examining
strace
output of a UDP session and/or inspecting the tokio code.If we indeed are making unnecessary syscalls, we should restructure the code to avoid it. A couple possible structures:
Session
'spoll_next
just reads the other side of the channel rather than doing any work itself. Remember to clean up the tasks when theSession
is dropped.TaskSet
.That might be worth doing even if tokio/mio stops us from reaching the syscall stage; that code might be expensive enough to be worth avoiding too.
It'd be nice to have a proper benchmark of UDP, too, like we have for TCP.
The text was updated successfully, but these errors were encountered: