Repository navigation
Description
Problem
On Windows, command output in the integrated terminal arrives far later than the shell produced it. Printing 2,000 lines from PowerShell takes 1.9 s to reach the client; the same 2,000 lines take 0.23 s with the WSL backend on the same machine. A 50,000-line (5 MB) file takes 40 s in the app, against 17 s for the same command through ConPTY with nothing else in the way.
The cause is that the server sends one WebSocket frame per ConPTY chunk and the client acknowledges every frame. On Windows a line-at-a-time producer (PowerShell pipeline output, cmd /c type, most build and test output) gives ConPTY one chunk of about 100 bytes per line, so 50,000 lines become about 51,000 Chunk frames and 51,000 Ack frames, and 5 MB of output becomes 13.8 MB on the wire. On Linux the pty hands over larger chunks and the stream merges what is already queued, so the same 5 MB is about 225 frames.
Steps to reproduce
- On Windows, run the app (desktop, or
vp run devand a browser) with the Windows backend and open any project. - Create a file with 50,000 lines of about 100 characters (5 MB), for example in PowerShell:
0..49999 | % { "{0:d6} {1}" -f $_, ("x" * 92) } | Set-Content $env:TEMP\big.txt - Open the terminal drawer (Ctrl+J). The default shell is Windows PowerShell 5.1.
- Run
Get-Content -TotalCount 2000 $env:TEMP\big.txt, thenGet-Content $env:TEMP\big.txt, and time each until the prompt returns. - Repeat with the WSL backend (
head -n 2000,cat) on the same machine.
I timed it from pressing Enter to the WebSocket frame that carries an end marker printed after the command, by listening to the page's WebSocket frames over the Chrome DevTools Protocol.
Numbers
Windows Server 2025, 4 vCPU (Xeon Platinum 8370C), 16 GB, NTFS, Node 26.13.1, Defender on with default settings, commit a62bc81, dev server from source, headless Chromium on the same machine. The Linux baseline is the WSL backend (WSL2, Ubuntu 24.04) on the same machine, driven from the same Windows browser. Three runs each, range shown.
| Output | Windows backend, in the app | Same command through ConPTY alone (node-pty, no app) | WSL backend, in the app |
|---|---|---|---|
| 2,000 lines | 1,848 to 2,007 ms, 2,065 to 2,123 frames | 776 to 867 ms | 231 to 245 ms, 72 to 81 frames |
50,000 lines, 5 MB (Get-Content / cat) |
39.1 to 41.4 s, 51,159 to 51,612 frames, 13.8 MB received | 16.8 to 17.1 s | 0.98 to 1.19 s, 218 to 229 frames, 5.3 MB received |
50,000 lines via cmd /c type |
20.6 to 21.8 s, 23,245 to 25,100 frames | 8.4 to 8.5 s | n/a |
5 MB via Git's cat.exe (writes in 16 KB blocks) |
1.43 to 1.48 s, 486 to 517 frames | 0.72 to 0.75 s | n/a |
In every Windows run the number of frames the client sent equals the number it received: each output frame is answered by one Ack.
ConPTY itself is slow for line-at-a-time output (about 0.17 to 0.33 ms per line), and that part is Windows. The app then more than doubles it: 1.1 s added on 2,000 lines, 23 s added on 50,000.
Interactive use is not affected: a keystroke's echo frame arrives in 5.3 ms (p95 15.9, n=40) and a command's first output in 12.4 ms (p95 27.7, n=20) on Windows, the same as WSL (7.8 ms and 8.8 ms).
Where it comes from
terminalOutputStream in apps/server/src/terminal/OutputProtocol.ts only merges events that are already queued when the stream pulls (takeBatch). On Windows one line arrives every 0.2 to 0.3 ms, the stream pulls after each one, and each line goes out as its own Chunk. withOutputWindow in the same file then waits for the client's Ack once eight chunks are outstanding.
A measured direction
I ported the 2 ms batching window from the closed pull request #33324 onto this commit, on the test machine only, and reran the same script on Windows:
| Output | Before | With the 2 ms window |
|---|---|---|
| 2,000 lines | 1,848 to 2,007 ms, about 2,100 frames | 1,037 to 1,274 ms, 418 to 445 frames |
50,000 lines (Get-Content) |
39.1 to 41.4 s, about 51,300 frames | 20.8 to 22.4 s, 7,979 to 8,296 frames |
50,000 lines (cmd /c type) |
20.6 to 21.8 s | 10.1 to 10.9 s, 3,849 to 4,001 frames |
| Keystroke echo frame | 5.3 ms (p95 15.9) | 5.0 ms (p95 17.2) |
| Enter to first output frame | 12.4 ms (p95 27.7) | 11.7 ms (p95 35.5) |
That removes most of what the app adds and leaves interactive latency where it was. #33324 was measured on Linux only, where the pty already delivers large chunks, which is why it showed little there.
Expected
Bulk terminal output on Windows reaches the client in about the time ConPTY takes to produce it, with frames in the hundreds or low thousands rather than one per line.
Not covered
The machine has no GPU, so paint cost per frame in the renderer is not part of these numbers; they stop at the WebSocket frame.
Activity