Skip to content

perf(rendering): reshape the keyboard overlay only when its text changes (2.8x faster) - #2525

Merged
richiemcilroy merged 3 commits into
CapSoftware:mainfrom
notkainoa:perf/keyboard-overlay-shape-cache
Oct 20, 2026
Merged

richiemcilroy merged 3 commits into
CapSoftware:mainfrom
notkainoa:perf/keyboard-overlay-shape-cache

Conversation

@notkainoa

@notkainoa notkainoa commented Oct 13, 2026 •

Copy link
Copy Markdown

The keyboard overlay is 2.8x cheaper per frame. It rebuilt and reshaped its text on every frame while keys were showing, even though the text only changes when a new key appears. Now it keeps the shaped text and reshapes only when it changes.

Before After Speedup
p50 19.1 µs 6.8 µs 2.8x
mean 19.5 µs 8.1 µs 2.4x
p95 (a new key appears) 26.5 µs 18.2 µs 1.5x

Runs on every frame of GPUI editor playback and export when the keyboard overlay is on.

What changed

  • The shaped buffer is kept, and rebuilt only when the visible text, font size, wrap width, font or weight changes.
  • The text color moved from the shaping attributes to the text area's default_color, which glyphon already uses for glyphs without their own color. Fades no longer force a reshape, and the pixels are the same.

Output is unchanged

Benchmark setup

KeyboardLayer::prepare at 1920×1080: 3 typed commands at 60 fps. One warmup pass, then 3 measured passes pooled (466 visible frames per pass, 1,398 total). Each number is the median of 3 runs. Apple M1, release build, opt-level 3. "Before" is the same benchmark on main (3d19c5c).

CARGO_PROFILE_RELEASE_OPT_LEVEL=3 cargo test -p cap-rendering --release --lib benchmark_keyboard_layer_prepare -- --ignored --nocapture

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issue was found.

Summary

KeyboardLayer now keeps shaped text until the text, font size, wrap width, family, or weight changes.

  • The keyboard overlay reuses shaped text between key and font changes.

The checkout lacked the previous review commit and a shared merge base. Review therefore covered the full endpoint diff.

Reviews (2) · Last reviewed commit: "test(rendering): check the keyboard layo..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread crates/rendering/src/layers/keyboard.rs
@notkainoa
notkainoa force-pushed the perf/keyboard-overlay-shape-cache branch from 2d71108 to 32eb6ca Compare October 14, 2026 19:34
@richiemcilroy

Copy link
Copy Markdown
Member

@greptileai review

@richiemcilroy
richiemcilroy merged commit b544adf into CapSoftware:main Oct 20, 2026
44 of 46 checks passed
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.

2 participants