Skip to content

perf: Reduce redundant cursor geometry calculations - #442

Open
itradesize wants to merge 1 commit into
vinzdg:mainfrom
itradesize:perf/cursor-geometry-upstream-main
Open

itradesize wants to merge 1 commit into
vinzdg:mainfrom
itradesize:perf/cursor-geometry-upstream-main

Conversation

@itradesize

Copy link
Copy Markdown

Summary

Reduce unnecessary CPU usage during mouse movement by reusing cursor geometry calculations within each mouse event.

Runtime profiling identified repeated geometry and model calculations in cursor callbacks as a major source of CPU activity, particularly in multi-display configurations.

This optimization is independent of PR #431.

Changes

  • Introduce reusable cursor geometry evaluation.
  • Reuse calculated hit regions, wing geometry, cell spacing, and interactive regions within each cursor callback.
  • Refresh geometry when synchronous model updates can affect layout or positioning.
  • Preserve existing hover detection, tooltip interactions, expansion, and folding behavior.
  • Add focused regression tests for geometry equivalence and state transitions.

No mouse-event throttling, artificial delays, or animation quality reductions were introduced.

Performance observations

Observed on an Apple Silicon MacBook Pro with four displays.

Build Stationary CPU Mouse movement CPU
Original Debug 6–8% 30–43%
Release before optimization ~3.6% 16–19%
Optimized Release 2.4–5% ≤7.5%

These are informal Activity Monitor observations during normal usage, not controlled benchmarks.

The Debug-to-Release improvement comes from compiler optimization and is not attributed to this PR.

The relevant comparison for this source change is between the two Release builds.

Test Plan

  • Run test suite (make test-ci)
  • Tested on macOS (Apple Silicon, macOS 27.0.1)
  • UI / Notch interactions verified during normal use

Additional validation:

  • Optimized Release build compiled successfully using Swift -O and whole-module optimization.
  • Application launched and operated correctly across four displays.
  • Static code review and git diff --check passed.
  • Focused geometry regression tests were added but have not been executed.

Automated tests were intentionally not run during final preparation.

Screenshots / Screen Recordings

No visual UI changes.

The optimization preserves existing notch appearance and interactions while reducing redundant CPU work.

@itradesize
itradesize requested a review from vinzdg as a code owner October 9, 2026 17:35
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.

1 participant