-
Notifications
You must be signed in to change notification settings - Fork 184
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
fix(iroh): AsyncUdpSocket
backpressure when connection type is *not* mixed
#3117
base: main
Are you sure you want to change the base?
Conversation
AsyncUdpSocket
backpressure when connection type is mixedAsyncUdpSocket
backpressure when connection type is *not* mixed
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3117/docs/iroh/ Last updated: 2025-01-13T16:16:01Z |
Netsim numbers:
vs. latest merged PR:
|
I haven't managed to get the This means we practically (?) never run into the I still think this code is more correct, but it really doesn't make much of a difference. |
AsyncUdpSocket
backpressure when connection type is *not* mixedAsyncUdpSocket
backpressure when connection type is *not* mixed
I had previously held off this because I was worried that you do not know the next packet that is going to be sent. But I think my logic was wrong: you do know the next packet: it will be the same one. So I think it's interesting to try this out. However, does it make #3067 more critical? Looking at the perf numbers I assume this has no impact and is all just noise? You might have more luck seeing the blocked metric go up if you test relay-only since then you have a single path. You can even go further and setup a relay server which rate-limits client connections so it is easier to fill up the magicsock pipes. I think it makes some sense that this is difficult to trigger, because Quinn is using congestion control and packet pacing to control the speed at which packets are being sent as well. Before WouldBlock comes into the picture. So you need to have a place where your flow control, congestion control and packet pacing all allow for more then the internal magicsock buffers are able to flush. |
Tried relay-only with rate limits. No effect :/ |
But then why return |
AsyncUdpSocket
backpressure when connection type is *not* mixedAsyncUdpSocket
backpressure when connection type is *not* mixed
Good questions. I think my above statement is a bit wrong. The reason we didn't do this is because we do not know where the next packet is going to be sent. If you have a direct path to one node, but relay paths another node you do not want to be blocking the direct path because the relay path is congested. Which still makes this change somewhat debatable (and I'm not sure I should have approved). We should certainly do a lot more testing before we commit to a change like this. |
Description
With the previous logic, when
relay_url
isNone
, thenrelay_pending
isfalse
.The same is true with
udp_addr
andudp_pending
.However, we only ever report
WouldBlock
ifudp_pending
andrelay_pending
.So this means we only ever report
WouldBlock
ifrelay_url
isn'tNone
andudp_addr
isn'tNone
, so when we're in mixed connection mode.Because in e.g. direct connection mode,
relay_url
isNone
, thusrelay_pending
isfalse
and we never returnErr(WouldBlock)
.Notes & open questions
I'm curious about netsim numbers.No changesMaybe this should have a test. EDIT: Hm this is really hard to test. I can't find a way to 'induce'
WouldBlock
in the relay and/or socket without fairly invasive changes that would allow replacing the socket & relay implementations.Change checklist
[ ] Documentation updates following the style guide, if relevant.[ ] Tests if relevant.Very hard to test this.