Repository navigation
perf: stop idle focused terminals from waking on every screen refresh - #430
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ghosttyto617aac442on the fork branchidle-park-display-link: the change itself, plus a commit that takesdraw_mutexfor the idle-timer resets becausedrawFramecan run off the render thread.drawFramenotes each display link tick with nothing to draw and stops the CVDisplayLink after 250ms of them.Thread.drawFramenow callsresumeVsync, 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.docs/ghostty-fork.mdgets 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
psCPU deltas, bench kept frontmost the whole time):Test Plan
tests-build-and-lag(typing latency).xcframework-617aac44206e6a88761e4b3a253547e07b8870df, and its checksum is pinned inscripts/ghosttykit-checksums.txt.yes | head -50000) and confirm it scrolls smoothly.