Skip to content

terminal: optimize OSC string reading with SIMD - #14011

Merged
mitchellh merged 1 commit into
mainfrom
osc-simd
Aug 25, 2026
Merged

mitchellh merged 1 commit into
mainfrom
osc-simd

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

We now have large OSCs (e.g. Kitty clipboard protocol) on the order of megabytes. OSC was still byte-at-a-time. This adds a vector-optimized plus bulk storing path to OSC, similar to APC.

Throughput measured with the terminal-stream benchmark:

Corpus Before After Speedup
OSC 52, 1MiB payloads 446ms 14ms 32x
OSC 5522, 1MiB payloads 446ms 15ms 30x
OSC 5522, 64KiB payloads 448ms 14ms 32x
OSC 5522, 4KiB payloads 448ms 16ms 29x
Tiny titles (~24B each) 450ms 73ms 6.2x
Mixed OSCs (16MiB) 595ms 531ms 1.13x

Used Fable to help validate this with a barrage of differential tests. The actual implementation was AI-written but was guided to basically mimic the APC path and then I hand verified everything too.

@mitchellh mitchellh added this to the 1.4.0 milestone Aug 25, 2026
@mitchellh
mitchellh requested a review from a team as a code owner August 25, 2026 13:38
@ghostty-bot ghostty-bot Bot added the vt Control sequence related label Aug 25, 2026
We now have large OSCs (e.g. Kitty clipboard protocol) on the order
of megabytes. OSC was still byte-at-a-time. This adds a vector-optimized
plus bulk storing path to OSC, similar to APC.

Throughput measured with the terminal-stream benchmark:

| Corpus                   | Before | After | Speedup |
|--------------------------|--------|-------|---------|
| OSC 52, 1MiB payloads    | 446ms  | 14ms  | 32x     |
| OSC 5522, 1MiB payloads  | 446ms  | 15ms  | 30x     |
| OSC 5522, 64KiB payloads | 448ms  | 14ms  | 32x     |
| OSC 5522, 4KiB payloads  | 448ms  | 16ms  | 29x     |
| Tiny titles (~24B each)  | 450ms  | 73ms  | 6.2x    |
| Mixed OSCs (16MiB)       | 595ms  | 531ms | 1.13x   |

Used Fable to help validate this with a barrage of differential tests.
The actual implementation was AI-written but was guided to basically
mimic the APC path and then I hand verified everything too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vt Control sequence related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant