Skip to content

feat(tcp): make TCP_NODELAY the default#5469

Merged
mergify[bot] merged 16 commits into
libp2p:masterfrom
jxs:tcp-no-delay
Jun 13, 2024
Merged

feat(tcp): make TCP_NODELAY the default#5469
mergify[bot] merged 16 commits into
libp2p:masterfrom
jxs:tcp-no-delay

Conversation

@jxs

@jxs jxs commented Jun 13, 2024

Copy link
Copy Markdown
Member

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
@jxs jxs mentioned this pull request Jun 13, 2024
2 tasks
Comment thread transports/tcp/src/lib.rs
Self {
ttl: None,
nodelay: None,
nodelay: Some(false), // Disable Nagle's algorithm by default

@romac romac Sep 9, 2024

Copy link
Copy Markdown

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
Copy Markdown
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