Skip to content

Mirrored terminal: whole-screen repaints and one RPC per keystroke; bandwidth and typing latency are unmeasured #261

Closed

Description

@devswha

What happens

MirrorSession sends the whole screen on every change. It reads every 80 ms while the screen is changing and relaxes to 400 ms when it is not (server/mirror.ts:15-16, server/mirror.ts:41-44, server/mirror.ts:103). A pane with a spinner or streaming output, such as an agent at work, changes on almost every read. Each viewer then gets up to about 12 full-screen frames a second, relayed over SSH to the server PC and on to the browser, often a phone.

Typing is one pane.send_text per xterm onData chunk, each a new named-pipe connection on the PC, serialized per pane (server/index.ts:1381-1390). The echo appears only after the next read.

Mirror frames are never split. A single frame over 1 MiB closes an ack-mode client with 4008 (server/index.ts:374, server/output-window.ts:5). That is unlikely, but possible with a large grid in truecolor.

None of this has been measured on a Windows PC or on a phone over mobile data.

Measure

  • Frame size and frames per second for an idle shell, a working agent, and a full 200x60 truecolor screen.
  • Time from keystroke to echo over a real Add PC bridge.

Ideas, if the numbers are bad

  • Send only the rows that changed (diff row by row, with a cursor move to each).
  • Coalesce typing for a few milliseconds into one send_text.
  • Keep a frame below OUTPUT_HARD_BYTES, or exempt whole-screen frames that replace each other from the hard cap.

Activity

  1. devswha commented on Oct 2, 2026

    @devswha
    OwnerAuthor

    Fixed by #292, measured first as this issue asked.

    before after
    gjc at work on a mirrored pane (Linux), both servers on the same turn 88.2 KB/s (12.3 whole screens a second, 7.3 KB each) 10.6 KB/s
    key to echo, idle shell, mirror on Linux (median of 12) 153 ms 16 ms
    key to echo, real Windows PC over the Add PC bridge (median of 12) 159 ms 23 ms
    every cell truecolor, the whole screen changing, 119x39 56 KB a frame, 269 KB/s the same

    What changed: only the rows that changed go out (the whole screen at the start, after a resize, every 10 s while changing, and once the screen goes quiet), and the screen is read 15 ms after something is typed instead of at the mirror's own pace.

    Not done, on the numbers: typing is still one send_text per key (23 ms leaves little to gain), and a frame is not split (the largest measured was 56 KB against the 1 MiB cap; a 200x60 truecolor screen would be about 230 KB).

    Not checked: a phone over mobile data. The Windows numbers are from the build before the last review changes; the echo path did not change after it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions