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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" }
libp2p-swarm = { version = "0.45.0", path = "swarm" }
libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" }
libp2p-tcp = { version = "0.41.1", path = "transports/tcp" }
libp2p-tcp = { version = "0.42.0", path = "transports/tcp" }
libp2p-tls = { version = "0.4.0", path = "transports/tls" }
libp2p-uds = { version = "0.40.0", path = "transports/uds" }
libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" }
Expand Down
4 changes: 3 additions & 1 deletion transports/tcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.41.1
## 0.42.0

- Disable Nagle's algorithm (i.e. `TCP_NODELAY`) by default.
See [PR 4916](https://github.com/libp2p/rust-libp2p/pull/4916)

## 0.41.0

Expand Down
2 changes: 1 addition & 1 deletion transports/tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-tcp"
edition = "2021"
rust-version = { workspace = true }
description = "TCP/IP transport protocol for libp2p"
version = "0.41.1"
version = "0.42.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
2 changes: 1 addition & 1 deletion transports/tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

backlog: 1024,
enable_port_reuse: false,
}
Expand Down
Loading