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>
| Self { | ||
| ttl: None, | ||
| nodelay: None, | ||
| nodelay: Some(false), // Disable Nagle's algorithm by default |
There was a problem hiding this comment.
@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.
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.