szn

Bug 425 — Performance cluster 2

425. Performance cluster 2: status cache defeated exactly when it matters, per-frame recompiles, whole-scrollback rebuild per search keystroke, runtime binding scans vs the comptime mandate

Severity: LOW Status: ✅ RESOLVED

(a) #309’s status cache is consulted only if (!self.dirty and ...) — but self.dirty is true on every keystroke and every output burst, i.e. for essentially every rendered frame that needs a status update (clock seconds, pane titles, activity). Busy panes therefore rebuild the whole line per frame per client: fresh Context (~7 dupes), per-window expandOps + truncateVisible allocations, then a second dupe into dc.status_line while freeing the just-built line (:3082-3083). (b) expandInto recompiles every nested #…/conditional argument into a fresh ops ArrayList per call (format.zig:197-206) — parse work at every nesting level, every redraw. (c) Copy-mode search rebuilds UTF-8 text + byte-offset tables for every logical line across the entire scrollback on each /, n, N keystroke, allocating fresh GPA buffers per call (mode_copy.zig:395-537). (d) Key-binding tables are runtime linear-scan ArrayLists consulted per input byte (twice per byte when the root table is non-empty) — AGENTS.md explicitly mandates comptime-generated binding tables; #393 fixed adjacent lookups but not this one. (e) handlePtyEvent scans client_fds per event (:732) while run() rescans per event (:653) — foldable into the existing fd→kind map. See also #404.

Fix: key the status cache on a second-granularity clock tick + explicit invalidation (not !dirty); cache compiled ops for nested templates; memoize the scrollback line table per grid generation; comptime default tables + a small map for user overrides.