-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Nagle's algorithm and uTP #6935
Comments
hopefully I'll find some time to look into this. |
I've been using this for the last month or so to potentially work around it, though it's not been tested beyond the 'it still compiles and doesn't outright break uTP' stage. |
interesting. My understanding of nagle's algorithm is that only one under-sized packet is supposed to be sent per RTT. Perhaps I misread it. I think it makes sense, though, to try really hard to coalesce sent data into as large packets as possible. |
I was basing that on what was in the original RFC from 1984:
It looks like it was superseded by this though, which does indeed hold back the undersized packet until there's nothing left in flight:
I guess one way favors latency, and the other favors efficiency. The original RFC appears to have been marked as obsolete as of 2016. |
That looks about right. Unless I'm misreading, then that appears to be the logic that the Linux kernel itself uses. There's some more background info here that's helped me get my head around it, and how that differs from the original from 1984. How about something like this then? Noting the sequence number of the last undersized packet sent and not sending another until its been ack'd. That should mean that the last few bytes of a 'big' send (eg. data ending in a choke) can get sent immediately rather than being held back for an entire RTT which appears to currently be the case. |
It might be worth looking at the deferred ack logic as well. If I'm reading things right, currently It might also be worth removing a previously queued deferred ack if |
I'll open some PRs with potential changes, though I'd imagine they'd need review/more testing to make sure they're fixing what they're intended to fix. |
thanks. great patches! |
Do you guys have plans to backport these to RC_1_2? |
I've opened #7096 that backports these to 1.2. You might want to keep an eye on that to see if/when it gets merged. |
I've noticed that the way libtorrent handles undersized uTP packets is different than that of
libutpand the original RFC introducing Nagle's algorithm, and introduces a potential delay of up to an RTT.If I'm reading the code correctly, currently libtorrent holds back sending an undersized uTP packet until its either no longer undersized, or until there are no more unack'd packets in flight. As a result, the packet can be held back for up to an entire RTT waiting for acks to arrive before being transmitted.
libtorrent/src/utp_stream.cpp
Lines 1514 to 1520 in 084219e
libutp appears to only hold back an undersized packet until the next ack is received.The RFC also only mentions holding back the packet until something arrives from the other end (though it is from 1984, and I don't know if things have changed). As a result, there is much less likely to be any significant extra delay.I'm not sure what the effects of this extra delay might be - if any - or whether it's been intentionally done that way or was an oversight. One thing that does come to mind though is when a peer is choked, where there will be a large stream of outgoing data that ends in a tiny choke message. The choke message could potentially be held back as undersized until everything previously in-flight is ack'd, causing the peer to continue requesting new pieces, and - if the extra RTT delay on top of the existing send buffers and underlying latency is high enough - potentially be disconnected due to sending requests while choked.
I'd be surprised if this alone has any meaningful effect on #3542.
The text was updated successfully, but these errors were encountered: