victory-gpu: batch heap sync and loose Execute slots #127
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/vktory6--VKtory!127
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-127"
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?
@olafix52 on GitHub · 2026-12-01 16:50 UTC · original
olafix52:perf/heap-sync-batch→main· +269 −180 · 4 files · 3 commits · merged 2026-12-01 17:03 UTCTargets
docs/TASKS.mditem "The serial frame chain" (title:heap-sync).Problem
On placed shader-visible heaps,
sync_heaps(crates/victory-gpu/src/descriptor/sync.rs) spent ~6.9 ms/frame on average in its"making"phase:spread::each_viewpass after page comparison, scanning a combinedVec<u32>on everyvictory-recordsworker thread.index % 256), running atomicfetch_or/fetch_andRMWs, updating shared global atomics (SENT,LOOSE_READS) on every slot (~91k slots/frame), and building unused[u8; 20]payloads +GATHEREDTLS vectors (record.rs).MEMORYevents beforeExecute, then re-sorting even when indices are already strictly monotonic.Changes
HostHeap::mirror/sync_heaps(descriptor.rs,descriptor/sent.rs): only slots holdingVIEW_TAGare sent, a previously sent slot that loses its view is sent once more to null it, and concurrent updates betweendescriptor::mirror(SentSlots::send) andsync_heaps(SentSlots::send_batch) preserve last-read ordering under the slot's stripe lock.SentSlotsblock striping &send_batch(crates/victory-gpu/src/descriptor/sent.rs):STRIPE_SHIFT = 10,STRIPES = 256). Because 1,024 is a multiple of 64, eachu64word insentbelongs exclusively to one stripe lock, allowingnoteto useload(Relaxed)+ conditionalstore(Relaxed)without atomic RMWs.SentSlots::send_batchto lock once per contiguous block run, reserve one contiguousLOOSE_READSsequence range while holding the stripe lock, and accumulate localSENTcounters before flushing once at the end.sync_heaps(crates/victory-gpu/src/descriptor/sync.rs):spread::each_viewpasses into one, runningsink.send_batchdirectly while each chunk's changed slots are warm in cache, then appending chunks toLOOSEunder a single lock viarecord::extend_loose.crates/victory-gpu/src/record.rs,greenfield/vkback/src/live/liststage.rs):[u8; 20]stack formatting outsideOPEN.depth > 0and removedGATHEREDTLS (loose_together); unified 20-byte slot encoding intoappend_slot.latest_by_handle+ per-slotMEMORYemission withpack_loose(adds an O(n) no-sort fast path when handles are strictly increasing) emitting a singleSLOTSevent beforeExecute, matchingDecoder::eventinliststage.rswithself.pending.reserve(payload.len() / 20).Measurement (interleaved A/B/B/A, RX 9070 XT,
5ad3422vs candidate, standard0..140 swindow,VKB_LAT+frames.py --no-perf)5ad3422)heap-sync-batch)heap-sync-batch)5ad3422)title:heap-sync(>33.3 ms)sync_heapstotal (log.txt)making(log.txt)Verification
-D warnings):cargo xwin clippy --workspace --all-targets --all-features --target x86_64-pc-windows-msvc --locked -- -D warnings: pass (verified after rebase onto3465541).cargo xwin clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings: pass (verified withoutdiagnosticsafter#119).victory-shader,victory-formats,victory-core,xtask) andgreenfield: pass.cargo xtask policy: 521 files OK.vkback --lib(155 passed, 3 ignored) andvkback --test policy(6 passed).victory-gpuunit tests under Wine (descriptor::sent::tests,record::loose_tests,descriptor::copied::changed_records_tests): 6/6 passed.loud.txt/ERROR rule32on all four runs — zero new errors (only existing known items already tracked indocs/TASKS.md).Vec::reserveinliststage.rs; Vulkan API calls and emitted SPIR-V are unchanged.@vktory6 on GitHub · 2026-12-01 17:03 UTC · original
Merged as
63a18bf, thanks! The A/B/B/A table is very convincing: half ofsync_heapsgone, -46 % time over 33.3 ms.What I checked:
send, so the latest read still wins across the title's thread and the sync.pack_looseonly skips the sort for strictly increasing handles.SLOTSevent exactly like the old 20-byteMEMORYevents (both go topendingfor the Execute).I pushed one commit before merging: the sync line printed four counters that were never filled (
SYNCEDslots 4-6 andSYNCED_KINDS; already dead on main, your change made it visible). They're gone, andSYNCEDkeeps the foursync_heapsfills.