@@ -135,6 +135,11 @@ Methodology:
135135 - A sample replays the corpus into the same engine until at least ` --min-ms `
136136 (500 ms by default) has elapsed, so fast targets are not dominated by
137137 timer noise.
138+ - Laptop CPUs leave turbo a few seconds into sustained load: on the machine
139+ below, throughput falls about 3x after ~ 2.7 s and stays there, whatever
140+ the engine does. With 500 ms samples, runs land on both sides of that drop
141+ and spreads reach 50–180%. Samples of ~ 3 s (` --min-ms 3000 ` , or the
142+ script's ` -MinMs 3000 ` ) all run at the sustained clock.
138143- ** Conservative verdict.**
139144 - ` faster ` only when builtin's * slowest* run beats Ghostty's * fastest* .
140145 - ` slower ` when the reverse holds.
@@ -169,6 +174,7 @@ Workloads (`--workloads a,b,...`):
169174``` powershell
170175pwsh scripts/Invoke-TerminalBenchmarks.ps1 # vt + render, results in artifacts/bench/<timestamp>
171176pwsh scripts/Invoke-TerminalBenchmarks.ps1 -Quick # fast local signal
177+ pwsh scripts/Invoke-TerminalBenchmarks.ps1 -Suite vt -MinMs 3000 # ~3 s samples: stable on CPUs that leave turbo under load
172178pwsh scripts/Invoke-TerminalBenchmarks.ps1 -Baseline artifacts/bench/<previous>/vt.json # fails if builtin/ghostty-vt drops >15% on identical inputs
173179pwsh scripts/Invoke-TerminalBenchmarks.ps1 -RequireBeatGhostty # fails unless builtin wins every vt workload
174180pwsh scripts/Invoke-TerminalBenchmarks.ps1 -GhosttyBench <path>\ghostty-bench.exe # also replays the corpora through upstream +terminal-stream
@@ -198,37 +204,44 @@ lists the full set of gates.
198204
199205Setup for these numbers:
200206
201- - One Windows 11 x64 workstation (24 logical CPUs, AVX2), .NET 10.0.13 (JIT,
202- tiered compilation off), and the pinned ` libghostty-vt ` (ReleaseFast).
203- - 120x30 grid, 16 KiB chunks, 8 MiB per workload, 7 timed runs plus 1 warmup.
207+ - One Windows 11 x64 laptop (Intel Core Ultra 9 285HX, 24 cores, AVX2),
208+ .NET 10.0.14 (JIT, tiered compilation off), and the pinned ` libghostty-vt `
209+ (ReleaseFast).
210+ - 120x30 grid, 16 KiB chunks, 8 MiB per workload, 7 timed runs plus 1 warmup,
211+ samples of at least 3 s.
204212- Each workload ran in its own process, via:
205213
206214 ``` powershell
207- pwsh scripts/Invoke-TerminalBenchmarks.ps1 -Suite vt,render
215+ pwsh scripts/Invoke-TerminalBenchmarks.ps1 -Suite vt -MinMs 3000
208216 ```
209217
210- This machine's absolute speed drifted by up to 2.5x between invocations
211- (Ghostty itself moved from ~ 540 to ~ 1,600 MB/s on ` light-cells ` ). So read the
218+ This machine's absolute speed drifts by up to 2.5x between invocations,
219+ mostly with the CPU's turbo state (see * Fair timing * above ). So read the
212220** builtin / ghostty-vt ratio** , which is measured within each run, and treat
213221anything within about ±10% of 1.0 as a tie. Throughput is the median MB/s.
214222
215223### Ingest: builtin engine vs raw ` libghostty-vt `
216224
217225| Workload | builtin | ghostty-vt | ghostty (DT) | ratio | verdict | builtin alloc / MiB | screens |
218226| --- | ---: | ---: | ---: | ---: | --- | ---: | --- |
219- | ascii | 1,144 | 922 | 411 | ** 1.24x** | overlap | 31 KB | identical |
220- | ascii-lines | 879 | 741 | 361 | ** 1.19x** | ** faster** | 40 KB | identical |
221- | light-cells | 2,024 | 1,647 | 60 | ** 1.23x** | ** faster** | 0 | identical |
222- | scrolling | 42.5 | 31.9 | 29.5 | ** 1.33x** | overlap | 0.7 MB | identical |
223- | dense-cells | 207 | 144 | 53 | ** 1.44x** | ** faster** | 0 | identical |
224- | styled | 78.4 | 26.9 | 24.8 | ** 2.91x** | ** faster** | 5.4 MB | 1 row differs |
225- | osc | 124 | 27.0 | 25.1 | ** 4.59x** | ** faster** | 6.9 MB | identical |
226- | mixed | 667 | 362 | 227 | ** 1.84x** | ** faster** | 54 KB | identical |
227- | scroll-region | 641 | 669 | 56 | 0.96x | overlap | 0 | identical |
228- | cursor-motion | 152 | 168 | 94 | 0.90x | slower | 33 KB | identical |
229- | emoji | 588 | 736 | 267 | 0.80x | overlap | 61 KB | identical |
230- | utf8 | 61.3 | 79.6 | 70.1 | 0.77x | slower | 8.7 MB | identical |
231- | cjk | 458 | 596 | 299 | 0.77x | slower | 78 KB | identical |
227+ | osc | 147 | 25.3 | 23.5 | ** 5.82x** | ** faster** | 6.7 MB | identical |
228+ | styled | 45.9 | 18.0 | 13.2 | ** 2.54x** | ** faster** | 1.4 MB | 1 row differs |
229+ | mixed | 787 | 366 | 229 | ** 2.15x** | ** faster** | 8 KB | identical |
230+ | dense-cells | 262 | 138 | 51 | ** 1.90x** | ** faster** | 0 | identical |
231+ | scrolling | 56.5 | 32.6 | 31.9 | ** 1.73x** | ** faster** | 104 KB | identical |
232+ | utf8 | 80.1 | 59.0 | 69.3 | ** 1.36x** | overlap | 92 KB | identical |
233+ | light-cells | 2,265 | 1,737 | 62 | ** 1.30x** | ** faster** | 0 | identical |
234+ | emoji* | 816 | 672 | 301 | ** 1.21x** | ** faster** | 7 KB | identical |
235+ | ascii | 1,145 | 971 | 448 | ** 1.18x** | ** faster** | 5 KB | identical |
236+ | ascii-lines | 716 | 626 | 286 | ** 1.14x** | overlap | 9 KB | identical |
237+ | cjk* | 583 | 522 | 237 | ** 1.12x** | ** faster** | 10 KB | identical |
238+ | scroll-region | 865 | 782 | 58 | ** 1.11x** | ** faster** | 0 | identical |
239+ | cursor-motion | 188 | 172 | 95 | ** 1.09x** | ** faster** | 32 KB | identical |
240+
241+ \* From a later invocation of those two workloads alone. In the full run they
242+ landed in a noisy stretch (spreads over 50%) and measured 0.98x and 1.22x.
243+ Other quiet runs of the same code measured 1.07–1.21x on cjk and 1.18x on
244+ emoji.
232245
233246` ghostty (DT) ` skips projection without ` --frame-kb ` . The one-row difference in
234247` styled ` is a behavior difference, not a measurement artifact: builtin drops a
@@ -237,21 +250,23 @@ combining mark that follows a space, and Ghostty keeps it.
237250How builtin got here, as the median builtin/ghostty-vt ratio per round (each
238251round measured against its own in-run Ghostty control):
239252
240- | Workload | ` dc1cd26 ` | round 1 | round 2 (packed cells) | round 3 | round 4 |
241- | --- | ---: | ---: | ---: | ---: | ---: |
242- | ascii | 0.009 | 0.20 | 0.55 | 1.21 | 1.24 |
243- | ascii-lines | 0.009 | 0.20 | 0.50 | 1.13 | 1.19 |
244- | light-cells | 0.009 | 0.32 | 0.48 | 1.20 | 1.23 |
245- | scrolling | 0.015 | 0.14 | 0.40 | 1.11 | 1.33 |
246- | dense-cells | 0.42 | 0.63 | 0.62 | 1.57 | 1.44 |
247- | styled | 0.30 | 1.33 | 1.14 | 2.82 | 2.91 |
248- | osc | 0.29 | 2.60 | 4.52 | 4.57 | 4.59 |
249- | mixed | 0.03 | 0.39 | 0.45 | 1.56 | 1.84 |
250- | scroll-region | 0.018 | 0.22 | 0.34 | 0.90 | 0.96 |
251- | cursor-motion | 0.11 | 0.23 | 0.17 | 0.94 | 0.90 |
252- | utf8 | 0.10 | 0.36 | 0.27 | 0.57 | 0.77 |
253- | cjk | — | — | — | 0.53 | 0.77 |
254- | emoji | — | — | — | 0.50 | 0.80 |
253+ | Workload | ` dc1cd26 ` | round 1 | round 2 (packed cells) | round 3 | round 4 (` f45b95b ` ) | round 5 |
254+ | --- | ---: | ---: | ---: | ---: | ---: | ---: |
255+ | ascii | 0.009 | 0.20 | 0.55 | 1.21 | 1.24 | 1.18 |
256+ | ascii-lines | 0.009 | 0.20 | 0.50 | 1.13 | 1.19 | 1.14 |
257+ | light-cells | 0.009 | 0.32 | 0.48 | 1.20 | 1.23 | 1.30 |
258+ | scrolling | 0.015 | 0.14 | 0.40 | 1.11 | 1.33 | 1.73 |
259+ | dense-cells | 0.42 | 0.63 | 0.62 | 1.57 | 1.44 | 1.90 |
260+ | styled | 0.30 | 1.33 | 1.14 | 2.82 | 2.91 | 2.54 |
261+ | osc | 0.29 | 2.60 | 4.52 | 4.57 | 4.59 | 5.82 |
262+ | mixed | 0.03 | 0.39 | 0.45 | 1.56 | 1.84 | 2.15 |
263+ | scroll-region | 0.018 | 0.22 | 0.34 | 0.90 | 0.96 | 1.11 |
264+ | cursor-motion | 0.11 | 0.23 | 0.17 | 0.94 | 0.90 | 1.09 |
265+ | utf8 | 0.10 | 0.36 | 0.27 | 0.57 | 0.77 | 1.36 |
266+ | cjk | — | — | — | 0.53 | 0.77 | 1.12 |
267+ | emoji | — | — | — | 0.50 | 0.80 | 1.21 |
268+
269+ Round 5 was measured with 3 s samples; earlier rounds used 500 ms samples.
255270
256271The ` -Baseline ` gate flagged real regressions twice:
257272
@@ -260,12 +275,15 @@ The `-Baseline` gate flagged real regressions twice:
260275 the short-ASCII path.
261276
262277Each was confirmed with an interleaved A/B build and fixed before moving on.
263- Moves of about ±10% between rounds (dense-cells and cursor-motion from round 3
264- to round 4, for example) are within this machine's noise.
278+ Round 5 passed the gate after each change. Moves of about ±10% between rounds
279+ (ascii and ascii-lines into round 5, for example) are within this machine's
280+ noise. styled's 2.54x comes from a run with a 136% spread; single-workload
281+ runs of the same code measured 3.39–3.61x.
265282
266283### DT's Ghostty mode vs raw ` libghostty-vt ` , with frames
267284
268285These numbers use ` --frame-kb 256 ` , so a projection is taken every 256 KiB.
286+ They were measured in round 4; round 5 did not change the Ghostty engine.
269287
270288| Workload | ghostty (DT) before | after | ghostty-vt | ratio before → after |
271289| --- | ---: | ---: | ---: | ---: |
@@ -280,7 +298,7 @@ per-cell P/Invoke projection still dominates.
280298
281299### Frame preparation and CPU paint
282300
283- ` render ` , 120x30, median p50 / p95:
301+ ` render ` , 120x30, median p50 / p95, measured in round 4 :
284302
285303| Stage | before packed cells | now |
286304| --- | --- | --- |
@@ -298,14 +316,18 @@ No Ghostty counterpart exists on Windows.
298316
299317Every fast path is checked against the per-character path by differential
300318tests (` AsciiFastPathTests ` , ` CsiFastPathTests ` , ` CellRowModelTests ` ,
301- ` PackedCellStorageTests ` ). Each new branch was also checked by deliberately
302- breaking it and confirming a test fails.
319+ ` PackedCellStorageTests ` , ` CombiningTableTests ` ). Each new branch was also
320+ checked by deliberately breaking it and confirming a test fails.
303321
304322- ** Packed, reference-free storage** (` CellRow ` , ` PackedCell ` ).
305323 - A cell is 16 bytes with no GC references, down from about 40 with two
306324 ` string? ` fields.
307- - Combining text and hyperlinks live in per-line side arrays that exist only
308- while needed and are freed when the line is recycled.
325+ - Hyperlinks live in a per-line side array that exists only while needed.
326+ - Combining text is interned per buffer (` CombiningTable ` ), and lines store
327+ int IDs. A cluster seen before costs no allocation, a recycled line keeps
328+ its ID array, and the table compacts so ever-new clusters cannot grow it
329+ without bound. This took utf8 from 9.4 MB to under 0.1 MB allocated per
330+ MiB.
309331 - The public ` Cell ` and ` TermColor ` are unchanged, and every value round-trips
310332 losslessly.
311333- ** Logically blank cells are never written.**
@@ -318,54 +340,67 @@ breaking it and confirming a test fails.
318340 - ** ASCII:** the parser hands whole printable-ASCII runs to
319341 ` IVtDispatch.PrintAscii ` . They are stored a row segment at a time, two
320342 64-bit (or, with AVX2, two 256-bit per four cells) stores per cell batch.
321- - ** UTF-8 runs:** well-formed UTF-8 runs (2–4 byte sequences decoded inline)
322- go to ` IVtDispatch.PrintRunes ` .
343+ - ** UTF-8 runs:** well-formed UTF-8 runs go to ` IVtDispatch.PrintRunes ` .
344+ Runs of 3- or 4-byte sequences (CJK, emoji) are decoded four at a time
345+ from 16-byte ` Vector128 ` loads, with the scalar decoder's validity rules
346+ (no overlong forms, surrogates or values past U+10FFFF); anything else
347+ falls back to the scalar decoder. On CJK this decodes about 3x faster.
323348 - ** Grapheme joins:** precomputed tables for planes 0 and 1 rule out joins,
324349 so runes that cannot join are stored a segment at a time. That includes
325- emoji after a cell without a trailing ZWJ.
350+ emoji after a cell without a trailing ZWJ. A zero-width rune with no join
351+ property (a combining accent, ZWJ) goes straight into the previous cell's
352+ combining text.
326353 - ** Rows without wide glyphs:** a conservative per-row "may hold wide cells"
327354 flag means classifying and storing happen in one pass, with no clearing
328- around wide glyphs. Every freshly recycled scrollback line qualifies.
329- - ** CSI fast path.** A complete plain CSI sequence is parsed in one pass, then
330- goes through the same ` DispatchCsi ` as the byte path. Parameters are copied
331- into reused arrays.
355+ around wide glyphs. Every freshly recycled scrollback line qualifies. That
356+ pass ORs each rune into precomputed template bits and writes one 16-byte
357+ store per cell, with widths from a table where ambiguous widths are already
358+ resolved.
359+ - ** Short writes:** the packed print templates are cached and rebuilt only
360+ when the attributes, protection or shell-integration state change, and a
361+ single printable byte between escape sequences is one store.
362+ - ** CSI fast path.** A complete plain CSI sequence is parsed in one pass,
363+ straight into the arrays the dispatcher receives, and the parser calls the
364+ engine directly instead of through ` IVtDispatch ` . Sequences with no private
365+ marker or intermediate byte skip the special cases and go straight to the
366+ switch on the final byte.
332367- ** C0 fast path.** CR, LF and other controls in ground state go straight to
333368 ` ExecuteC0 ` instead of through the string-state checks.
334369- ** Scroll regions** rotate line references with ` Array.Copy ` , not one
335370 indexer call per line.
336371
337372### What still separates builtin from Ghostty
338373
339- - ** Non-ASCII text** (` cjk ` , ` emoji ` , ` utf8 ` : about 0.8x). On CJK, per scalar:
340-
341- | Stage | Cost |
342- | --- | --- |
343- | Builtin: decode | ~ 2.0 ns |
344- | Builtin: storage (two 16-byte cells per wide character) | ~ 3.6 ns |
345- | Builtin: dispatch | ~ 0.6 ns |
346- | Ghostty: everything | ~ 5 ns |
347-
348- What was tried and measured:
349- - ** Runtime SIMD transcoder.** Swapping the scalar decoder for the runtime's
350- SIMD ` Utf8.ToUtf16 ` (plus a UTF-16-to-rune pass) was * slower* at these run
351- lengths, and was reverted.
352- - ** Unchecked scalar decoding.** A ` ref ` -based decoder with unchecked ` Rune `
353- construction measured the same as the indexed one.
354-
355- Closing the rest needs either a purpose-built SIMD UTF-8 decoder or 8-byte
356- cells.
357- - ** cursor-motion and scroll-region** are ties within noise (0.90–0.96x). Per
358- escape sequence, builtin still pays for an interface call into the engine
359- and that call's own checks before each short write.
360- - ** Cell size.** Packed cells are 16 bytes against Ghostty's 8, so a cleared
361- or copied row moves twice the memory. Getting to 8 bytes means interning
362- styles, which is a larger change.
374+ Builtin now leads on every workload. The closest leads, ` cursor-motion ` ,
375+ ` scroll-region ` and ` cjk ` (1.09–1.12x), sit near the ±10% band of this
376+ machine's noise, and ` ascii-lines ` and ` utf8 ` still get ` overlap ` verdicts
377+ from run-to-run spread. Timed stage by stage on CJK after round 5 (one engine
378+ reused with history full, per scalar, all stages in one process):
379+
380+ | Stage | Cost |
381+ | --- | --- |
382+ | UTF-8 decode, block path | ~ 0.5–1.0 ns |
383+ | Parser per-line work (CR/LF dispatch, run setup) | ~ 0.7–1 ns |
384+ | Cell stores (two 16-byte cells per wide character) | ~ 2 ns |
385+ | Buffer CR/LF, scrolling and line reuse | ~ 0.7 ns |
386+
387+ - ** Parser per-line overhead** now costs about as much as the decode. Each
388+ CR and LF still goes through an interface call, and each line's run of
389+ characters pays its setup once.
390+ - ** Cell size.** Packed cells are 16 bytes against Ghostty's 8, so storing,
391+ clearing or copying a row moves twice the memory. Getting to 8 bytes means
392+ interning styles, which is a larger change.
393+ - ** What did not help.** Prefetching the scrollback lines about to be reused
394+ measured slower: with history full, steady-state throughput is the same at
395+ 100 and 9,000 lines, so cold recycled lines are not a bottleneck.
363396
364397** Variance.** Within isolated processes the ratio repeats to about ±10% on
365- this machine. In one long process running every workload, ratios drifted by
366- up to 50%, because heap state carried over between workloads. For that reason
367- the script runs one process per workload, and ` -Baseline ` only compares
368- workloads with the same SHA-256 and gates on the ratio, not on absolute MB/s.
398+ this machine with 3 s samples. With 500 ms samples, runs straddle the CPU's
399+ turbo drop and single workloads swing by 50% or more. In one long process
400+ running every workload, ratios also drifted by up to 50%, because heap state
401+ carried over between workloads. For that reason the script runs one process
402+ per workload, and ` -Baseline ` only compares workloads with the same SHA-256
403+ and gates on the ratio, not on absolute MB/s.
369404
370405## Definition of "matches or beats Ghostty"
371406
0 commit comments