Repository navigation
perf(gpui): resolve complex shape overlays in one pass with A/B benchmarks - #3945
himanshu748 wants to merge 11 commits into
Conversation
|
@himanshu748 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb24d25528
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Both review findings are addressed in commit
Could you please review the latest head @codex review Note: Several unrelated CI checks have been failing at dependency download/setup with HTTP 504 errors rather than a code/test failure. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
CI investigation for the latest head I checked the first attempt's Intel job log: it failed in Could someone with access to the Intel runner's attempt-2 logs/annotations check the final output for job |
Summary
The native GPUI Studio editor resolves visible shape stacking on every redraw and pointer move. Previously, each overlay shape track rescanned every shape segment to collect its active shapes, while resolving the overlay stacking order used repeated
Vec::containsmembership checks. This makes the work quadratic as a project gains tracks.This PR makes that hot path scale with the number of shapes and tracks:
EditorWindow::visible_shape_orderthrough the shared project implementation, affecting frame redraw and pointer hit-testing without changing scene semantics.Why this is a meaningful optimization
Before: active shape ordering rescans
Nshapes for each ofTshape tracks,O(N × T); resolving the stack isO(T²).After: active shape ordering performs one
O(N)scan, plusO(T)bucket setup/flattening; saved stack membership checks areO(T)expected. Shape-track counts of 16 or fewer, and scenes with at most 32,768 shape-track comparisons, retain the direct-scan path.The implementation keeps the output indices byte-for-byte equivalent to the old ordering, including per-track source order and reverse-of-stack paint order.
Native Rust measurements, including review regression cases (November 8, 2026)
Environment: isolated Vercel Linux x86-64 sandbox, 4 vCPUs, 8 GB RAM, Rust 1.95.0, release-optimized
cap-project. The checked-in benchmark compares the original and optimized Rust algorithms in the same executable, asserts identical indices, and alternates nine A/B timing rounds. The figures below are medians from seven independent benchmark processes on the reviewed implementation.At 256 tracks, all seven process-level speedups were between 7.64× and 8.03×. The 1, 8, 9, 12, 16, and 17-track cases are explicit regression checks following the Greptile/Codex reviews. The revised dispatch preserves the original direct scans for up to 16 shape tracks or up to 32,768 shape-track comparisons; larger scenes use grouped traversal.
Validation
cargo +1.95.0 test --release --locked -p cap-project --lib: 293 passed, 0 failed, 7 ignored.cargo +1.95.0 fmt --all -- --check: passed.Reproduce the benchmark
The benchmark prints JSON rows with
baseline_p50_us,optimized_p50_usandspeedup, with nine interleaved timing samples per case and a correctness assertion before timing.This targets an independent GPUI code path and intentionally does not overlap the separate GPUI renderer/scene patch work in #3886/#3887.
AI assistance disclosure: Code changes and the benchmark harness were developed with AI assistance. The performance figures above come from actual compiled native Rust A/B runs, not model estimates; correctness was verified with tests.


Confidence Score: 5/5
The PR appears safe to merge; no blocking issues were found.Summary
The PR shares shape ordering between GPUI and the project code, uses membership sets for large overlay stacks, and groups active shapes in one pass for larger scenes.
Reviews (6) · Last reviewed commit: "perf(gpui): protect sparse shape timelin..." · Reviewed by Greptile