Repository navigation
perf(project): move completed keys into keyboard overlay groups - #3197
Merged
richiemcilroy merged 1 commit intoOct 25, 2026
Merged
richiemcilroy merged 1 commit into
richiemcilroy merged 1 commit into
Conversation
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
group_key_eventsclones every completed group's key vector, including each key's owned String, then clears the working vector. The GPUI editor calls this throughgenerate_project_keyboard_segmentswhen building keyboard overlays; legacy keyboard synchronization uses it too.Move the key entries into an exactly sized output vector with
Vec::append, retaining the working vector's allocation for the next group. This removes the deep key-text copies without repeatedly growing a fresh working vector. Group text handling, grouping decisions, modifier state, timestamps, IDs, and APIs are unchanged. The production change is three call-site substitutions and one small private helper.Measurements
Baseline
f510acfa1against this branch. Linux x86_64 container, AMD EPYC 9V74, two-CPU quota, process pinned to CPU 0, Rust 1.88.0; repository release profile (opt-level=s, thin LTO, one codegen unit).Five alternating independent processes per version, 25 samples per fixture after three warmups; table shows medians of process p50s. Positive reduction means faster. Fixtures model ten keys/second, typing
helloseparated by spaces; the shortcut variant presses/releases Meta periodically. Ten fixture sizes/modes were measured, from 100 to 36,000 keys.The 36,000-key fixture represents about one hour and 72,000 captured events (75,600 with shortcuts). The complete
generate_project_keyboard_segmentsAPI measurement includes warm event-file reads, binary decoding, projection, and grouping. It excludes recording metadata loading, app dispatch, rendering, and output destruction. No native UI/FPS claim is made. The 1,000-key plain-typing generation control is 1.6% slower; small whole-path changes should not be overstated.Every process serialized all grouped/generated tracks. All ten fixtures and both APIs match the baseline byte-for-byte across all runs (aggregate SHA256
df803d338e6e50f1ccabe2f095dfe96160de20f9657cfacb9c751cd407cd0ebd). In the one-hour plain-typing fixture, 6,000 completed words each contain five key strings, so this avoids 30,000 deep string copies while preserving output sizes and the scratch vector's capacity.Correctness and checks
A new normal test covers group completion on a nearby space, a distant space, a new key after a pause, and a modifier. It pins the completed group's full serialized contents, key offsets and times after subsequent reuse, and verifies the source events are unchanged. Existing modifier, special-key, backspace, projection, binary compatibility, and timing tests pass.
cargo fmt --allandcargo fmt --all --checkcargo check -p cap-project --lockedcargo test -p cap-project --locked: 179 library tests and 4 integration tests passed; 4 existing benchmarks ignored.cargo clippy -p cap-project --all-targets --locked -- -D warningsgit diff --checkReproduction
Use this branch's benchmark source on both revisions. It increases warmups/samples and selects the appropriate p95 sample for the larger sample count; the comparison above uses p50.
Save baseline/head binaries separately, alternate five processes each, compare the output files, and take medians of the p50 columns. The existing
--check-scalingoption remains available. Raw samples/outputs are kept outside the production repository.Risk is limited to ownership during group completion.
Vec::appendempties the accumulator and transfers the original owned entries; later clearing/reuse cannot modify completed groups. No cache, concurrency, or public data layout changes. This is separate from the merged modifier-scan/indexing optimizations and the pending key-symbol/keycap UI changes.Publication validation: rebased onto
ec15b9840; 183 scoped tests passed, plus formatting, check, and strict all-target Clippy. Benchmarks above were recorded before this rebase; the production paths changed by this PR remain as measured.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Moves completed groups’ keys instead of cloning their strings, while keeping the working vector’s allocation.
Reviews (1) · Last reviewed commit: "perf(project): move completed keyboard k..." · Reviewed by Greptile