Skip to content

perf(render): reduce per-frame allocations in panel and pointer hot paths#165

Open
peters wants to merge 4 commits intomainfrom
perf/reduce-hot-path-allocations
Open

perf(render): reduce per-frame allocations in panel and pointer hot paths#165
peters wants to merge 4 commits intomainfrom
perf/reduce-hot-path-allocations

Conversation

@peters
Copy link
Copy Markdown
Owner

@peters peters commented Apr 15, 2026

Summary

  • defer per-panel Vec<Event> cloning in handle_terminal_pointer_input until cheap pointer-hit checks show the panel actually needs pointer processing
  • reuse scratch vectors for panel render order and workspace accents, and compute panel display titles and workspace labels lazily to avoid per-frame String cloning
  • reduce terminal cell text allocation churn by fast-pathing single codepoints and only preallocating when zero-width glyphs are present
  • trim Horizon's direct Tokio feature list to rt and macros; transitive dependencies still provide the IO and network features used by the update paths
  • split HorizonApp::new bootstrap setup into a helper after merging main, keeping the constructor within clippy limits without changing behavior

Review follow-up

  • merged the latest main into this branch to resolve the PR conflict
  • dropped the earlier release-profile panic = "abort" change

Test plan

  • cargo fmt --all -- --check
  • ./scripts/check-maintainability.sh
  • RUSTFLAGS="-D warnings" cargo test --workspace
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo clippy --workspace --lib --bins --examples -- -D warnings -D clippy::unwrap_used -D clippy::expect_used
  • cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic

…aths

Defer the Vec<Event> clone in handle_terminal_pointer_input past the
early-exit check so panels not under the pointer skip the clone entirely.

Remove title and display_title String fields from PanelSnapshot — the
display title is now computed inline via Cow (often zero-alloc), and the
panel title is fetched lazily only during the rare rename interaction.

Replace the per-frame Vec<(WorkspaceId, String, Color32)> with a
reusable Vec<(WorkspaceId, Color32)> field; workspace names are looked
up lazily inside the context-menu callback which only runs when the menu
is open.

Store panel_render_order as a reusable field to avoid a Vec allocation
every frame.

Trim tokio to features = ["rt", "macros"] (transitive deps supply the
rest) and add panic = "abort" to the release profile.
Copy link
Copy Markdown
Owner Author

@peters peters left a comment

Choose a reason for hiding this comment

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

Left one inline comment on the release-profile change.

Comment thread Cargo.toml Outdated
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