alacritty / vte

Parser for virtual terminal emulators
https://docs.rs/vte/
Apache License 2.0
242 stars 56 forks source link

Added APC support #110

Closed John-Toohey closed 1 month ago

John-Toohey commented 9 months ago

Fixes #109.

This adds support for APC (Application Program Command) in the same way OSC is implemented. It does, however, have the drawback of (just over) doubling the in-memory footprint of the table::STATE_CHANGES static, for it became necessary to split State and Action as the amount of variants within Action exceeded 15, meaning it was no longer possible for it to be a pseudo u4.

More detail in the commit messages.

Thank you for your time.

John-Toohey commented 7 months ago

I've worked on performance, and have got the following results (from vtebench):

Summary Table

TL;DR About the same in both master and the patch

master (ms) John-Toohey:apc (ms)
cursor_motion 125.9 ± 23.72 119.24 ± 18.61 🟢
dense_cells 357.36 ± 23.02 335.43 ± 13.69 🟢
light_cells 157.11 ± 15.96 151.83 ± 18.97 🟢
scrolling 485.88 ± 99.5 444.17 ± 14.44 🟢
scrolling_bottom_region 449.83 ± 9.96 🟢 475.5 ± 46.53
scrolling_bottom_small_region 1486.29 ± 67.27 1436.43 ± 11.07 🟢
scrolling_fulscreen 142.09 ± 8.89 141.37 ± 16.11 🟢
scrolling_top_region 1538.14 ± 22.46 1391.38 ± 9.32 🟢
scrolling_top_small_region 1358.63 ± 29.52 1308.38 ± 14.42 🟢
unicode 150.99 ± -20.21 🟢 151.41 ± 35.04

🟢 = fastest

Raw Results

Normal Alacritty:

Results:

  cursor_motion (80 samples @ 1.41 MiB):
    125.9ms avg (90% < 151ms) +-23.72ms

  dense_cells (28 samples @ 4.1 MiB):
    357.36ms avg (90% < 398ms) +-23.02ms

  light_cells (64 samples @ 1.06 MiB):
    157.11ms avg (90% < 166ms) +-15.96ms

  scrolling (17 samples @ 1 MiB):
    485.88ms avg (90% < 651ms) +-99.5ms

  scrolling_bottom_region (23 samples @ 1 MiB):
    449.83ms avg (90% < 463ms) +-9.96ms

  scrolling_bottom_small_region (7 samples @ 1 MiB):
    1486.29ms avg (90% < 1634ms) +-67.27ms

  scrolling_fullscreen (35 samples @ 1 MiB):
    142.09ms avg (90% < 154ms) +-8.89ms

  scrolling_top_region (7 samples @ 1 MiB):
    1538.14ms avg (90% < 1577ms) +-22.36ms

  scrolling_top_small_region (8 samples @ 1 MiB):
    1358.63ms avg (90% < 1431ms) +-29.52ms

  unicode (67 samples @ 1.06 MiB):
    150.99ms avg (90% < 177ms) +-20.21ms

Alacritty + John-Toohey:apc

Results:

  cursor_motion (84 samples @ 1.41 MiB):
    119.24ms avg (90% < 153ms) +-18.61ms

  dense_cells (30 samples @ 4.1 MiB):
    335.43ms avg (90% < 347ms) +-13.69ms

  light_cells (66 samples @ 1.06 MiB):
    151.83ms avg (90% < 182ms) +-18.97ms

  scrolling (18 samples @ 1 MiB):
    444.17ms avg (90% < 455ms) +-14.44ms

  scrolling_bottom_region (22 samples @ 1 MiB):
    475.5ms avg (90% < 506ms) +-46.53ms

  scrolling_bottom_small_region (7 samples @ 1 MiB):
    1436.43ms avg (90% < 1450ms) +-11.07ms

  scrolling_fullscreen (35 samples @ 1 MiB):
    141.37ms avg (90% < 156ms) +-16.11ms

  scrolling_top_region (8 samples @ 1 MiB):
    1391.38ms avg (90% < 1412ms) +-9.32ms

  scrolling_top_small_region (8 samples @ 1 MiB):
    1308.38ms avg (90% < 1339ms) +-14.42ms

  unicode (66 samples @ 1.06 MiB):
    151.41ms avg (90% < 179ms) +-35.04ms

vte's benchmarks

TL;DR Approximately the same.

alacritty/vte:master

test bench::state_changes ... bench:     99,218 ns/iter (+/- 1,106)
test bench::testfile      ... bench:     98,814 ns/iter (+/- 1,364)

John-Toohey:apc

test bench::state_changes ... bench:     100,910 ns/iter (+/- 1,106)
test bench::testfile      ... bench:      98,791 ns/iter (+/- 1,364)
John-Toohey commented 7 months ago

As for how this new solution works, it basically takes the implementation of OscString and makes it work over all 4 types of strings (so it actually works for SOS and PM strings too) meaning that the STATE_CHANGES is still an array of u8s. This also means there is now a Null state to replace ApcPmSos, which is no longer a special case.

chrisduerr commented 7 months ago

@John-Toohey If you have an Alacritty revision that is built against this, could you put that up in a draft PR on the Alacritty repo? That way I can easily run performance tests against it.

chrisduerr commented 1 month ago

Dead PR see https://github.com/alacritty/vte/pull/115.