From 2cd6bde402937937be0fdba21e024eb98304e552 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Mon, 2 Nov 2026 14:15:46 +0200 Subject: [PATCH] fix(s3s-fs): set TCP_NODELAY on every accepted connection The accept loop served each socket with Nagle on. A response that hyper writes as a head and then a body holds the body until the client ACKs the head, and a Linux client delays that ACK by 40 ms. Every request whose response went out in two writes paid it. Measured on the Ravel MetricsBench ci stack (NOFireAI/ravel issue 3561): a warm selector query took 50.3 to 50.9 ms against s3s-fs, and 9.3 to 9.6 ms with quickack set in the client's network namespace. A tcpdump of port 9000 showed one 40.4 to 41.0 ms gap per query, each after a 204-byte segment from s3s-fs and ended by the client's ACK. A socket that refuses the option is served without it. Signed-off-by: Panagiotis Moustafellos --- crates/s3s-fs/src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/s3s-fs/src/main.rs b/crates/s3s-fs/src/main.rs index cb58bec8f..63e44a430 100644 --- a/crates/s3s-fs/src/main.rs +++ b/crates/s3s-fs/src/main.rs @@ -180,6 +180,13 @@ async fn run(opt: Opt) -> Result { } }; + // Without it a response written as a head and a body holds the body + // until the client ACKs the head, which a delayed-ACK client takes + // 40 ms to do. + if let Err(err) = socket.set_nodelay(true) { + tracing::debug!("could not set TCP_NODELAY on an accepted connection: {err}"); + } + let conn = http_server.serve_connection(TokioIo::new(socket), service.clone()); let conn = graceful.watch(conn.into_owned()); tokio::spawn(async move {