-
Notifications
You must be signed in to change notification settings - Fork 998
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
feat(tcp): make TCP_NODELAY the default #5469
Conversation
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@@ -161,7 +161,7 @@ impl Config { | |||
pub fn new() -> Self { | |||
Self { | |||
ttl: None, | |||
nodelay: None, | |||
nodelay: Some(false), // Disable Nagle's algorithm by default |
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.
@jxs Doesn't this explicitly enable Nagle's algorithm? If I understand correctly, to disable Nagle's algorithm, one needs to set TCP_NODELAY to true
.
TCP_NODELAY
If set, disable the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets, which results in poor utilization of the network.
https://linux.die.net/man/7/tcp
pub fn set_nodelay(&self, nodelay: bool) -> Result<()>Set the value of the TCP_NODELAY option on this socket.
If set, this option disables the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets.
https://docs.rs/socket2/latest/socket2/struct.Socket.html#method.set_nodelay
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.
Hi Romain, yeah you are right thanks for catching this. I overlooked it when re-creating the PR. Do you want to submit a PR addressing it? I can then release a patch version with this fix
Superseeds libp2p#4916. Fixes: libp2p#4890. Pull-Request: libp2p#5469.
Description
Superseeds #4916.
Fixes: #4890.
Notes
Added no delay to be Some(true) by default whenever the new method is called.