perf(renderer): throttle instead of skip occluded-surface frame generation - #265
Merged
Conversation
Supersedes the reverted occluded-render skip (c25020f99, PR that caused CI hangs via ghostty_surface_read_text on the permanently-occluded virtual display). Throttles updateFrame to 4Hz while occluded instead of skipping it outright, preserving ~95%+ of the CPU win while keeping the scrollbar dirty/clear handshake and other updateFrame-gated state machines making forward progress. See docs/ghostty-fork.md section 8 for the full rationale.
Downloaded and verified the release asset published by Build GhosttyKit for PR #265: sha256 8794693b5b06fa6702a61be57442ced102b7ea8955fba97397c72ecb668d970d.
4 tasks
3 tasks
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
Replaces the reverted occluded-surface
updateFrameskip with a throttle. Hidden panes (background agent tabs, unfocused splits) still get almost all of the CPU savings, but they no longer freeze state that only progresses insideupdateFrame.This supersedes the earlier skip approach (
c25020f99), which shipped a real CPU win but caused two production-visible regressions in CI, where every surface is permanently occluded on the virtual display:.scrollbarmailbox path (already fixed separately, app-side, and unrelated to this change)ghostty_surface_read_textlocksrenderer_state.mutexand depends onupdateFramemaking progress — the hard skip left the scrollbar dirty/clear handshake with no live half (scrollbar_dirtyis set inupdateFramebut only cleared indrawFrame, which is also gated off while invisible)Both issues are fixed or avoided by this throttle, and the CPU win is preserved at ~95%+.
Summary
ghosttysubmodule bumped to08bac45e9on the fork branchperf/occluded-update-frame-throttle(based onc25020f99).renderCallbackinsrc/renderer/Thread.zignow callsupdateFrameon every wakeup while visible (unchanged from upstream), and at most once per 250ms (4Hz) while occluded, tracked via a monotonicstd.time.Instanttimestamp onThread(mirrors the existing bell-ring throttle pattern inSurface.zig).nullon the visible→occluded transition so the first occluded update fires immediately rather than waiting a full interval.markDirty()on the occluded→visible transition indrainMailboxis unchanged from the original skip implementation.docs/ghostty-fork.mdsection 8 rewritten for the throttle, with the merge-conflict note about upstream's secondupdateFramecaller (renderNow) retained and updated to point at the throttle instead of a hard skip.Merge gate
This is a probabilistic failure mode (CI hangs on the permanently-occluded virtual display), so the fork branch should not merge to fork
mainuntil 3 consecutive green CI runs on this PR.Test Plan
zig build -Demit-xcframework=true -Dxcframework-target=universal -Doptimize=ReleaseFastinghostty/exits 0xcodebuild -project GhosttyTabs.xcodeproj -scheme programa -configuration Debug -destination 'platform=macOS'succeeds against the new framework