Repository navigation
Conversation
A focused vsync window currently keeps CVDisplayLink running at the display cadence. Idle frames still hop the render thread for a Metal no-op presentLastTarget. Start the link from updateFrame when cells_rebuilt or an animation wake is set, so Thread.drawFrame(false) still waits for vsync. Stop it after a draw that leaves nothing pending. Unfocused, occluded, and window-vsync=false are unchanged. Idle focused Time Profiler (t ≥ 5s): renderer plus CVDisplayLink went from 0.80% of one core on main to 0.13% on this branch (6.3×; 257 ms / 32 s vs 29 ms / 23 s).
Contributor
|
Looks good, made some changes and replaced it with this #14035 kept you as coauthor |
mitchellh
added a commit
that referenced
this pull request
Aug 26, 2026
#14033 Pause the CVDisplayLink when there isn't any real work to do. Start the link after updateFrame rebuilds cells, keep it running while cell changes or animations remain pending, and resync it from the no-redraw path to sleep it again. I also did some benchmark to measure the cost of starting/stopping the display link since this includes a lot more of that and I found that a continuously running link used 29 to 35 us of CPU per callback, while starting and stopping it for every frame used 103 to 121 us. So, in some pathological case this can be worse, but its still microseconds, and in the normal case this helps Ghostty sleep a lot more.
pull Bot
pushed a commit
to fucheng-guo-sun/ghostty
that referenced
this pull request
Aug 26, 2026
ghostty-org#14033 Pause the CVDisplayLink when there isn't any real work to do. Start the link after updateFrame rebuilds cells, keep it running while cell changes or animations remain pending, and resync it from the no-redraw path to sleep it again. I also did some benchmark to measure the cost of starting/stopping the display link since this includes a lot more of that and I found that a continuously running link used 29 to 35 us of CPU per callback, while starting and stopping it for every frame used 103 to 121 us. So, in some pathological case this can be worse, but its still microseconds, and in the normal case this helps Ghostty sleep a lot more. Co-authored-by: Jesse Miller <jmiller@jmiller.com>
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.
A focused vsync window currently keeps CVDisplayLink running at the display cadence. Idle frames still hop the render thread for a Metal no-op presentLastTarget.
Start the link from updateFrame when cells_rebuilt or an animation wake is set, so Thread.drawFrame(false) still waits for vsync. Stop it after a draw that leaves nothing pending. Unfocused, occluded, and window-vsync=false are unchanged.
Idle focused Time Profiler (t ≥ 5s): renderer plus CVDisplayLink went from 0.80% of one core on main to 0.13% on this branch (6.3×; 257 ms / 32 s vs 29 ms / 23 s).
This is from #14030 (comment), this looks like a clean win with minimal change for focused window efficiency.
AI - extensive use of grok 4.6 and some Claude in the experiments, this small change was all human after the research.