Commit 4d5790f
feat(tunnel): fully separated upload/download tasks, wseq write ordering
Architecture:
- Upload task (spawned): reads client socket → sends MuxMsg::Data with
wseq directly to mux → sends InflightEntry to download task. Fully
independent, never blocked by downloads.
- Download task (inline): processes replies, sends refill polls (timer),
accepts InflightEntry. Never blocked by uploads.
- Lock-free mpsc channels throughout — no Mutex contention.
Write ordering (wseq):
- Client assigns monotonic wseq to data-bearing ops only (not polls).
- Tunnel-node buffers out-of-order writes per session, flushes in wseq
order. Backward compatible: old clients without wseq write immediately.
- Fixes data corruption from pipelined batches completing out of order.
Upload accumulation:
- Adaptive: 50ms initial window for small messages (low latency).
- If >= 32KB accumulated, extend to 1s / 1MB cap (fat uploads for files).
Other:
- Removed consecutive_empty gate on refill (was killing idle sessions).
- Tunnel-node reader buffer 2MB (was 512KB).
- Removed legacy detection (was false-triggering on merged replies).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 47b22b9 commit 4d5790f
3 files changed
Lines changed: 487 additions & 308 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
535 | 537 | | |
536 | 538 | | |
537 | 539 | | |
| |||
0 commit comments