Skip to content

Comments

tonic: Server::default(): Set TCP_NODELAY to true; improve docs#2413

Merged
LucioFranco merged 1 commit intohyperium:masterfrom
evanj:evan.jones/nodelay-defaults-docs
Oct 21, 2025
Merged

tonic: Server::default(): Set TCP_NODELAY to true; improve docs#2413
LucioFranco merged 1 commit intohyperium:masterfrom
evanj:evan.jones/nodelay-defaults-docs

Conversation

@evanj
Copy link
Contributor

@evanj evanj commented Sep 17, 2025

Motivation

I recently ran into problems where we accidentally "lost" the tcp_nodelay=true setting, due to refactoring some code to make it easier to test. This caused mysterious 40 ms latency increases. I hope this makes it less likely for others to make this mistake.

Solution

The documentation of the Server::tcp_nodelay() function said "Enabled by default", but that was only true when using Server::builder(). The default() method set this to false. To fix this:

  • Change Server::default() to set tcp_nodelay: true.
  • Change Server::builder() to just call Server::default().
  • Add a test to verify the settings for nodelay and keepalive.
  • Document the functions to note that the TCP settings are ignored when using serve_with_incoming. tcp_keepalive already had this note. I added the same documentation to tcp_nodelay and to serve_with_incoming so it is less likely to be missed.

@evanj evanj force-pushed the evan.jones/nodelay-defaults-docs branch from 32218e1 to 03aeb02 Compare September 17, 2025 13:35
@evanj evanj force-pushed the evan.jones/nodelay-defaults-docs branch from 03aeb02 to ef4af6c Compare October 20, 2025 20:08
@evanj evanj changed the base branch from v0.14.x to master October 20, 2025 20:09
@evanj
Copy link
Contributor Author

evanj commented Oct 20, 2025

I'm not sure what the right base branch is here. I just rebased this to master, and I fixed the clippy warnings that were previously reported on the unit test.

@evanj
Copy link
Contributor Author

evanj commented Oct 21, 2025

Hmm I think the failing interop test may be a flaky test, since it passed on my first revision of this change. I'm going to rebase this change again to retry it.

The documentation of the Server::tcp_nodelay function said "Enabled
by default", but that was only true when using Server::builder().
The default() method set this to false. To fix this:

* Change Server::default() to set tcp_nodelay: true.
* Change Server::builder() to just call Server::default().
* Add a test to verify the settings for nodelay and keepalive.
* Document the functions to note that the TCP settings are ignored
  when using serve_with_incoming. tcp_keepalive already had this
  note. I added the same documentation to tcp_nodelay and to
  serve_with_incoming so it is less likely to be missed.

I recently ran into problems where we accidentally "lost" the
tcp_nodelay=true setting, due to refactoring some code to make it
easier to test. This caused mysterious 40 ms latency increases. I
hope this makes it less likely for others to make this mistake.
@evanj evanj force-pushed the evan.jones/nodelay-defaults-docs branch from ef4af6c to 94240f3 Compare October 21, 2025 13:46
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this sounded like a really fun one to debug 😂

@LucioFranco LucioFranco merged commit 2c01429 into hyperium:master Oct 21, 2025
20 checks passed
alexanderrilee pushed a commit to alexanderrilee/tonic that referenced this pull request Oct 29, 2025
…rium#2413)

## Motivation

I recently ran into problems where we accidentally "lost" the
tcp_nodelay=true setting, due to refactoring some code to make it easier
to test. This caused mysterious 40 ms latency increases. I hope this
makes it less likely for others to make this mistake.

## Solution

The documentation of the `Server::tcp_nodelay()` function said "Enabled
by default", but that was only true when using `Server::builder()`. The
`default()` method set this to false. To fix this:

* Change Server::default() to set tcp_nodelay: true.
* Change Server::builder() to just call Server::default().
* Add a test to verify the settings for nodelay and keepalive.
* Document the functions to note that the TCP settings are ignored when
using `serve_with_incoming`. `tcp_keepalive` already had this note. I
added the same documentation to `tcp_nodelay` and to
`serve_with_incoming` so it is less likely to be missed.
jen20 pushed a commit to jen20/tonic that referenced this pull request Dec 30, 2025
…rium#2413)

## Motivation

I recently ran into problems where we accidentally "lost" the
tcp_nodelay=true setting, due to refactoring some code to make it easier
to test. This caused mysterious 40 ms latency increases. I hope this
makes it less likely for others to make this mistake.

## Solution

The documentation of the `Server::tcp_nodelay()` function said "Enabled
by default", but that was only true when using `Server::builder()`. The
`default()` method set this to false. To fix this:

* Change Server::default() to set tcp_nodelay: true.
* Change Server::builder() to just call Server::default().
* Add a test to verify the settings for nodelay and keepalive.
* Document the functions to note that the TCP settings are ignored when
using `serve_with_incoming`. `tcp_keepalive` already had this note. I
added the same documentation to `tcp_nodelay` and to
`serve_with_incoming` so it is less likely to be missed.
LucioFranco added a commit that referenced this pull request Jan 28, 2026
# Changelog for v0.14.3

## Features

- Expose `tcp_keepalive_interval` and `tcp_keepalive_retries` options on
Server (#2472)
- Allow configuration of `max_local_error_reset_streams` on Server
(#2437)
- Put source error into the `Display` impl of `Status` (#2417)
- `Server::default()` now sets `TCP_NODELAY` to true (#2413)

## Bug Fixes

- Respect `max_message_size` when decompressing a message (#2484)
- Depend on http at least 1.1.0 (#2426)

## Documentation

- Fix documentation links for timeout configuration (#2483)
- Fix documentation typos and grammar issues in status.rs and
codec/mod.rs (#2468)
- Fix labels in `Display for Status` (#2414)
- Fix features docs in tonic-build and tonic-prost-build (#2434)
- Remove redundant word in tonic-build and tonic-prost-build README
(#2425)
grembo pushed a commit to grembo/tonic that referenced this pull request Feb 3, 2026
…rium#2413)

## Motivation

I recently ran into problems where we accidentally "lost" the
tcp_nodelay=true setting, due to refactoring some code to make it easier
to test. This caused mysterious 40 ms latency increases. I hope this
makes it less likely for others to make this mistake.

## Solution

The documentation of the `Server::tcp_nodelay()` function said "Enabled
by default", but that was only true when using `Server::builder()`. The
`default()` method set this to false. To fix this:

* Change Server::default() to set tcp_nodelay: true.
* Change Server::builder() to just call Server::default().
* Add a test to verify the settings for nodelay and keepalive.
* Document the functions to note that the TCP settings are ignored when
using `serve_with_incoming`. `tcp_keepalive` already had this note. I
added the same documentation to `tcp_nodelay` and to
`serve_with_incoming` so it is less likely to be missed.
@evanj evanj deleted the evan.jones/nodelay-defaults-docs branch February 9, 2026 14:57
LucioFranco pushed a commit that referenced this pull request Feb 13, 2026
## Motivation

I recently ran into problems where we accidentally "lost" the
tcp_nodelay=true setting, due to refactoring some code to make it easier
to test. This caused mysterious 40 ms latency increases. I hope this
makes it less likely for others to make this mistake.

## Solution

The documentation of the `Server::tcp_nodelay()` function said "Enabled
by default", but that was only true when using `Server::builder()`. The
`default()` method set this to false. To fix this:

* Change Server::default() to set tcp_nodelay: true.
* Change Server::builder() to just call Server::default().
* Add a test to verify the settings for nodelay and keepalive.
* Document the functions to note that the TCP settings are ignored when
using `serve_with_incoming`. `tcp_keepalive` already had this note. I
added the same documentation to `tcp_nodelay` and to
`serve_with_incoming` so it is less likely to be missed.
LucioFranco added a commit that referenced this pull request Feb 13, 2026
- Expose `tcp_keepalive_interval` and `tcp_keepalive_retries` options on
Server (#2472)
- Allow configuration of `max_local_error_reset_streams` on Server
(#2437)
- Put source error into the `Display` impl of `Status` (#2417)
- `Server::default()` now sets `TCP_NODELAY` to true (#2413)

- Respect `max_message_size` when decompressing a message (#2484)
- Depend on http at least 1.1.0 (#2426)

- Fix documentation links for timeout configuration (#2483)
- Fix documentation typos and grammar issues in status.rs and
codec/mod.rs (#2468)
- Fix labels in `Display for Status` (#2414)
- Fix features docs in tonic-build and tonic-prost-build (#2434)
- Remove redundant word in tonic-build and tonic-prost-build README
(#2425)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants