fix(victory-gpu): track exact upload block spans and move zeroing/alloc outside ARENAS lock #451
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!451
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-451"
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?
@Lewandox on GitHub · 2026-11-26 20:08 UTC · original
Lewandox:fix/victory-gpu-upload-block-bounds-and-lock→main· +165 −33 · 1 files · 2 commits · openSummary
Fixes two issues in
victory-gpu/src/upload.rs(used bylist::allocate_uploadandmemory::named_in_uploadfor ray-tracing top-level structure builds):Exact allocation boundaries in
upload::block(address)(fixes cross-list bleed / over-scan):Arenastored onlytaken: Vec<bool>, soupload::block(address)counted all consecutivetrueblocks starting at(address - arena.at) / BLOCK.memory::named_in_uploadscanned across unrelated command lists' upload buffers (risking concurrent data races with other recording threads and wasting CPU scanning up to 4 MiB instead of the caller's own block). And whenaddressfell inside a later block of a multi-block allocation,block()returned a truncated tail instead of the allocation's true start.(first, count)(Slot::FREEwhen free), soupload::block(address)returns the exact(start, len)of the owning allocation in O(1).Reduced
ARENASmutex contention and unnecessaryMEM_WRITE_WATCHdirtying inUpload::new(len):Arena::freeto skip full arenas in O(1).write_byteszeroing of reused blocks outside the globalARENASlock.VirtualAlloc2(reserve) andshadow::registeroutside theARENASlock (eliminating lock nesting withshadow's global table and stalls on parallel recording threads).write_bytes(0)on freshlyVirtualAlloc2(MEM_COMMIT)arenas (Windows guarantees zero-initialized pages), avoiding prematurely dirtying untouched pages inMEM_WRITE_WATCH.Verification
cargo test -p victory-gpu --lib upload::tests(default and--features diagnostics)upload::tests::block_returns_exact_allocation_bounds_without_bleeding_into_neighborsverifies adjacent allocations, multi-block queries from non-zero offsets, and clean release.@mauroalvare on GitHub · 2026-11-27 01:13 UTC · original
Independent Windows x64 release verification at
ef0113b6585249f8e5fbe7652f9319d7dfa42ba7and parent37d4686711bbb04c2cc3825f3f13bbff7c140fb0.upload::testspassed at the head, both with default features and with--features diagnostics.block_returns_exact_allocation_bounds_without_bleeding_into_neighborstest copied over, the first assertion returned 256 KiB for a 64 KiB allocation.Reproduce the cold case by appending this test to
third_party/victory/crates/victory-gpu/src/upload.rson each revision and running the command in a fresh process for each sample.Sharing a pending arena reservation among simultaneous misses would retain the exact-span fix while limiting committed memory growth. Builder frame timings would need a fixture that exercises
memory::named_in_upload.@Lewandox on GitHub · 2026-11-27 01:28 UTC · original
Great catch — thank you for the independent release verification and the cold-start repro!
Pushed a follow-up commit adding a dedicated slow-path
ARENA_GROWmutex with a double-checkedARENASre-probe before callingreserve():ARENA_GROWand still zero outsideARENAS.VirtualAlloc2andshadow::registerstay outsideARENAS, while simultaneous cold-start misses now serialize growth and share one 4 MiB arena.upload::tests::cold_parallel_uploads_share_a_single_arena(fresh subprocess, 16 concurrent threads on a barrier, assertingARENAS.len() == 1); all 4upload::testspass locally (4 passed, 0 failed).@mauroalvare on GitHub · 2026-11-27 01:56 UTC · original
Retested the follow-up
c9aadb7684e86f2f8e3afb4258d3a701027cce8bon Windows x64, Rust 1.98.1, release.upload::testspassed with the default features and with--features diagnostics.ef0113bbuild used 8–16 arenas. This reproduces the correction with the original workload.The last command uses the test in my earlier comment and was run eight times in fresh processes.
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.