Skip to content

fix(kubernetes): send port-forwarded replies without a 40 ms delay - #13445

Merged
cv merged 1 commit into
v1from
codex/port-forward-nodelay
Oct 19, 2026
Merged

cv merged 1 commit into
v1from
codex/port-forward-nodelay

Conversation

@cv

@cv cv commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Failure

kubernetes::connection::forward relays local connections to a Kubernetes gateway through a port-forward, but it doesn't set TCP_NODELAY on 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 with TCP_NODELAY. I have not measured a real port-forward to a cluster.

Change

Set TCP_NODELAY on each local connection forward accepts. A connection that refuses the option is still relayed.

Validation

  • New test forwarded_replies_arriving_in_pieces_reach_the_client_promptly in crates/nemoclaw-sdk/tests/kubernetes_connection.rs requires 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 --check and Clippy for nemoclaw-sdk.

Checked and left unchanged

These were also missing TCP_NODELAY; the same VM showed no delay, so this PR doesn't touch them:

  • Ollama proxy (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.
  • Shared HTTP test fixture (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 leaves TCP_NODELAY off on our connections to the Kubernetes API server.

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
cv enabled auto-merge (squash) October 19, 2026 04:53
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit a59f232 into v1 Oct 19, 2026
@cv
cv deleted the codex/port-forward-nodelay branch October 19, 2026 05:07
@wscurran wscurran added area: networking DNS, proxy, TLS, ports, host aliases, or connectivity area: performance Latency, throughput, resource use, benchmarks, or scaling bug-fix PR fixes a bug or regression platform: k8s Affects Kubernetes deployments platform: linux Affects non-Ubuntu Linux environments v1 NemoClaw v1 branch labels Oct 23, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: networking DNS, proxy, TLS, ports, host aliases, or connectivity area: performance Latency, throughput, resource use, benchmarks, or scaling bug-fix PR fixes a bug or regression platform: k8s Affects Kubernetes deployments platform: linux Affects non-Ubuntu Linux environments v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants