Skip to content

tower tunnel: small RPCs starve behind large transfers on the shared H2 session (default 64 KB windows) — 39 s explorer stall through the relay #1677

Closed

Description

@amrmelsayed

Field measurement from the fork's web-IDE interim path (browser in Sydney → cloud.codevos.ai on Railway sin1 → tunnel → Tower/IDE server on a Sydney WSL box), 2026-09-12. Chrome performance trace + HAR analysed.

Symptom

A tiny RPC on the VS Code management WebSocket (explorer root resolve, ~100 B request / ~3 KB reply) took 39 s (sent 12.96 s, answered 52.11 s). A terminal getTerminalLayoutInfo on the same socket took 15 s. Page main thread idle; socket connected; no HTTP in flight. Replies on that socket arrived as a trickle of ~0.5–1.5 KB/s for ~40 s.

Concurrently the browser pushed 1.3 MB on the extension-host WebSocket at 19 s (the extension registry), then 199 KB at 26 s and 146 KB at 46 s. The small replies stalled until those drained.

Ruled out: the client machine (measured 2.5 MB/s upload to the Cloudflare edge, RTT 7 ms; origin TTFB 195 ms) and the IDE server (server-side trace shows extension scan, ext-host spawn and folder watchers all done within ~1 s of connection).

Hypothesis

Both browser WebSockets are proxied (RFC 8441 CONNECT) as two streams on one H2 session between the relay and the tower. Neither end sets H2 window sizes: http2.connect(...) on the relay and http2.createServer({ settings: { enableConnectProtocol: true } }) on the tower both run with Node's defaults (64 KB initial/session window, no setLocalWindowSize). With a ~100–150 ms relay↔tower RTT, a 64 KB shared window caps the session and lets a large transfer on one stream starve small frames on the other (head-of-line blocking at the session window). The observed shape matches.

Ask

  1. Measure tunnel throughput per direction and RTT relay↔tower on a real tower (a 2 MB upload and download through /t/<tower>/...).
  2. Raise H2 windows on both ends: settings.initialWindowSize (per stream) to ≥1 MB and call session.setLocalWindowSize(...) for the connection window on both the relay's client session and the tower's server session; consider paddingStrategy/maxSessionMemory accordingly. Also check ws perMessageDeflate on the tower's tunnel client (default on for ws clients) — CPU-bound inflate of large DATA frames in the same event loop delays outbound frames.
  3. Re-test: the acceptance signal is a small management RPC completing in ~1 RTT while a 1 MB message is in flight on the other stream.

This directly affects the durable design (Tower-owned /ide/ forward): the IDE's two sockets will always share the tunnel.

Activity

  1. added
    area/tower
    on Sep 12, 2026
  2. amrmelsayed commented on Sep 12, 2026

    @amrmelsayed
    CollaboratorAuthor

    Routing ruling from the tower contract seat: (1) This is a COMPANION fix to #1668, not a plan change — the forward proxies to loopback and owns no H2 tuning; the starvation lives in the tunnel-client↔relay session. #1668 proceeds unchanged. (2) It IS a binding SEQUENCING input for #1668's cloud-leg verification: a ~21MB workbench boot through two streams on an untuned 64KB-window session would crawl, and a slow cloud leg would misattribute tunnel starvation to the forward — so the cloud-leg judgment waits for this fix or explicitly accounts for it. (3) Severity note: the measured 15s terminal RPC under a 1.3MB drain means every cloud-relay user's terminals hit this today, independent of the IDE — promoting this to the 3.3.4 candidate set alongside #1629/#1627. The measurement-first ask (per-direction throughput before tuning) is the right order.

  3. amrmelsayed commented on Sep 12, 2026

    @amrmelsayed
    CollaboratorAuthor

    Bisection confirmed (owner test, 2026-09-12). Same IDE server, same folder, same browser session, opened directly at the server (LAN, no relay/tunnel): explorer and sidebar populate instantly. Through the relay: ~45 s. That clears the server, the build and the client machine; the stall is entirely in the relay↔tower path.

  4. amrmelsayed commented on Sep 12, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  5. added 7 commits that reference this issue on Sep 12, 2026
    557e2f1
    c1dbf47
    2227700
    59e96a8
    851ae88
    51a5e81
    70de094
  6. amrmelsayed commented on Sep 14, 2026

    @amrmelsayed
    CollaboratorAuthor

    Reopened per the gate ruling (Refs, not Fixes): PR #1678 delivered the TOWER-SIDE inbound half only. GitHub auto-closed this on merge because the ruling was applied to the PR body but commit messages ('Fix #1677: ...') also carry auto-close keywords — noted as a process gotcha for future Refs rulings (amend must cover commits or the ruling needs a reopen like this one). Still outstanding before this issue closes: relay-side deploy live (codev-cloud 33b9781, was deploying), and the end-to-end field re-test of the 100B-RPC-under-1.3MB-drain scenario with both halves live. The re-test also unblocks judging #1668's cloud leg.

  7. added 2 commits that reference this issue on Sep 15, 2026
  8. added a commit that references this issue on Sep 17, 2026
    678f082
  9. amrmelsayed commented on Sep 19, 2026

    @amrmelsayed
    CollaboratorAuthor

    Field re-test with both halves live (2026-09-19). Relay on 33b9781 (1 MiB stream / 4 MiB session), tower on codev 3.3.4 (this fix via #1678) forwarding a full browser IDE through /t/<tower>/ide/ (#1683), WSL tower, Windows browser, real repository open:

    before (64 KiB defaults) after
    IDE explorer populates (management-socket RPCs behind a ~1.3 MB ext-host push) 45–52 s 7 s
    IDE integrated terminal usable ~15 s 12 s

    Direct-on-localhost reference for the same session: < 1 s. The head-of-line starvation is gone; what remains is relay round-trips plus remote extension-host spawn. codev-cloud's synthetic before/after throughput run (big asset vs concurrent small request) is queued on their side as the second data set.

  10. amrmelsayed commented on Sep 19, 2026

    @amrmelsayed
    CollaboratorAuthor

    Closing on the 2026-09-19 field re-test above: both halves live (tower 3.3.4 via PR #1678, relay deployed), and the head-of-line starvation this issue is about is gone end to end (explorer RPCs behind a 1.3 MB drain: 45-52 s before, 7 s after). The residual integrated-terminal latency (12 s vs < 1 s localhost) barely moved with the window fix, so it is a different bottleneck and now tracked separately as #1708 (attribute the terminal channel leg by leg, fix the codev-side share).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions