vt: CSI parameter parsing is 10.7% of the parse thread under DOOM-fire #417

Closed
opened 2026-09-25 05:31:28 +09:00 by natsukium · 0 comments
Owner

Split from #399.

Params::push_run (crates/felis-vt/src/lib.rs), the bulk CSI-parameter arm of Parser::advance, is the second-largest self-time frame of the parse thread under DOOM-fire. Linux profile of the daemon (i5-12400F, felis main ef96bb46, release with line tables, perf record -e cycles:u --call-graph lbr, 15 s of DOOM-fire at 188x93, load 5.2), share of felis-pty-parser samples, self time:

frame self
Grid::put_grapheme 11.0%
Params::push_run 10.7%
Grid::print_wide_str 9.7%
build_sink closure, Parser::advance inlined 8.9%
StyleTable::intern 8.2% (#416)
Grid::csi_dispatch 7.4%
Parser::advance_byte 6.0%

About 85% of DOOM-fire's bytes are 38;5;N / 48;5;N SGRs (.agents/skills/perf-trace/references/cost-maps.md "SGR flood / DOOM-fire"), so parameter parsing runs on most of the stream. push_run already replaced a per-byte arm (+38% on the doom floor); the next step would be decoding a parameter's digits with fewer branches per byte.

Any change here is guarded by the chunk-invariance test and the vt_parser fuzz target, and the "Accepted cost" note in cost-maps (the sparse full-screen scroll floor reads −5% with the bulk arm present) has to be re-checked.

Done when push_run's share drops by a measured amount on the doom floor bench without the scroll floor regressing, or the profile shows the decode is at its floor and the reason is recorded.

Split from #399. `Params::push_run` (`crates/felis-vt/src/lib.rs`), the bulk CSI-parameter arm of `Parser::advance`, is the second-largest self-time frame of the parse thread under DOOM-fire. Linux profile of the daemon (i5-12400F, felis `main` ef96bb46, release with line tables, `perf record -e cycles:u --call-graph lbr`, 15 s of DOOM-fire at 188x93, load 5.2), share of `felis-pty-parser` samples, self time: | frame | self | |---|---| | `Grid::put_grapheme` | 11.0% | | **`Params::push_run`** | **10.7%** | | `Grid::print_wide_str` | 9.7% | | `build_sink` closure, `Parser::advance` inlined | 8.9% | | `StyleTable::intern` | 8.2% (#416) | | `Grid::csi_dispatch` | 7.4% | | `Parser::advance_byte` | 6.0% | About 85% of DOOM-fire's bytes are `38;5;N` / `48;5;N` SGRs (`.agents/skills/perf-trace/references/cost-maps.md` "SGR flood / DOOM-fire"), so parameter parsing runs on most of the stream. `push_run` already replaced a per-byte arm (+38% on the doom floor); the next step would be decoding a parameter's digits with fewer branches per byte. Any change here is guarded by the chunk-invariance test and the `vt_parser` fuzz target, and the "Accepted cost" note in cost-maps (the sparse full-screen scroll floor reads −5% with the bulk arm present) has to be re-checked. Done when `push_run`'s share drops by a measured amount on the doom floor bench without the scroll floor regressing, or the profile shows the decode is at its floor and the reason is recorded.
Commenting is not possible because the repository is archived.
No description provided.