Repository navigation
fix(gpu): sync shader-visible heaps holding the heap lock one page at a time - #199
Merged
pragyaangaur merged 2 commits intoNov 26, 2026
Merged
Conversation
… a time sync_heaps runs before every submission (29 a frame in the world) and held SHADER_HEAPS across every written page of every heap, some 350,000 slots a frame, while title threads writing views (mirror) wait on the same lock. The written ranges are now taken in one short hold, then each page is made under its own hold, after checking that the heap is still listed: Heap::drop takes the lock to leave the list, so a listed heap is alive. Ranges are still taken only once a heap has its host heap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Reviewed and merging. The change takes the written ranges in one short hold and then makes each page under its own hold, checking that the heap is still listed first. That is sound, because Heap::drop takes the write lock to leave the list. This branch conflicted with main after the RwLock change in #169, so I merged main in and made the per-page holds read locks as well. Clippy on the Windows target and the native tests pass, and CI is green. |
This was referenced Nov 26, 2026
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
descriptor::sync_heapsruns before every submission and heldSHADER_HEAPSacross every written page of every shader-visible heap. Title threads writing views (descriptor::mirror) wait on the same lock.Now the written ranges are taken in one short hold. Each page is then made under its own hold, after checking under the lock that the heap is still listed.
Heap::droptakes the same lock to leave the list, so a heap that is still listed is still alive. As before, a heap's ranges are taken only once it has its host heap.Why
A diagnostics run in the world (Series S) showed
sync_heapschecking about 350,000 slots a frame, over 29 submissions, much more than the 1,300-14,400 the doc comment expects. Title threads waited about 106 ms a frame onSHADER_HEAPS(MirrorWaitUs). With the lock held across the whole sync, a title thread that wrote a view stalled for the entire sync.Measured
Apple M3 Pro, 36 GB, macOS 27, D3DMetal 4.0b3,
--console series-s,VICTORY_PATCH_MASKED=all VICTORY_FAULT_TRACKING=1. Diagnostics build, driven into the world withVICTORY_KEYS. The world lines are those with more than 800 draws per frame, about 28 per run:The summed
MirrorWaitUsbarely moves (106 → 103 ms). The gain comes from title threads no longer stalling for a whole sync at once.In a release build, preparing time per world frame fell from about 400 ms to about 100-300 ms in comparable scenes, and light-to-medium scenes went from about 1.6 to 1.8-3.5 fps. One release run stayed in the world for 1 h 35 min. It ended in the title's own crash handler after a 5.3 s frame, while I was running the GPU test suite on the same Mac at the same time, so I don't attribute that to this change.
Caveat: these runs were measured on a local branch that also carries #148, #152 and three upstream VIctory commits (#1865, #2054, #2147). The before/after rows differ only in this change.
Tests
cargo test --workspace: 472 passed, 0 failedWINEDLLOVERRIDES="d3d12,d3d12core,dxgi=b" tools/macos/test-wine.sh --workspace --no-fail-fast: 874 passed, 0 failed, 12 ignoredcargo clippy -p victory-gpu --all-targets -- -D warnings(gnullvm target): cleanrecords_copied_as_bytes_are_made_at_the_next_synctest covers the sync behaviourNo game data, offsets or file names here.
AI-assisted (Claude Code). The runs above were run on my Mac.
🤖 Generated with Claude Code