perf(gpu): batch list counters and use stack arrays in barrier/targets #511
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/lobomfz--VIctory-xmem!511
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-511"
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?
@Not4Eric on GitHub · 2026-12-04 20:24 UTC · original
Not4Eric:perf/list-batch-counters-stack-arrays→main· +129 −23 · 2 files · 1 commits · merged 2026-12-05 17:30 UTCWhat this does
Cuts per-call heap allocations, lock traffic, and atomic contention during command-list recording and thin-list translation:
VALUE_WAITS(and itsreset()mutex lock) behind#[cfg(not(windows))]since Windows builds never push to it.Vecheap allocations inlist::barrier(small stack array[Barrier; 16]withVecoverflow, short-circuiting thebuf_uavcheck) andlist::state::targets([u64; 8]/ borrowed slice).CountBatchsolist::thin::Recording::runbatchesDRAWS,DISPATCHES,TOTALS, andthin::STATSincrements per translated chunk/run instead of hitting global atomics on every draw/dispatch.give_backon an emptyVecinlist/thin.rs.Checks
crates/victory-gpu/src/list.rsandcrates/victory-gpu/src/list/thin.rs.list::unit tests pass; no prior behavioural bug existed for a failing-before unit test.ListFront) and #408 (enhanced barriers).cargo xtask policypassed (360 files ok); no fork-only files, configs, or build outputs.Verified
cargo xtask policy—360 files okPROFILE=diag PKG=victory-gpu ./build.sh check— 0 warningsPKG=victory-gpu ./build.sh test --lib -- list:: --test-threads=1(Proton Wine on Linux, RX 9070 XT) —5 passed; 0 failed, 0 warningsCost
None (reduces heap allocations and cross-core atomic traffic on
victory-list-*threads; 0 new warnings).AI-assisted: yes
@Kal0s-design on GitHub · 2026-12-04 21:36 UTC · original
Checked
8bcb343on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). I tested the PR head as it is against mainb581f7e, and it also merges cleanly onto main.list::passes 5/5 on both sides, plain and with--features diagnostics+VICTORY_D3D12_DEBUG=1, on the card and on WARP. The full lib run matches main. The only failures are the ones already failing natively on main (the twoindirect::tests::host_list_*and the twopipeline::hostlibrary loads) plus the flaky watch test. Clippy shows no new warnings with or without diagnostics, and the diagnostics build compiles.I also ran a throwaway test (not pushed) on both sides with the debug layer, card and WARP. It captures the slice that goes to
ResourceBarrier.barrier()calls with 0 to 40 entries, with dropped entries mixed in and with or without a buffer transition (which adds the trailing UAV). Same order as expected on both sides, including 16, 17 and the spill caused by the trailing UAV, with no debug layer errors.take_counts()is (3000, 1000) every round, the barrier slices match, and thin STATS read 12186 calls and 3 lists on both sides.On the four points
wait_forundercfg(not(windows))(main list.rs:2261), and Windows goes tocut(). The only other use is theretaininreset(main list.rs:699). Nothing pushes or reads it on Windows, so gating both is fine. I couldn't build a non-Windows target here.Barrieris a plainCopystruct holding borrowed raw pointers, so there's no refcount involved. The array starts filled withUAV_BARRIERand onlystack[..len]is read, so there are no uninitialized reads. The spill copies the first 16 in order. One small thing is thatbuffer_bytesnow runs on every barrier instead of stopping at the first buffer, which is cheap. Instate::targets, the one-range path now caps at 8 handles where main didn't, which is fine for D3D12.set_targetsstill allocates its own Vecs per call (draw.rs:1404), so that call still allocates.Drop, so unwinding is covered too. That happens beforedoneis set, so whoever waits on the recording sees the counts. It's a const thread-local with no destructor, so nothing is pending at thread exit, and the totals match main. Thin STATS are now added whenrunruns out of chunks, afterdone, so they can slip into the next frame-rate line. That's cosmetic.VICTORY_BORROW_RECORDING, off by default (ca97da2), and became a hard false when the switches went (2773fdf). With it on, the back list has no host list after detach, and the next RESET takes one from the idle pool. I found no use-after-reuse. Streams always start with RESET,Recording::droponly callsclose, which is a no-op without a host, and a re-submit gets an empty closed list either way. One difference is that iffresh_list()fails, main just leaves that list out of the submission, while hereresetcallscrate::host::fail. Lists weren't run through a real queue, so it may be worth checking with the maintainer that flipping the old default is intended.AI-assisted: yes
perf(gpu): batch list counters, use stack arrays, and borrow thin recordingsto perf(gpu): batch list counters and use stack arrays in barrier/targets8bcb343e72to502f4219b5@Not4Eric on GitHub · 2026-12-05 00:00 UTC · original
Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this
Pushed updates addressing your review:
back.borrow_recording = trueback tofalseinlist/thin.rsto keep this PR purely performance-focused without changing the opt-in recording-borrow behaviour, and updated the PR title/description.buf_uavcheck insidelist::barrier().@Kal0s-design on GitHub · 2026-12-05 00:59 UTC · original
Re-checked
502f421on native Windows (didn't run the game).borrow_recording is back to false in list/thin.rs:323, so thin.rs matches main there and the fresh_list() failure path in reset (list.rs:717) is only reachable with the opt-in again, same as main. The buf_uav check at list.rs:848-853 now stops calling buffer_bytes once it's set. list:: passes 5/5, the full lib run shows only the four failures main already has natively plus the flaky watch test, clippy has nothing new with or without diagnostics, and it still merges cleanly onto current main. The 8-handle cap and the set_targets allocation were only side notes, fine as they are.
If you touch it again, rustfmt wants the
let host: &[Barrier] = if ...line at list.rs:863 split over several lines. It was already like that before the amend.AI-assisted: yes
github-bot referenced this pull request2026-12-05 02:15:02 +00:00
502f4219b5to8c2bd6443a