Repository navigation
core: the profiler counts GPU targets made per frame - #423
Merged
Merged
Conversation
The profiler timed fizzy's work and the backend's submit, but not what a frame asks the driver to allocate. A window-tall frost on Safari remade ~5 render targets a frame and ran at 66 fps while the profiler said 1.2 ms of work. Now each backend keeps running totals of textures made, targets made, both destroyed, and target switches; the profiler takes the difference each frame and shows it per frame, per history frame, and per hitch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
What changes
The profiler now counts what each frame asks the GPU to allocate, which no timed scope sees. The devtools frame line gains
textures N /f targets N /f switches N /f. A frame picked on the graph, and a held hitch, show their own counts ("made 6 targets"). Hitch chips say "made N" when their frame allocated anything.devtools.stats/core.profile.reportwrites.gpu = .{ … }on.frameand on each hitch.Why: dragging a window-tall float on Safari ran at ~66 fps, but the profiler showed 1.22 ms of work and 0.05 ms of submit. The cost was the frost recreating ~5 render targets a frame (fixed separately in #422), and on ANGLE/Metal that cost lands outside every scope.
How:
Health.Countsgainstextures/targets/destroyednext to its existingtarget_switches.SDLBackend.gpuTotals()returnsHealth.total.WebBackendkeeps the same four totals. A switch counts only when the target actually changes, as on native.core/profile/Gpu.zigis std-only: the counts, their wrapping difference, and a per-frame average.Entrypasses the backend's totals tohostFrameBegin, next tolast_submit_ns. The profiler assigns the difference to the last recorded frame, the same way it handles submit, so the counts cover that frame's submit too. It keeps them in the history, the window average (FrameStats.gpu), and the hitch (Lookback.noteGpu).profile.abi4→5 andLookback.abi1→2. A plugin built against the old layout records nothing until it is rebuilt, which is the existing guard.SDK impact
test-sdk-versionpasses; fingerprint unchanged)Verified
zig build,zig build test(91/91 steps),zig build test-integration(53/53 steps,fizzy-profile-tests18/18),zig build test-sdk-version. New unit tests cover counts across a wrap, a frame's counts landing in its own slot and the window average (and not before the profiler records), and a hitch keeping its late counts but no other frame's.zig build check-web, plus a live run (zig build web,?worker=0) in the desktop browser pane, Chromium, at 120 fps:textures 0.0 /f targets 0.0 /f switches 0.0 /f.targets 0.3 /fover 61 frames (~20 targets). A JS wrapper ongl.createTexture/createFramebuffercounted 30 of each over the same stretch.targets 0.0 /f, withswitches 13.0 /f(the frost's passes).Follow-ups
🤖 Generated with Claude Code