victory-gpu: keep heap buffer refresh spans disjoint and guard nested wide jobs #630
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/Belobug--VIctory-Belobug-AMD!630
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-630"
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?
@zaixiakongyiji on GitHub · 2026-11-27 15:13 UTC · original
zaixiakongyiji:pr/heap-disjoint-refresh-spans→a-publier· +1164 −218 · 3 files · 1 commits · openProblem
draw.rs,host.rs):HeapRanges/BufferSweep/heap_buffer_passflattened all descriptor-heap buffer views targeting the sameShadowinto one(min, max)envelope, andhost.rs(front_spans, Port 6ListFront,written_spans,Batch::add,watch::ask_once,stale_under_flights) re-flattened per-copy ranges to(min, max)as well.Shadowworker contention & nestedwide_eachre-entrant self-deadlock (host.rs,shadow.rs):Shadowproduces multiple disjoint refresh spans, dispatching flat spans acrosswide_each/wide_runlets multiple workers contend onShadow::copied, and ifShadow::copy_stale(while holdingself.copied) enterstake_all -> wide_each(>= 1 MiB dirty run),wide_eachpops another outer job fromWORKERS.jobson the same thread and deadlocks trying to re-lockself.copied.Changes
crates/victory-gpu/src/draw.rs:Shadow(MERGE_GAP_BYTES = 256 KiB,MAX_INTERVALS_PER_COPY = 16merging smallest adjacent gaps first) inHeapRanges/BufferSweep.slots: HashSet<u32>insideShadowIntervalsso dead-Shadoweviction (Arc::strong_count == 1) removes and rescans only itskslots inO(copies + k)instead of scanning the full heap.crates/victory-gpu/src/host.rs:256 KiB(4 * 64 KiBguard/write-watch pages) disjoint sub-intervals acrossstale_under_flights,watch::ask_once,front_spans, Renderer Port #6'sListFront(fold_touches,join_keys,join_fronts),written_spans,Batch::add/flush_one, and exact (gap = 0)Batch::aheadcoverage.Shadow(group_spans_by_shadow) before parallel dispatch inBatch::refresh_front(both default andVICTORY_PORT_GUARD=1paths),Batch::refresh_ahead, andBatch::flush_allso each worker processes a distinctShadow.crates/victory-gpu/src/shadow.rs:IN_WIDE+ RAIIWideDepthGuardinworkers(),wide(), andwide_each()so nestedwide/wide_eachcalls execute inline without stealing outer jobs fromWORKERS.jobs.Verification
cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p victory-gpu --locked&cargo test -p victory-gpu --features diagnostics --locked: 451 + 1 passed, 0 failed (6 unit tests covering 174 MiB hole exclusion,O(k)dead-copy slot eviction, Port #6fold_touches/join_keyshole preservation, exactBatch::aheadmiddle-hole coverage,group_spans_by_shadow, and nestedwide_eachunder a non-recursiveMutex).@gw1337x on GitHub · 2026-11-27 17:13 UTC · original
In-game numbers for
e1a3cf8on a card-bound scene. Memory Integrity was off.PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, Belobug launcher settings plus the 5 port switches, warm shader caches. #630 on
4eb6cfdvs4eb6cfd; the base runs were taken before and between the PR runs in the same session.The three submitting-thread rows are the median of every
preparing per frameline once the world is on screen (about 220 lines per run).What this shows here:
buffer views of the heap made readyline readsspans=5027 ... holes_mb=420andspans=4888 ... holes_mb=508(copies 4384 and 4203).Not tested: the city scenes the description is about. I don't have a save there, so I can't say whether the saving on wide envelopes outweighs this cost in them.
View 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.