diff options
| author | user <user@clank> | 2026-09-03 16:26:41 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-03 16:26:41 +0200 |
| commit | e3059676a6b342ea9ff07753d5b976e854d4b111 (patch) | |
| tree | 0bd6dd5bb7bb95503d116bddc0b7633b46d46de0 /src/app_ui.c | |
| parent | web: card (diff) | |
| download | slosh-e3059676a6b342ea9ff07753d5b976e854d4b111.tar.gz slosh-e3059676a6b342ea9ff07753d5b976e854d4b111.tar.xz slosh-e3059676a6b342ea9ff07753d5b976e854d4b111.zip | |
pane: drop the render snapshot of panes on hidden tabs -- 154K -> 66K each
An updated GhosttyRenderState retains a full copy of the pane's viewport
(rows, cells, per-row arenas, styles) so renders can read it without the
terminal lock. Measured with bpftrace and a lib-vt micro-benchmark, that
copy is ~140KB for an 80x24 pane -- more than twice the terminal it
mirrors (~57KB) -- and every pane kept one forever, composed or not.
Only the current tab is ever composed, so app_compose now drops the
snapshot of every pane on the other tabs (a pointer test once dropped),
and pane_new no longer creates one at all: pane_compose and
pane_select_word build it on first use. Both already begin with
ghostty_render_state_update(), so a dropped snapshot is rebuilt, never
missed, and the tab switch already forces a full repaint.
Server memory per empty 80x24 terminal drops from 154K to 66K anon
(Superlogical reports 68K on macOS; tmux 4K, zellij 1.2-6.2M). Fifty
background tabs: 8.2M -> 3.8M, reclaimed on close, and cycling through
tabs does not ratchet. What remains is the lib-vt terminal itself.
Diffstat (limited to 'src/app_ui.c')
| -rw-r--r-- | src/app_ui.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/app_ui.c b/src/app_ui.c index d03ddd4..8daf8f1 100644 --- a/src/app_ui.c +++ b/src/app_ui.c @@ -985,6 +985,11 @@ bool rename_key(app_t *a, const input_event_t *ev) { return true; } +static void drop_render_cb(node_t *n, void *ud) { + (void)ud; + if (n->pane) pane_render_cache_drop(n->pane); +} + void app_compose(app_t *a, screen_t *s) { screen_clear(s); /* every frame starts blank: no ghosts in the gap ring */ hit_reset(&s->hits); @@ -994,6 +999,16 @@ void app_compose(app_t *a, screen_t *s) { a->animating = false; if (!a->ntabs || !cur(a)->root) return; + /* Only the current tab is composed, but a composed pane retains a viewport + * copy inside its render state (~140KB at 80x24) that nothing will read + * until its tab is looked at again -- at which point it is rebuilt from the + * terminal anyway. Dropping it here, rather than on the tab switch, catches + * every route a tab can leave the screen by; for a pane already dropped it + * is a pointer test. */ + for (size_t i = 0; i < a->ntabs; i++) + if (i != a->cur && a->tabs[i].root) + walk(a->tabs[i].root, drop_render_cb, NULL); + /* Looking at a pane is the acknowledgement, and it happens before anything * is drawn rather than while the pane itself is: the tab strip is painted * first and would otherwise spend a frame reporting a bell that had just |
