-
Notifications
You must be signed in to change notification settings - Fork 235
fix(iroh): Poll all AsyncUdpSocket sources fairly #2996
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
Conversation
The existing AsyncUdpSocket::poll_recv polled the UDP IPv4 socket first, only if that has no datagrams would it poll UDP IPv6 and only also that had no datagrams to deliver was the relay socket polled. This highly favoured IPv4 relay traffic, potentially starving the relay traffic. This change makes it prefer a different source on each poll. Meaning if multiple sockets have data to deliver a fairer delivery happens.
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/2996/docs/iroh/ Last updated: 2024-12-03T15:38:17Z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some nits, but otherwise I really like this. Especially the split off process_udp_datagrams
function is a really good change!
Co-authored-by: Philipp Krüger <[email protected]>
Description
The existing AsyncUdpSocket::poll_recv polled the UDP IPv4 socket
first, only if that has no datagrams would it poll UDP IPv6 and only
also that had no datagrams to deliver was the relay socket polled.
This highly favoured IPv4 relay traffic, potentially starving the
relay traffic.
This change makes it prefer a different source on each poll. Meaning
if multiple sockets have data to deliver a fairer delivery happens.
Closes #2981.
Breaking Changes
Notes & open questions
Using Ordering::Relaxed is probably fine. I believe normally
this polling would only happen from a single task (the Quinn
endpoint driver) and even if it was polled concurrently from
different threads it would not be that bad and still an improvement
on the current order.
I'm not particularly fond of the implementation, but the macros is
the best I could come up with. Maybe there's something cleverer
which can be done.
Change checklist