Repository navigation
perf(native): stop building what a shut frame never shows - #924
Merged
Merged
Conversation
A session card built its whole right-click menu every frame it was closed, and every dialog in the window built its title, description, buttons and widget closures every frame while shut. A busy session's spinner also asked for an immediate redraw, so the whole window repainted at the display's rate for a 22px ring. ContextMenuLazy builds its entries only while the menu is open, the two cards that carry a large menu use it, and each dialog layout leaves the frame when it is shut and done fading (DialogState.Animating keeps the close transition whole). The spinner asks for its next frame 33ms out. Measured on the sidebar card menu: 105 allocations and 12KB per card per frame become none while the menu is closed.
The plugin install gate was the one dialog still built every frame while shut. The patch notes dialog reads its open state once, after its buttons, and the CHANGELOG entry drops a redraw estimate that held only at 60Hz.
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.
Three per-frame costs a native window pays while nothing about them is on screen.
A card's right-click menu.
cardMenuand the review file card's menu were built every frame for a card that was drawn every frame, menu open or not: 105 allocations and 12KB per card per frame (BenchmarkReviewCardFixedWidthcovers the same menu shape at 5.4µs/105 allocs).ui.ContextMenuLazyholds the entries as a closure and builds them only while the menu is open, on the same frame the press opens it.TestContextMenuLazyBuildsOnlyWhileOpenpins both halves: nothing built while closed, one build and a working item when opened.A busy session's spinner.
statusGlyphasked for an immediate redraw, so a window whose only motion was a 22px ring repainted at the display's rate. It now asks for its next frame 33ms out (30fps). Output still draws as it arrives; the ring is the only frame source this rate applies to.Every dialog, shut. Each of the window's dialogs built its title, description, buttons and widget closures every frame, then asked
DialogStyle.Layoutto return early because it was closed. Each layout now leaves the frame when its dialog is shut and done fading.DialogState.Animatingreports the close transition, so a dialog dismissed now still fades instead of vanishing, and the frame that takes a click still asks for the next one (theframeRig"no next frame" tests cover that path).Left out: virtualizing the sidebar list. The cards live inside
ui.Sortable.List, which measures every id each frame for drag-and-drop geometry, so culling them needs a height cache and spacer items of its own. Separate PR.Gate:
gofmt -l .,go vet ./...,go test ./...fromnative/(libghostty fromnative/GHOSTTY_COMMIT). Backend untouched.