Skip to content

[1/4] TUI: add retained transcript performance benchmarks - #14575

Merged
kevinyang372 merged 1 commit into
masterfrom
oz/tui-transcript-benchmark
Jul 31, 2026
Merged

[1/4] TUI: add retained transcript performance benchmarks#14575
kevinyang372 merged 1 commit into
masterfrom
oz/tui-transcript-benchmark

Conversation

@kevinyang372

Copy link
Copy Markdown
Member

Description

Stack 1 of 4. Adds a retained Criterion benchmark for long Warp Agent CLI transcripts using the real App, TuiPresenter, terminal block list, viewport state, and TuiAIBlock.

This PR intentionally changes no runtime rendering behavior. Later stack layers use this benchmark to isolate bounded painting, retained-frame overhead, and streaming height reconciliation.

Baseline at 120×50:

  • Many completed blocks remain flat from 100 to 10,000 blocks: 64–66 µs/frame.
  • Retained 1,000-row rich response: 2.30 ms/frame.
  • Retained 10,000-row rich response: 24.5 ms/frame.
  • Invalidated 10,000-row rich response: 25.7 ms/frame.
  • Retained 10,000-row streaming tail at end: 33.9 ms/frame.
  • Dirty 10,000-row streaming tail below a fixed viewport: 10.9 ms/frame.

Stack: 1/4oz/tui-bounded-viewport-paintoz/tui-retained-frame-overheadoz/tui-streaming-height-reconciliation.

Agent conversation: https://staging.warp.dev/conversation/2b6af7be-b227-4b20-aaf4-23c9a8494b81
Stack plan: https://staging.warp.dev/drive/notebook/yM2YcQsILFsFzwixBDbD9p
Performance plan: https://staging.warp.dev/drive/notebook/LHzsFd1B8XbQ8AnUqB88LS

Linked Issue

N/A — performance benchmark foundation.

Testing

  • cargo nextest run -p warp_tui — 902 passed.

  • cargo clippy -p warp_tui --all-targets --features test-util -- -D warnings

  • cargo bench -p warp_tui --features test-util --bench transcript_bench

  • ./script/format

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-NONE

@oz-for-oss

oz-for-oss Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@kevinyang372

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@harryalbert harryalbert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds a Criterion benchmark target for retained Warp TUI transcript rendering, along with test-util-gated benchmark support fixtures that exercise real App/TuiPresenter/TuiAIBlock/block-list paths. It does not change runtime rendering behavior.

Concerns

  • No blocking correctness, security, or spec-alignment concerns found in the annotated diff.
  • spec_context.md reports that no approved or repository spec context was found, so there were no concrete spec commitments to validate against.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

kevinyang372 commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@kevinyang372
kevinyang372 marked this pull request as draft July 31, 2026 15:01
@kevinyang372
kevinyang372 marked this pull request as ready for review July 31, 2026 15:20
@kevinyang372
kevinyang372 merged commit d5b1e69 into master Jul 31, 2026
49 checks passed
@kevinyang372
kevinyang372 deleted the oz/tui-transcript-benchmark branch July 31, 2026 15:20
@oz-for-oss

oz-for-oss Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@kevinyang372

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds Criterion benchmarks and test-only fixture support for measuring retained TUI transcript rendering scenarios. The benchmark fixture is generally scoped to dev/test-only code, and I did not find security issues. No approved spec context was available for implementation-drift checks.

Concerns

  • The retained benchmark path currently calls present() without first putting TuiPresenter into its no-op invalidated frame state, so TuiPresenter::present takes the direct-render fallback for the root view rather than the cached last_element path. That makes the retained baseline measure a different path than the benchmark name and PR description claim.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

}

/// Paints one frame from retained view elements and returns a cheap checksum.
pub fn present(&mut self) -> u64 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] TuiPresenter::present only reuses last_element when invalidate() ran for the frame; calling this directly leaves invalidated_this_frame false and takes the direct root-render fallback, so the retained_* benchmark cases rebuild BenchmarkTranscriptView instead of measuring the retained root path. Add a retained-frame method that runs a no-op WindowInvalidation::default() before present(), while keeping invalidate_all() for the invalidated cases.

kevinyang372 added a commit that referenced this pull request Jul 31, 2026
## Description
Stack 2 of 4. Removes the full-height scratch buffer from `TuiClipped`
and paints children directly through a nested, buffer-enforced clip.
`TuiText` supplies the logical row offset to ratatui so only the visible
paragraph window is painted.

