Skip to content

Faster output, cheaper prompt scans, and a pixel-exact grid at any scale - #17

Merged
sn merged 3 commits into
mainfrom
perf/pixels-and-speed
Nov 19, 2026
Merged

sn merged 3 commits into
mainfrom
perf/pixels-and-speed

Conversation

@sn

@sn sn commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Three changes found by measuring: a profile of heavy output, timings of the prompt scan, and headless screenshots at four display scales checked pixel by pixel. One commit each.

Before After
Showing a 200 MB file (median of 5) 3.51 s 3.12 s
Reading the last command, at command start and finish all the scrollback: 0.5 ms at 10,000 lines, 10 ms at 100,000, 106 ms at 1,000,000 (40 columns) about 1 µs at any size
Coloured prompt segment and its powerline arrow 1-pixel gap at 1.5× and 2× none at 1×, 1.25×, 1.5×, 2×
Box-drawing line widths at 1.5× 2, 1, 2, 2 pixels all 2
Row heights at 1.5× 29 and 28 pixels, alternating all 29

Throughput. The shell-integration rewriter looked at output a byte at a time. Text between escapes is now copied a stretch at a time. Checked against the old rewriter on 3,000 random streams split at random: the same bytes out.

Scrollback scans. Two things read every line of scrollback on the UI thread, with the terminal locked.

  • Naming a command when it starts or finishes now reads from the bottom up and stops a screenful above the prompts it needs.
  • The look for prompts every 200 ms during output is skipped when the shell has marked nothing new and nothing can have moved. Once scrollback is full and holds prompts, it's read as before.

Pixels. Box drawing snapped to logical pixels while cell backgrounds landed on device pixels, which is where the gap came from. Rows, cell edges, underlines and box drawing now sit on the screen's own pixels at any scale, with one line thickness for the whole grid. At 1× the output is pixel for pixel what it was. Glyphs aren't moved.

Also checked and left alone: idle CPU is near zero apart from the cursor blink, and under heavy output the time is in the terminal parser, not Lumen's UI thread (about 1% of samples).

Measured under Xvfb with a software renderer on Linux. Not checked on a real GPU, Wayland or macOS, and keypress-to-pixel latency was not measured.

sn added 3 commits November 19, 2026 18:40
The rewriter that turns the shell's marks into links looked at output a byte at a time. Text between escapes is now copied a stretch at a time. Showing a 200 MB file takes about 11% less time (3.51 s to 3.12 s, median of five). Checked against the old rewriter on 3,000 random streams, split at random: the same bytes out.
Naming a command when it starts or finishes read every line of scrollback for prompts, on the UI thread: about 0.5 ms at 10,000 lines of 40 columns, 10 ms at 100,000 and 106 ms at 1,000,000. It now reads from the bottom up and stops a screenful above the prompts it needs, about a microsecond at any size.

The look for prompts every 200 ms while output arrives is skipped when the shell has marked nothing new and what was found can't have moved: lines are counted from the oldest, which stays put until the scrollback is full. Once it is full, and holds prompts, it's read as before.
Box drawing and powerline shapes were snapped to whole logical pixels while cell backgrounds landed on device pixels, so at 1.5x and 2x a one-pixel gap opened between a coloured prompt segment and the arrow after it. At 1.5x, box lines came out 1 or 2 pixels thick and rows 28 or 29 pixels tall.

Rows are now a whole number of screen pixels tall, cell edges, underlines and strikethroughs sit between screen pixels, and box drawing is worked out in screen pixels with one line thickness for the whole grid. At 1x the output is pixel for pixel what it was. Text keeps its even spacing: glyphs aren't moved.
@sn sn self-assigned this Nov 19, 2026
@sn
sn merged commit 737bf87 into main Nov 19, 2026
3 of 4 checks passed
@sn
sn deleted the perf/pixels-and-speed branch November 19, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant