Repository navigation
Diagnostics: heap-sync counters and run-hash shader labels (buffer-release change reverted) - #3
Open
CocoBeans64 wants to merge 5 commits into
Open
CocoBeans64 wants to merge 5 commits into
CocoBeans64 wants to merge 5 commits into
Conversation
A profile of the prologue's world (xperf, context switches and ready events) shows the title's recording threads and the submission thread (queue::pump -> Host::execute) taking turns: the submission thread runs alone at ~100 % of a core for ~400 ms a frame while everything else waits, so it is the frame's critical path. 17 % of its time was the driver freeing the memory of host copies gone (memory::Shared::rewrite dropping the old page table's last references -> ID3D12Resource release -> amdxc64). - `Shadow::buffer` is released by a thread of its own (`release_later`). A copy goes only once no submission holds it, and D3D12 objects are free-threaded. - `shadow::BUFFERS` becomes a read-write lock: `find` looks buffers up shared and writes only to make a first copy. The title's five recording threads woke each other ~2,400 times a second on the mutex (no gain of its own, measured). Bench (Series X, FSR 0.5, BVH builder skipped, 300 s of the prologue on an RX 6800 XT / Ryzen 7 7800X3D, Windows 10 + Agility SDK): mean frame 647 ms against 705-759 ms over four reference runs, 1.69 fps mean (1.41-1.56). victory-gpu shadow tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Counters per frame-rate line for `sync_heaps`, to find what its time goes to: - "heap syncs per frame": syncs, mapped pages, slots looked at, slots stale, time reading/comparing records and time making the stale ones. - "stale slots per frame": made null, first made, the same view again (by content), another view; by kind. - "made null per frame": zeroed records, old generations, anything else; time making null slots and views. Each call takes under a microsecond, so this split reads low (truncated to whole us). - "unknown records per frame": records neither zero nor ours: how many repeat their bytes, become ours or zero when read again, look like a GPU address; their most frequent first dwords and a few samples. In the prologue's world (Series X, FSR 0.5) a frame syncs ~19 times and looks at ~590,000 slots, ~34,000 of them stale: 6.7 ms reading, ~36 ms making. ~21,000 of those are made null: ~9,200 zeroed records, ~12,200 "unknown" records that are the title's own data (floats such as 0x3f800000, index lists), which shares the big shader-visible heap's memory with descriptors in turn. Only ~0.5 % are the same view again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`run` names shaders by the blake3 of the container as the title passes it (its own size), e.g. in VICTORY_GPU_TIMING's "GPU ... ms/frame" lines; `translate --list` named them by file and offset only. Each program's label now starts with that hash (`h<16 hex digits>`), so a costly pipeline in a run can be found in the list (the two costliest compute pipelines of the prologue's world, 51.6 ms/frame, are XboxBvhBuilder.dll's). VICTORY_EMIT_ONLY (comma-separated label substrings) limits VICTORY_EMIT_DUMP to those programs, and dumped files keep the start of the label, where the hash is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CocoBeans64
force-pushed
the
perf-submission-thread
branch
from
November 25, 2026 23:29
0f101be to
2295330
Compare
📊 Same picture on another machine: the frame is CPU-bound, and FSR barely helpsThanks for the xperf breakdown. It matches what we just measured on avatarmanz/VIctory-7900XTX with FSR from Marvisak#1793 and frame generation (avatarmanz/VIctory-7900XTX#53):
RX 9070 XT, Ryzen 7 9800X3D, 32 GB, Series X profile, |
This reverts commit e837b60. On upstream 842b0cb the cost it moved is gone: a profile of the prologue's world (xperf, sampled stacks) shows memory::prepare / Shared::rewrite at 0.09 % of the process, against 17 % of the submission thread on the old base (13f91ca), most likely since Marvisak#1865 writes the page tables directly. A control run gave 799 ms/frame with the commit and 750 ms/frame without (one run each, noise ~5 %), so it adds a thread and a ManuallyDrop for nothing. 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.
Summary
Performance work on the prologue's world, toward a steadier frame rate (goal: 30 fps, even at reduced quality). It comes from one evening of measurements with a reproducible bench on Windows 10 (RX 6800 XT, Ryzen 7 7800X3D, Agility SDK, Series X profile, FSR at 0.5 scale from Marvisak#1793).
New targets on
842b0cb(sampled stacks, prologue's world): the submission thread is still the critical path, and it runs alone for ~380 ms a frame. It spends 29 % inShadow::writing, 15 % insync_heaps, 15 % inBatch::flushand 8.5 % incopy_mapped. The main recording thread spends 35 % inlist::allocate_uploadand 14 % on contended locks.Main finding: the frame is bound by the submission thread. A context-switch profile (xperf) shows two phases taking turns. First, the title's five recording threads record for ~300 ms. Then
queue::pump -> Host::executeruns alone at ~100 % of one core for ~400 ms while every other thread waits. Cutting work elsewhere (lock waits, heap syncs, resolution, the GPU) barely moved the frame time. Freeing that thread helped on the old base.Commits
memory::Shared::rewritedrops the old page table's last references, thenID3D12Resourcerelease, thenamdxc64.Shadow::bufferis now released on a thread of its own.shadow::BUFFERSalso becomes aRwLock, with a shared read path infind. It removes a lock convoy between the recording threads, but brought no measurable gain of its own.sync_heaps. They show that ~63 % of the slots made per frame are made null, and that ~12,000 slots a frame hold the title's own data (floats, index lists) rather than descriptors. The big shader-visible heap's memory is shared with other data.runlogs;VICTORY_EMIT_ONLY. This is how the two costliest GPU pipelines were identified: they are XboxBvhBuilder.dll's, 51.6 ms per frame, ~40 % of GPU command time.Measurements (300 s of the prologue's world, scripted camera loop)
VICTORY_SKIP_PIPELINES, image about the same)842b0cb(BVH skipped), without commit 1842b0cb(BVH skipped), with commit 1On the old base: −24 % per frame since the base. With the BVH builder skipped, the GPU drops from 214 to 135 ms per frame, but the frame shortens by only ~110 ms, because the submission thread is the bound.
What did not help (measured, for the record)
SHADER_HEAPSas aRwLock: title wait 250 → 100–135 ms, but sync time ×3; no gain.shadow::BUFFERSread-write lock on its own: within noise.Next targets on the submission thread
sync_heaps(19 % of its time): mostly null views made for the title's own data.Shadow::update/watch::take_split(22 % + 14 %): could run on more threads, since 13 cores sit idle.Test plan
cargo test -p victory-gpu shadow(8/8)cargo check -p victory-gpuwith and withoutdiagnostics;cargo check -p victory842b0cb: clippy (with and withoutdiagnostics) passes;cargo test --workspacegives 228 passed and 3 failed, and the same 3 fail on plain upstream on this machine (GPU tests: placed R32_UINT -> R9G9B9E5 view does not share its host texture (Windows 10, RX 7800 XT) Marvisak/VIctory#1999,compute_view_marks_rebind_after_depth_twin_conversion,depth_bounds_control_a_title_draw)cargo test --workspace(not run;draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_viewalready fails on this machine on plain upstream, GPU tests: placed R32_UINT -> R9G9B9E5 view does not share its host texture (Windows 10, RX 7800 XT) Marvisak/VIctory#1999)🤖 Generated with Claude Code