Skip to content

[APP-5825] Bypass layout cache for editor text - #15831

Open
warp-agent-staging[bot] wants to merge 8 commits into
masterfrom
factory/app-5825-uncached-rte-text-layout
Open

[APP-5825] Bypass layout cache for editor text#15831
warp-agent-staging[bot] wants to merge 8 commits into
masterfrom
factory/app-5825-uncached-rte-text-layout

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Description

The rich-text editor now lays out modified document text directly through TextLayoutSystem instead of populating a LayoutCache that is discarded after each parallel pass. RenderState already retains the resulting BlockItem frames and only lays out changed blocks, so those per-pass cache entries could not produce later hits.

The uncached WarpUI API preserves leading-BOM removal and fallback-font requests. Placeholder lines whose frames are owned by render elements continue to use the persistent Presenter cache; the generic WarpUI Presenter cache remains unchanged.

Linked Issue

APP-5825

  • The linked issue is labeled ready-to-spec or ready-to-implement. — This work is tracked in Linear rather than a GitHub issue.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes). — This internal layout performance change is verified by benchmarks and automated tests; no visual change is expected.

Testing

  • cargo nextest run --manifest-path /workspace/warp/Cargo.toml -p warp_editor — 501/501 passed on Linux.
  • cargo nextest run -p warp_editor — 502/502 passed on macOS 26.3.1 arm64 at b5a760903871146b29831e690e393aca1407b590.
  • cargo nextest run -p warp_editor -E 'test(=render::model::offset_map::tests::test_end_to_end)' — 1/1 passed on macOS using native text frames.
  • cargo nextest run --manifest-path /workspace/warp/Cargo.toml -p warpui_core — 329 passed, 7 skipped.
  • cargo clippy --manifest-path /workspace/warp/Cargo.toml -p warp_editor --all-targets -- -D warnings — passed.
  • cargo clippy --manifest-path /workspace/warp/Cargo.toml -p warpui_core --all-targets -- -D warnings — passed.
  • cargo check --manifest-path /workspace/warp/Cargo.toml -p warp_editor --bench text_layout_bench and cargo check --manifest-path /workspace/warp/Cargo.toml -p warpui_core — passed.
  • cargo bench --manifest-path /workspace/warp/Cargo.toml -p warp_editor --bench text_layout_bench -- --quick — Linux test-backend smoke passed.
  • cargo fmt --manifest-path /workspace/warp/Cargo.toml --package warp_editor --package warpui_core and git diff --check — passed.
  • Required CI for final head 3af13a57e2af46a9c9745c65426b0054a43a79cc: run 33968691027 (in progress with no failures at the time of this update).

Benchmark

Native CoreText

The benchmark sends 4,096 unique, long blocks through EditDelta::layout_delta. Each block includes Latin ligature sequences, Arabic and Hebrew bidirectional runs, combining marks, Devanagari, Thai, and emoji/joiner sequences. It loads Menlo through warpui::platform::mac::FontDB, while App::test supplies only the ancillary AppContext; the measured text layout system is native CoreText.

The benchmark initializes Rayon’s global pool at exactly six threads before App::test, failing if any earlier use contaminated that setup. The 4,096 non-empty tasks flow through production’s bounded chunks of up to 64 tasks / 64 KiB and each chunk uses into_par_iter(). Each backend performs one full untimed layout_delta before Criterion starts, warming Rayon workers and shaping/font state. The same pool is reused without reset because every parallel iterator drains before returning and Rayon retains no per-layout cache.

The published cached baseline commit 93ad14348c3c838e6058792ecce5f74faf289573 on factory/app-5825-coretext-cached-baseline contains the exact workload, Rayon setup, warm-up call, and Criterion configuration while creating one fresh LayoutCache per invocation. The uncached run used b5a760903871146b29831e690e393aca1407b590. A normalized source comparison is identical after removing only the cache import, construction, and constructor arguments.

Both commits ran sequentially in the same clean checkout on macOS 26.3.1 arm64, Apple M4 Pro (Virtual), repo-pinned Rust 1.92.0, with 20 samples, a 2-second warm-up, and a 5-second requested measurement period. RAYON_NUM_THREADS was unset because the benchmark fixes the pool at six threads.

  • Cached: cargo bench --quiet -p warp_editor --bench text_layout_bench -- 'editor_text_layout/core_text/layout_delta_4096_shaping_blocks_6_threads' --save-baseline cached-shaping
  • Uncached: cargo bench --quiet -p warp_editor --bench text_layout_bench -- 'editor_text_layout/core_text/layout_delta_4096_shaping_blocks_6_threads' --baseline cached-shaping
  • Cached mean: 285.260 ms (95% CI 283.733–287.024 ms); 4.911 Melem/s (95% CI 4.881–4.937).
  • Uncached mean: 278.749 ms (95% CI 277.959–279.528 ms); 5.025 Melem/s (95% CI 5.011–5.040).
  • Criterion measured 2.282% lower time (95% CI 1.691–2.943% lower) and 2.336% higher throughput (95% CI 1.720–3.032% higher), p = 0.00 < 0.05 (rounded display value).

Test-backend microbenchmark

The editor_text_layout/test_backend/layout_delta_4096_shaping_blocks_6_threads group exercises the same parallel task/chunking and shaping-heavy input with WarpUI’s test font backend. Its Linux smoke run measured 1.493–1.564 ms and 903.50–946.51 Melem/s; the native CoreText comparison above is the production-representative measurement.

  • I have manually tested my changes locally with ./script/run. — The requester explicitly scoped verification to benchmarks and automated tests; this change has no UI behavior change.

Agent Mode

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

CHANGELOG-NONE

Benchmark a stable 4,096-block EditDelta layout workload so cache contention changes can be measured on the same machine.\n\nCo-Authored-By: Warp Agent <agent@warp.dev>
Route rich-text editor layout directly through TextLayoutSystem while preserving BOM stripping and fallback font requests. Remove throwaway caches from document, placeholder, and ordered-list layout paths.\n\nCo-Authored-By: Warp Agent <agent@warp.dev>
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

Comment @warp-staging-factory on this PR to send it follow-up work.

View run View conversation View on Slack

Exercise missing-glyph fallback registration through layout_text_uncached, matching the document and ordered-list-number path.\n\nCo-Authored-By: Warp Agent <agent@warp.dev>
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review September 5, 2026 06:25
Comment thread crates/editor/benches/text_layout_bench.rs Outdated
Comment thread crates/editor/benches/text_layout_bench.rs
Comment thread crates/editor/benches/text_layout_bench.rs Outdated
Comment thread crates/editor/src/render/element/header.rs Outdated
Comment thread crates/editor/src/render/element/placeholder.rs Outdated
Comment thread crates/warpui_core/src/fonts/text_layout_system_tests.rs Outdated
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.

1 participant