Skip to content

perf: stop idle focused terminals from waking on every screen refresh - #430

Merged
arzafran merged 3 commits into
mainfrom
perf/park-idle-display-link
Oct 15, 2026
Merged

arzafran merged 3 commits into
mainfrom
perf/park-idle-display-link

Conversation

@arzafran

@arzafran arzafran commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

What this does

A focused terminal with nothing new to show now uses about half as much CPU. Ghostty used to wake up on every screen refresh while a terminal was focused, even when there was nothing to draw. It now stops after a quarter second of quiet and starts again on the next change. Typing and output look the same.

Summary

  • Bumps ghostty to 617aac442 on the fork branch idle-park-display-link: the change itself, plus a commit that takes draw_mutex for the idle-timer resets because drawFrame can run off the render thread.
  • drawFrame notes each display link tick with nothing to draw and stops the CVDisplayLink after 250ms of them. Thread.drawFrame now calls resumeVsync, which restarts a parked link when the surface is visible and focused, so a change still draws on the next vsync instead of without one.
  • 250ms was picked from a bench: restarting a parked link added about 4ms to that one draw, so the window outlasts the gap between keystrokes (typing at 150-200ms gaps kept the link running for 70 of 71 keys) and stays under the 600ms cursor blink.
  • docs/ghostty-fork.md gets patch group 12. A follow-up commit pins the GhosttyKit checksum once this PR's Build GhosttyKit run publishes the framework.

Bench (Release build, one window, one terminal, 30s ps CPU deltas, bench kept frontmost the whole time):

Focused, visible, quiet prompt with blinking cursor CPU
Before 1.60%
After 0.83%, 0.76%

Test Plan

  • CI is green, including tests-build-and-lag (typing latency).
  • Build GhosttyKit publishes xcframework-617aac44206e6a88761e4b3a253547e07b8870df, and its checksum is pinned in scripts/ghosttykit-checksums.txt.
  • In the built app, type in a focused terminal, then leave it idle for a few seconds and type again: the first key after idle echoes without a visible delay.
  • Run a command that streams output (yes | head -50000) and confirm it scrolls smoothly.

Bump ghostty to 2076a6134, which parks a focused terminal's display link
after 250ms with nothing to draw and restarts it on the next change.
@arzafran
arzafran merged commit 6d8e41b into main Oct 15, 2026
26 checks passed
@arzafran
arzafran deleted the perf/park-idle-display-link branch October 15, 2026 20:50
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