victory-gpu: coalesce and parallelize descriptor::sync_heaps #1293
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1293
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1293"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Vladimir-Human on GitHub · 2026-11-26 11:59 UTC · original
Vladimir-Human:perf/parallel-coalesced-sync-heaps→main· +1181 −258 · 2 files · 1 commits · openSummary
Optimizes
descriptor::sync_heaps(crates/victory-gpu/src/descriptor.rs&crates/victory-gpu/src/descriptor/host.rs):read_into+ unmapped-page fallback (descriptor.rs): Merges touching/overlapping dirty[from, to)ranges without bridging clean gaps (coalesce_ranges) and splits runs intowatch::PAGE-aligned128 KiBchunks (chunk_ranges). Reads each chunk with a singleread_intocall, falling back to per-watch::PAGEread_intoacross the chunk on failure so valid neighbour blocks still mirror.descriptor.rs+descriptor/host.rs):HostHeap::copiedto lock-freeOnceLock<Vec<AtomicU64>>fingerprints (copied_slots) and passes snapshot[u32; 3]words (record_words) intomirror_inner.HostHeap::madeacrossKEPT_PIECES(64) mutexes matchingHostHeap::kept, droppingindex's shard before unmaking stale placed-texture slots viaSpans::note_keyed+HostHeap::unmake_if_key.slot_flags:FLAG_TEXTURE,FLAG_PLACED,FLAG_BUFFER,FLAG_KEPT) maintained inside their respective subsystem locks so unrelated descriptor writes (e.g. constant buffer views) skip empty subsystem mutexes.mirror_copied_sliceandVICTORY_HEAP_SYNC_PAGE=0mirror_copied) with per-shardmade_direct_epochcounters so a pre-copied snapshot never reverts a concurrent directHostHeap::mirror.crate::shadow::wide_runwhile preserving allVICTORY_HEAP_SYNC*toggles (=0,_CUT,_PAGE=0,_BESIDE,_TABLES) andSYNC_PARTS/SYNCEDwall-time telemetry.Verification
git diff --check origin/main,git merge-tree --write-tree origin/main HEAD, neutral-naming scan (0hits)cargo run -p xtask -- policy(220 files ok)cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated(default &--all-features:0warnings)VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu -- --test-threads=1(220 passed; 0 failed; 6 ignored — includes parity, mid-chunk unmapped-page fallback, chunk boundary/unchanged-slot skip,keep_views()mip-update stale unmake, requeuedFLAG_TEXTUREeviction, and concurrent direct-mirror clobber guard tests)VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics -- --test-threads=1(239 passed; 0 failed; 7 ignored)cargo test --release -p victory-gpu --lib sync_heaps_coalesced_parallel_benchmark -- --nocapture(14,400dirty slots x10iters):64 KiBserial):2.504 ms/iter(8 reads/iter,parts=[take=0.014, read=0.038, walk=0.108, make=2.320])128 KiB):1.805 ms/iter(4 reads/iter,parts=[take=0.016, read=0.020, walk=0.089, make=1.677])@Garu667 on GitHub · 2026-11-26 12:04 UTC · original
Happy to A/B this on the RTX 3080 like #1279 (where your guard work gave 9.1 → 10.0 fps). It conflicts with current
main(ceb9e1f) indescriptor/host.rs:mainreworkedmirrorsince (made_now/heap_locks()fast path,keep_views/same_placed_texture,MIRROR_*timing), and yourmirror_innerrewrites the same body, so I'd rather not guess the merge. If you rebase it, I'll run it the same day against the same baseline.@KainanP on GitHub · 2026-11-26 13:08 UTC · original
Independent A/B of this PR and the other two open
sync_heapsPRs (#1202, #1220), each against its own merge base, using one black-box benchmark. All three conflict with currentmain, so each PR head is compared with the commit it branched from.Benchmark.
descriptor::tests::sync_heaps_benchon KainanP/victory-fork@bench/sync-heaps, added unchanged to every tree. It only usescreate_heap,create_cbv/create_srv/create_uav,sync_heaps,SYNCEDandSYNC_PARTS.sync_heapscall is timed.mainceb9e1f06702fe4fe062c32b31f7a8f9c9dVICTORY_HEAP_SYNC_PARALLEL=1006c35318e9683VICTORY_HEAP_SYNC_ZERO_RUNS=1Results.
What this does not show.
@MKmajster, @CuteBooty (#1083): your profile had
descriptor::sync_heapsat 21–26 ms per frame. If you can, please run this PR and compare its by-part line ("the pass over the title's view heap by part") and the frame time with its base.AI use: Claude Code (Claude Opus 5.5) wrote the benchmark, built and ran the seven trees, and wrote this comment.
🤖 Generated with Claude Code
@CuteBooty on GitHub · 2026-11-26 13:40 UTC · original
Thanks for the benchmark. One correction to the mention: the 21-26 ms for
descriptor::sync_heapswas MKmajster's profile, not mine. My tree (CuteBooty/victory-8gb) does not havesync_heaps; it compares descriptor records in its own heap pass, about 240,000 records a frame at an estimated few milliseconds, so I cannot give a like-for-like number for this PR from it.If a run of the fork's own code on an RTX 3070 8 GB with a Ryzen 5 3600 would still help, I can do one, but it would be the fork's build, not mine, and it would take me a little while to set up.
4fe062c062to8f3d81ef66@Vladimir-Human on GitHub · 2026-11-26 13:56 UTC · original
@KainanP Thank you for running that 7-tree benchmark — seeing
1.42 msvs5.96 ms(4.2× faster, with identical401,408looked-at /9,298mirrored counts) is great confirmation of the coalesced reads and parallel walk/make pipeline.@Garu667 Cleanly rebased onto current
main(a20809d, includingceb9e1f) as8f3d81e, preserving all ofceb9e1f's changes alongside this PR:made_now/heap_locks()lock-free fast path (both pre-copied and direct paths inmirror_inner)keep_views()/same_placed_texturemip-refinement retention (withSpans::keysstale-span unmake intact)MIRROR_*diagnostics telemetry (MIRROR_HOWTLS per worker inmirror_copied_slice, all outcome counters inmirror_inner,MIRROR_US[0..3]acrossnote_buffer_key+stale_to_unmake, view creation, andkeep, and thesync_linebreakdown)Re-verified post-rebase:
cargo run --locked -p xtask -- policy:220 files okcargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated(default &--all-features): cleanVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu -- --test-threads=1:220 passed, 0 failed(default) and239 passed, 0 failed(--features diagnostics), 0 D3D12 debug errorscargo test --release -p victory-gpu --lib sync_heaps_coalesced_parallel_benchmark -- --nocapture:2.035 ms/iter(4 reads/iter) vs2.494 ms/iter(8 reads/iter) baselineReady for A/B testing against
ceb9e1f/ currentmain!8f3d81ef66tod12f002929View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.