Repository navigation
fix(kubernetes): send port-forwarded replies without a 40 ms delay - #13445
Merged
Merged
Conversation
forward() copied cluster replies to local clients over sockets without TCP_NODELAY, so a reply that arrived in pieces waited for the client's delayed acknowledgment between pieces.
cv
enabled auto-merge (squash)
October 19, 2026 04:53
Contributor
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.
Failure
kubernetes::connection::forwardrelays local connections to a Kubernetes gateway through a port-forward, but it doesn't setTCP_NODELAYon the local connections it accepts. When a reply from the cluster arrives in pieces, such as a gRPC response's frames, each piece after the first waits for the client's delayed acknowledgment of the one before. That's about 40 ms on Linux, the same delay #13381 and #13382 removed from provider and fake-gateway replies.In an Ubuntu 24.04 arm64 VM, a fake gateway that answers each one-byte request with two writes 1 ms apart took 44 ms per round trip through
forward, and 2.7 ms withTCP_NODELAY. I have not measured a real port-forward to a cluster.Change
Set
TCP_NODELAYon each local connectionforwardaccepts. A connection that refuses the option is still relayed.Validation
forwarded_replies_arriving_in_pieces_reach_the_client_promptlyincrates/nemoclaw-sdk/tests/kubernetes_connection.rsrequires a median round trip under 20 ms. In the Linux VM it failed before the change (41.9 ms) and passed three times after it. macOS doesn't show the delay, so the test passes there either way.cargo test -p nemoclaw-sdk --test integration kubernetes: 136 passed on Linux (VM) and macOS.cargo fmt --all --checkand Clippy fornemoclaw-sdk.Checked and left unchanged
These were also missing
TCP_NODELAY; the same VM showed no delay, so this PR doesn't touch them:crates/nemoclaw-ollama-proxy): streamed chunks arrived 0.1 ms after the daemon wrote them, with and without the option, at 10, 2 and 1 ms between chunks.crates/test-support/http.rs): it closes each connection right after replying, which sends the held body. The 135 SDK Kubernetes tests took 4.4–4.9 s before and 4.9–5.5 s after.Not measured: kube's client connects with hyper-util's
HttpConnector::new(), which leavesTCP_NODELAYoff on our connections to the Kubernetes API server.