Skip to content

Connection perf: multiplexed persistent streams over one tunnel (replace HTTP-per-call + pool of 50) #5756

Open

Description

@dezren39

Multiplexed persistent streams over ONE tunnel for the sandbox↔laptop path (WS-C design, from #5701)

Part of epic #5412. Design evidence: WS-C connection-performance comment on #5701 (2026-11-04).

Measured problem (2026-11-04, trips.jsonl n=1149 + live probes)

  • Warm single trivial call: client trip p50 369 ms (status-200, <2 s subset, n=800) while daemon work is 1–11 ms (daemon trips.jsonl; example trip aedc705d4294: client 445 ms vs daemon 1 ms). Transport ≈ 99% of cost.
  • The path is HTTP/1.1-request-per-call over a pooled CONNECT tunnel (pool 50 in fleet proxy serve). Even warm, one request/response costs ~170–600 ms over the runtime-proxy (:3130) + DERP hairpin path. A warm RTT is the floor for EVERY operation, and every CLI operation is a separate call.
  • Cold CONNECT measured 1,434 ms trip (same-minute warm trip: 212 ms) — CONNECT setup ≈ 1.2–1.8 s, and the ramp test on Incident record 2026-11-04: afternoon responsiveness loss — sandbox wedged after post-boot herd (daemon restart, 88-min sampler silence); laptop path exonerated 21:00–21:28 UTC #5701 showed CONNECT setup serializes under concurrency (128 tunnels = 14.6 s wall, no failures).
  • Failure amplification: during proxy wobble, trips cluster at 502 after ~16.3 s (p50, n=119) and no-status after ~26 s (p50, n=73) — retry chains multiply the herd.

Proposal

Replace HTTP-per-call over N pooled tunnels with ONE (or two, for redundancy) persistent tunnel carrying multiplexed streams:

  1. Framed stream multiplexer on the tunnel (the broker already speaks length-prefixed frames on its unix socket — extend that framing end-to-end): each request is a stream (id, port/service, method, path, body) over a single TCP/TLS-less CONNECT tunnel; responses interleave by stream id. Candidates: yamux-style custom framing in the existing Rust fleet-proxy, HTTP/2 over the tunnel (h2 gives streams + HPACK + PING keepalive for free), or QUIC if the runtime proxy path ever allows UDP (it does not today — CONNECT/TCP only, so QUIC is out until that changes).
  2. No per-call CONNECT, no pool checkout, no HTTP/1.1 head-of-line blocking per request; pool of 50 tunnels collapses to 1–2 tunnels + stream concurrency (ramp proved the tunnel path itself survives 128 concurrent; streams remove the serialized CONNECT setup that made the ramp slow).
  3. Keepalive: application-level PING on the tunnel (replaces per-pool-connection health keepalives; current Python-broker constants KEEPALIVE_S=180 / idle-exit 3600 s carry over as starting values, but the broker must not idle-exit while a tunnel with in-flight streams is healthy — exit only when the tunnel is dead AND no calls for 3600 s).
  4. Backpressure + bounded retry: per-stream timeout with a hard ceiling well under the current 16–26 s failure cluster; one retry on a FRESH stream (not a fresh CONNECT) when the tunnel is alive; tunnel re-establishment is single-flight (one CONNECT at a time, queued streams wait on it) so a proxy wobble cannot stampede 50 CONNECTs.
  5. TCP_NODELAY on tunnel sockets end-to-end (absent in the Python stack today: grep finds no TCP_NODELAY in laptop-agent.py / laptop-agent-broker.py / laptop-agent-daemon.py) and coalesce header+body into one write per frame to avoid Nagle/delayed-ACK stalls on small request/response pairs.

Acceptance

  • Warm trivial exec trip p50 ≤ 50 ms (from 369 ms) at comparable load, daemon duration unchanged.
  • 128 concurrent requests over the single tunnel: 0 failures, wall ≤ ramp's 128-tunnel wall (14.6 s) by ≥5×.
  • Failure injection (kill runtime proxy briefly): calls fail or recover in ≤2 s, no 16–26 s cluster in trips.jsonl.
  • Trip logs on both sides keep the same trip id so the client/daemon split stays measurable.

Risks: single tunnel = single point of congestion/failure → mitigate with 2 tunnels + stream load-balancing and the single-flight reconnect above. HTTP/2 dependency in Rust (h2 crate) vs hand-rolled framing is an implementation choice for the builder; the wire contract (streamed frames, per-stream ids) is the requirement.

Activity

  1. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  2. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 5, 2026
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  4. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 5, 2026
  5. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  6. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  7. 66 remaining items

  8. added and removed
    status/blockedQueue or user escalation state
    on Nov 13, 2026
  9. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    Released to the queue under Drew's 2026-11-13 unblock-all order (main chat, 23:53 CT). Task(s) 15259 moved from blocked/parked to queued in the fleet unblock-all pass (worker main-unblock-all-2026-11-13). Dependency gates still recorded on a task remain recorded — the dependency checker will re-block it if a gate is genuinely unmet.

  10. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged

    Triage verdict (fresh, 2026-11-14): task 13913's packet-defect finding stands and its requested split is now executed.

    • Connection perf: multiplexed persistent streams over one tunnel (replace HTTP-per-call + pool of 50) #5756 OPEN, no hard-stop labels. Fresh check at origin/main: no yamux/multiplex code exists in pkgs/fleet/crates/fleet-proxy (pool logic still in serve.rs/http.rs) — the measured problem (transport ≈99% of call cost, CONNECT setup serializing under concurrency, 502 herds in proxy wobble) is unaddressed; fleet(proxy): fail-fast (≤2s) transport, single-flight recovery, stamped broker start (#5758) #6490 recovery and TCP_NODELAY remain landed assumptions.
    • Follow-on: queue task 16816 (small_fix whose deliverable is the merged design record, dedupe repo-health:v1:fix:developing-today/code:issue:5756) enqueued for step (a) of the 13913 split: endpoint owners, wire-protocol choice with rejected alternatives, rollout compatibility + fallback, the measurable acceptance harness, and the proposed per-crate implementation split. No wire code in that packet; implementation packets follow only after the record lands.
      Task 15259 completes as triaged naming task 16816.
  11. added a commit that references this issue on Nov 16, 2026
  12. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Agent note — done: seam record landed (task 16816, lane any-b, 2026-11-16)

    State: done (fixed_merged). The seam record is MERGED via PR #10686 (ae7170d6e9c6cd5031b3d0b7a351df507f57a08b): doc/2026-11-16T10-40-00Z_design_id5756_multiplexed_streams_seam.md.

    Decision recorded (D1): multiplexing extends the existing fleet-proxy-proto framing — a stream frame family (open/data/window/rst/ping/pong) inside the proven 8-byte length-prefixed JSON contract, negotiated by a new proxy-mux hello capability; 64 KiB frame bound, 256 KiB per-stream credit window as the backpressure bound, rst-based cancellation with a 10 s default per-stream ceiling, and tunnel failure failing all in-flight streams fast with trip ids preserved. HTTP/2 (h2), yamux-crate framing, and QUIC are rejected with reasons in the record. Rollout is capability-gated (both peers advertise, or the pooled path stays in charge byte-for-byte) under the no-one-sided-shipment rule; PR #6490's fail-fast/single-flight recovery and TCP_NODELAY are recorded as landed assumptions, not redo items.

    Per the packet, the per-crate implementation follow-ons (proto → proxy → client → broker dispatch → acceptance harness) are named in the record §7 and are enqueued only now that the record has landed — that enqueue is the next fleet action on this issue; the acceptance bar for all of them is §6 (128 concurrent / zero failures / ≤2.92 s; warm p50 ≤ 50 ms; ≤2 s failure recovery; trip-ID correlation).

  13. removed their assignment
    on Nov 20, 2026
  14. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Merged work, still open. Every pull request that references this issue has merged (#5930, #6490) and none is open, but the issue kept status:in-review. Tasks that name it as a blocker have been waiting on it.

    status:in-review is removed. Whoever takes this next: run the issue's done check against main. Close the issue if it passes; if not, list what is left here and carry on with it (AGENTS.md, "Finishing work").

    By: Claude, 2026-11-22 flow review.


    Generated by Claude Code

  15. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    Done check at origin/main c1700bc (2026-11-23): NOT landed. fleet-proxy-proto still carries only hello + request/response frames — no stream frame family, no proxy-mux capability anywhere under pkgs/fleet/. Landed assumptions confirmed present and not redo items: pooled per-port CONNECT (serve.rs), TCP_NODELAY (tunnel.rs), fail-fast/single-flight recovery (PR #6490).

    This lane lands §7 step 1 only — the fleet-proxy-proto slice: stream frame types (open/data/window/rst/ping/pong), the proxy-mux capability id + both-peers negotiation helper, window/credit semantics as types (64 KiB data-frame bound, 256 KiB initial per-stream window), and contract tests (frame bounds, unknown-field tolerance, negotiation). Dormant wire contract only — no behavior change anywhere, per the record's no-one-sided-shipment rule (§5). Steps 2–5 (proxy mux, client path, broker dispatch, acceptance harness) remain for follow-on packets.

  16. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  17. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 23, 2026
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

    epic/fleet-orchestrationReprioritization program epic (2026-11-12)queue/claimedQueue worker lifecycle statetask/triageQueue packet kind: verify, reproduce, and route this itemwork/assignedQueue worker lifecycle state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions