You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP server doesn't set TCP_NODELAY, adding ~40 ms to streamed responses #390
Version: laravel-rust 0.1.3 (still on 0.x at 3f09859)
What happens
LimitedListener::accept in src/foundation/connections.rs hands accepted connections to hyper without setting TCP_NODELAY, and serve_on builds the listener with .tap_io(|_| ()), so it isn't set anywhere else. With Nagle's algorithm on, a small write that follows an unacknowledged one waits for the client's delayed ACK, about 40 ms on Linux.
For a Streamed::channel or SSE response this delays the small chunks, including the first, so time to first byte goes up by ~40 ms. An app can't work around it, because the listener and accepted connections are private. (Reverb's listener already sets it.)
How to reproduce
A handler returning Streamed::channel that sends a few small chunks.
Call it over a keep-alive connection on Linux and time the first byte.
Measured (loopback, 600 sequential calls, p50 time to first byte):
Time to first byte
0.1.3
42.17 ms
with TCP_NODELAY
0.42 ms
Non-streamed responses were unchanged. Fix in #391.
Activity