Repository navigation
Faster output, cheaper prompt scans, and a pixel-exact grid at any scale - #17
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.
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.