Skip to content

perf(project): resolve hidden cursor windows without allocation - #3437

Open
OptimistOtaku wants to merge 2 commits into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-cursor-visibility-windows
Open

OptimistOtaku wants to merge 2 commits into
CapSoftware:mainfrom
OptimistOtaku:codex/perf-cursor-visibility-windows

Conversation

@OptimistOtaku

@OptimistOtaku OptimistOtaku commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Playback and export call cursor_visibility_at for every frame. When a project contains hidden-cursor clips, it constructs and drops a vector of every hidden run just to select the run containing that frame.

Merge runs while retaining the first matching window and the total clip duration, using fixed stack storage. The complete traversal remains necessary for fades at the timeline's end. Fullscreen-hold mapping, transition arithmetic, adjacent-run merging, exclusive end boundaries, and fade calculations retain their previous behavior. The small no-hidden-clips entry path is kept separate from the heavier implementation.

Measurements

Windows x86_64, Ryzen 5 5600H, Rust 1.88 GNU, repository release profile (opt-level=s, thin LTO). Nine alternating paired samples after warmups, each with 10,000 varying frame times. The ignored benchmark compares the exact previous functions with production code and checks complete float-bit equivalence before timing.

Clips Hidden clips Transitions Holds Before (ns) After (ns) Speedup
2 None No No 3.33 3.07 1.08×
2 All No No 58.01 17.94 3.23×
2 Mixed No No 69.65 20.46 3.40×
2 Mixed Yes No 75.80 25.36 2.99×
2 Mixed Yes Yes 141.38 94.25 1.50×
20 None No No 9.82 15.37 0.64×
20 All No No 128.95 83.50 1.54×
20 Mixed No No 196.30 88.34 2.22×
20 Mixed Yes No 305.81 203.31 1.50×
20 Mixed Yes Yes 530.48 434.08 1.22×
200 None No No 90.84 108.05 0.84×
200 All No No 892.96 790.40 1.13×
200 Mixed No No 1,176.43 848.08 1.39×
200 Mixed Yes No 3,116.00 2,863.57 1.09×
200 Mixed Yes Yes 5,931.31 5,729.84 1.04×
1,000 None No No 568.59 616.30 0.92×
1,000 All No No 5,378.99 4,777.59 1.13×
1,000 Mixed No No 5,660.08 4,880.92 1.16×
1,000 Mixed Yes No 21,384.78 20,603.92 1.04×
1,000 Mixed Yes Yes 40,407.80 42,132.87 0.96×

The benefit is concentrated in hidden-clip projects without large transition/hold workloads. No-hidden controls cost approximately 6–48 ns more in the larger fixtures; the 1,000-clip transition/hold control was about 4% slower. A second complete run retained the hidden-clip gains and that largest control's regression. Hold-window allocation and full clip traversal remain. These measure cursor visibility CPU work, excluding GPU rendering and overall FPS.

cargo test --locked -p cap-project --release --lib benchmark_cursor_visibility -- --ignored --nocapture

Validation

  • cargo fmt --all, cargo check --locked -p cap-project
  • cargo test --locked -p cap-project --lib --tests: 286 library tests and four integration tests passed after rebasing; seven benchmarks ignored by default. The cursor benchmark measurements above are from the original PR run.
  • cargo clippy --locked -p cap-project --all-targets -- -D warnings
  • git diff --check

Differential tests cover every hidden/visible pattern through six clips, fractional speeds, transitions, overlapping fullscreen holds, exact fade/window boundaries and neighboring representable timestamps, empty timelines, degenerate clips, and non-finite inputs. No dependencies, platform-specific code, persistent caches, or project-format changes. The native GPUI app was not launched locally. This branch is independent of #3436. Rebased onto main 6fbbaa577; the conflict resolution retains main's marker exports alongside the cursor test module. An existing shape-test field assignment was moved into its initializer to pass all-target Clippy without changing test behavior.

RetriggerView in GreptileConfidence Score: 5/5

The rebased PR appears safe to merge, with no actionable issues found.

Summary

Removes the hidden-run vector from cursor_visibility_at while keeping the previous window selection and fade calculations.

  • Cursor visibility finds the matching hidden run without building a list.
  • The shape test sets its infinite width when it builds the shape.

No actionable issues found. Build and test results were inspected as reported, not rerun.

Reviews (2) · Last reviewed commit: "test(project): initialize non-finite str..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings October 26, 2026 21:41
@vercel

vercel Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks for this. The win is tens of nanoseconds per frame against a multi-millisecond frame budget, and several rows in your own table get slower (no-hidden 20/200/1000 clips, 1000 clips with holds), so it isn't worth the extra code in cursor_visibility_at.

Copy link
Copy Markdown
Contributor Author

Thanks Richie, that's fair. I put too much weight on the relative microbenchmark gains here. Removing the allocation still leaves the full clip traversal and hold mapping, and the regressions in the no-hidden and large hold cases weaken the case further.

I agree the absolute savings don't justify the added complexity in this per-frame path. I'll take that into the next contribution: profile a meaningful bottleneck first, then check the absolute savings and common-case controls before proposing the change.

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks! Can you rebase on main to clear the conflicts? Then we'll take a look.

@OptimistOtaku
OptimistOtaku force-pushed the codex/perf-cursor-visibility-windows branch from b6eabbf to 1f12a8c Compare November 4, 2026 22:00

Copy link
Copy Markdown
Contributor Author

Rebased onto main (6fbbaa577); GitHub now reports no conflicts. The resolution retains the marker exports added on main and this PR's cursor tests. Formatting, cargo check, 286 library tests, four integration tests and all-target Clippy pass locally. I also fixed an inherited shape-test initializer that Clippy flagged after the rebase. Fresh CI is running.

@greptileai please review the rebased head, 1f12a8c5229a5f6b9377b4d461d8588801106563, so the review reflects the current commit.

This branch has not been deployed

No deployments
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.

3 participants