The clip is enforced for cell, style, and widget writes; it is not only
scene/hit-test metadata. Regression coverage includes nested clipping,
translated rows, negative bounds, cursor visibility, and a retained long
child that must not overwrite simulated input/footer rows.

Benchmark at 120×50 versus stack PR 1:
- Many completed blocks, 10,000: 64.0 → 29.1 µs/frame (55% faster).
- Retained rich response, 1,000 rows: 2.30 → 0.925 ms (60% faster).
- Retained rich response, 10,000 rows: 24.5 → 8.56 ms (65% faster).
- Invalidated rich response, 10,000 rows: 25.7 → 9.38 ms (63% faster).
- Retained streaming tail at end, 10,000 rows: 33.9 → 17.2 ms (49%
faster).

Stack: #14575 ← **2/4** → `oz/tui-retained-frame-overhead` →
`oz/tui-streaming-height-reconciliation`.

Agent conversation:
https://staging.warp.dev/conversation/2b6af7be-b227-4b20-aaf4-23c9a8494b81
Stack plan:
https://staging.warp.dev/drive/notebook/yM2YcQsILFsFzwixBDbD9p
Performance plan:
https://staging.warp.dev/drive/notebook/LHzsFd1B8XbQ8AnUqB88LS

## Linked Issue
N/A — Warp Agent CLI transcript rendering performance.

## Testing
- `cargo nextest run -p warpui_core --features tui` — 555 passed, 7
skipped.
- `cargo nextest run -p warp_tui` — 902 passed.
- Strict Clippy passed for `warpui_core --features tui` and `warp_tui
--features test-util`.
- `cargo bench -p warp_tui --features test-util --bench
transcript_bench`
- `./script/format`
- Signed-in 120×40 tmux PTY: zero state and unsent input repainted
correctly.

- [x] I have manually tested my changes locally with `./script/run-tui`

## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-IMPROVEMENT: Improved scrolling and typing performance for
long Warp Agent CLI transcripts.
kevinyang372 added a commit that referenced this pull request Jul 31, 2026
## Description
Stack 3 of 4. Reuses `TuiText` natural measurements when retained
content is laid out again at the same width, and avoids copying a
viewport selection snapshot when there is no active selection and
line-end trimming is disabled.

This layer targets steady-state frame overhead after stack PR 2 has
already bounded paint work. Width changes still recompute text
measurement, and selection snapshots remain enabled whenever selection
or trimmed line-end behavior needs them.

Benchmark at 120×50 versus stack PR 2:
- Retained rich response, 1,000 rows: 0.925 → 0.129 ms (86% faster).
- Retained rich response, 10,000 rows: 8.56 → 0.598 ms (93% faster).
- Retained middle frame, 10,000 rows: 8.41 → 0.395 ms (95% faster).
- Retained streaming tail at end, 10,000 rows: 17.2 → 9.88 ms (42%
faster).
- Invalidated rich response, 10,000 rows: 9.38 → 9.85 ms (~5% slower).
- Many completed blocks, 10,000: 29.2 → 31.6 µs/frame (~8% slower, still
flat with history depth).

The next stack layer removes the remaining repeated streaming-height
work and owns auto-scroll reconciliation.

Stack: #14575#14582 ← **3/4** →
`oz/tui-streaming-height-reconciliation`.

Agent conversation:
https://staging.warp.dev/conversation/2b6af7be-b227-4b20-aaf4-23c9a8494b81
Stack plan:
https://staging.warp.dev/drive/notebook/yM2YcQsILFsFzwixBDbD9p
Performance plan:
https://staging.warp.dev/drive/notebook/LHzsFd1B8XbQ8AnUqB88LS

## Linked Issue
N/A — Warp Agent CLI retained-frame performance.

## Testing
- `cargo nextest run -p warpui_core --features tui` — 555 passed, 7
skipped.
- `cargo nextest run -p warp_tui` — 902 passed.
- Strict Clippy passed for `warpui_core --features tui` and `warp_tui
--features test-util`.
- `cargo bench -p warp_tui --features test-util --bench
transcript_bench`
- `./script/format`
- Signed-in 120×40 tmux PTY: zero state and unsent input repainted
correctly.

- [x] I have manually tested my changes locally with `./script/run-tui`

## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-NONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants