Repository navigation
net: disable Nagle's algorithm on client connections - #2996
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2996 +/- ##
==========================================
- Coverage 79.00% 76.52% -2.48%
==========================================
Files 75 75
Lines 46249 46211 -38
==========================================
- Hits 36538 35364 -1174
- Misses 9711 10847 +1136 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sylvestre
force-pushed
the
pr/tcp-nodelay
branch
from
November 8, 2026 11:30
d7d117c to
9091e1b
Compare
ahochheiden
requested changes
Nov 13, 2026
ahochheiden
left a comment
Member
There was a problem hiding this comment.
With Nagle off, write_length_prefixed_bincode sends the length and body as two packets for anything over the 8 KiB BufWriter:
Lines 676 to 682 in 9091e1b
One write instead:
let mut bytes = vec![0; 4];
bincode::serialize_into(&mut bytes, &data)?;
BigEndian::write_u32(&mut bytes[..4], (bytes.len() - 4) as u32);
writer.write_all(&bytes)?;
writer.flush()?;A message is written as a length prefix and then its body. When the body spans several segments, Nagle's algorithm holds its last one until the daemon ACKs the previous ones, which Linux delays by up to 40ms when the daemon has no reply to send yet. Server mode barely noticed, but in client-side mode every cache write carries a whole entry: a write took 33ms on average instead of 0.2ms, and a cold FFmpeg build at -j28 spent 69 seconds of its compiles waiting on them. Set TCP_NODELAY on both ends of the connection, and only log a failure to set it: in the accept loop, an error would stop the daemon. The cold build goes from 47.6s to 45.3s in client-side mode, the same as server mode (44.9s).
sylvestre
force-pushed
the
pr/tcp-nodelay
branch
from
November 20, 2026 08:40
9091e1b to
a351a6a
Compare
sylvestre
marked this pull request as ready for review
November 20, 2026 13:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A message between a client and the daemon is written as a length prefix and then its body. When the body spans several TCP segments, Nagle's algorithm holds its last one until the daemon ACKs the previous ones, which Linux delays by up to 40ms when the daemon has no reply to send yet.
Server mode barely notices, but in client-side mode every cache write carries a whole entry: on a cold FFmpeg build at
-j28, a cache write took 33ms on average (median 43ms) instead of 0.2ms in server mode, 69 seconds of the compiles' time in total.Set
TCP_NODELAYon both ends of the connection. The cold FFmpeg build goes from 47.6s to 45.3s in client-side mode, the same as server mode (44.9s), median of 3.