szn

Bug 476 — Performance cluster 3: per-frame O(cells) taxes, quadratic reflow, per-frame allocs

476. Hot-loop and per-frame allocation inventory

Severity: MEDIUM (performance) Status: ✅ FIXED Files: src/server/render.zig, src/grid.zig, src/screen.zig, src/status.zig, src/format.zig, src/char_width.zig, src/options.zig, src/cmd/cmd.zig, src/cfg.zig, src/input.zig


Render per-frame O(cells) with per-cell sub-costs

Grid rewrap O(n^2) and per-op memmove

Screen 64-slot scans + per-char shifts

Status / format / options per-frame allocs and scans

Proposed Fix

Batch by area: cache historyLen/footprints per frame; hoist sixel scans behind a pane_has_sixels bit; reserve capacities (ensureTotalCapacity) for status/format/capture/parse buffers; memoize compiled formats per template; replace hottest linear scans (overrides, option defs) with comptime maps; single-pass rewrap with bounded backtrack. Profile with bench.sh before/after.


Resolution

Fixed the items with a safe, behavior-preserving change; the rest were re-measured and are documented below as benign (fixing them would add risk for nanosecond-scale gains).

Implemented

Evaluated, no change (benign at current scale)

Full suite (zig build test) passes; no behavior change, only fewer reallocs on the measured paths.