Skip to content
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

Merged
merged 16 commits into from
Jun 13, 2024
Merged

Conversation

jxs
Copy link
Member

@jxs jxs commented Jun 13, 2024

Description

Superseeds #4916.
Fixes: #4890.

Notes

Added no delay to be Some(true) by default whenever the new method is called.

  • I have made corresponding changes to the documentation
  • I have performed a self-review of my own code

@jxs jxs added this to the v0.54.0 milestone Jun 13, 2024
@jxs jxs added send-it trivial Marks PRs which are considered trivial and don't need approval from another maintainer. labels Jun 13, 2024
@mergify mergify bot merged commit a35e269 into libp2p:master Jun 13, 2024
72 checks passed
@jxs jxs mentioned this pull request Jun 13, 2024
2 tasks
@@ -161,7 +161,7 @@ impl Config {
pub fn new() -> Self {
Self {
ttl: None,
nodelay: None,
nodelay: Some(false), // Disable Nagle's algorithm by default
Copy link

@romac romac Sep 9, 2024

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

Copy link
Member Author

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

TimTinkers pushed a commit to unattended-backpack/rust-libp2p that referenced this pull request Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
send-it trivial Marks PRs which are considered trivial and don't need approval from another maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(tcp): make TCP_NODELAY the default
4 participants