Skip to content

perf(tui): skip prefix rebuild on steady-state refresh and cache canvas probes - #146

Merged
jkyberneees merged 1 commit into
mainfrom
perf/tui-hot-paths
Oct 3, 2026
Merged

jkyberneees merged 1 commit into
mainfrom
perf/tui-hot-paths

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

What

  • conversation() reuses the joined convPrefix (and its cached line count) when the finalized-message count is unchanged — the hot path for the ~12 Hz render flush while a turn streams. Per-block invalidation drops the joined prefix too, since it embeds the changed block.
  • paintCanvas caches its SGR probe colors per theme; theme switch invalidates.
  • resize skips the glamour renderer rebuild and full-transcript re-render when the wrap width is unchanged (height-only / no-op resize bursts), backfilling never-rendered finalized messages once.
  • Adds benchmarks for conversation, streaming refresh, token-batch ingestion, delta accumulation, paintCanvas, and clampLines — the repo previously had none.
  • Fix from adversarial review: jumpToAgentStep now invalidates the step/message caches it mutates.

Measured (M2 Pro)

path before after
conversation(), 800 msgs steady-state 14.3 ms 8.1 µs
refresh() streaming, 201 msgs 5.2 ms 0.57 ms

Verification

  • 3 adversarial reviewers on the branch diff; one MEDIUM stale-cache finding fixed pre-PR
  • make fmt / make vet / make lint (0 issues) / go test -race -count=1 ./... all green

…as probes

conversation() now reuses the joined convPrefix (and its cached line
count) when the finalized-message count is unchanged, instead of
re-reading every block and re-joining per refresh — the hot path for
the ~12 Hz render flush while a turn streams. Per-block invalidation
drops the joined prefix too, since it embeds the changed block.

paintCanvas caches its SGR probe colors per theme; theme switch
invalidates. resize skips the glamour renderer rebuild and full
transcript re-render when the wrap width is unchanged (height-only and
no-op resizes during window-drag bursts), backfilling never-rendered
finalized messages once.

Adds benchmarks for conversation, streaming refresh, token-batch
ingestion, delta accumulation, paintCanvas, and clampLines to anchor
future perf work.
@jkyberneees
jkyberneees merged commit cf188d8 into main Oct 3, 2026
8 checks passed
@jkyberneees
jkyberneees deleted the perf/tui-hot-paths branch October 3, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant