-
-
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
Change the Nagle algorithm to allow a single undersized packet in flight at a time #7055
Conversation
src/utp_stream.cpp
Outdated
if (m_bytes_in_flight > 0 | ||
&& int(p->size) < std::min(int(p->allocated), effective_mtu) | ||
&& !force | ||
&& m_nagle) | ||
&& m_nagle | ||
&& !compare_less_wrap(m_nagle_seq_nr, m_acked_seq_nr, ACK_MASK)) |
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 m_nagle_seq_nr
== m_acked_seq_nr
, that means we don't have an outstanding undersized packet, right?
I believe this logic handles that case incorrectly. compare_less_wrap()
would return false and we would hold off the packet.
If I understand correctly, this last condition should be:
&& compare_less_wrap(m_acked_seq_nr, m_nagle_seq_nr, ACK_MASK))
src/utp_stream.cpp
Outdated
@@ -1549,11 +1550,12 @@ bool utp_socket_impl::send_pkt(int const flags) | |||
if (m_bytes_in_flight > 0 | |||
&& int(p->size) < std::min(int(p->allocated), effective_mtu) | |||
&& !force | |||
&& m_nagle) | |||
&& m_nagle | |||
&& !compare_less_wrap(m_nagle_seq_nr, m_acked_seq_nr, ACK_MASK)) |
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 believe the comment aboc also applies here
this is an interesting result of this test: https://github.com/arvidn/libtorrent/runs/8244601393?check_suite_focus=true#step:5:723 If it's not caused by the comparison issue, it would be good to understand where the redundant packet is coming from |
Well spotted. I'll fix that up and see how that effects that unexpected packet. |
Looks like its still there. Might have to do some more digging to work out whats going on. |
the redundant packet counter is incremented on |
I believe this change should be made as well. It's unrelated to your change except that they affect the simulation outcome:
|
feel free to incorporate that patch in this PR, or just fix up the test and I can add it afterwards |
Will do. I'll fix the expected packet counts in |
Currently, libtorrent will hold back an undersized uTP packet until all previously transmitted packets have been ack'd. This can add an extra RTT of delay when sending the last few bytes of a 'big' send (eg. a stream of data followed by a choke).
This suggested change will only hold back the undersized packet if there is currently an undersized packet in flight, essentially allowing one undersized packet to be sent per RTT. This would allow the tail of a 'big' send to go out immediatley without any extra delay.
This is done by noting the sequence number of the last undersized packet sent, as suggested here
See #6935