perf(gpu,shader): add opt-in raw CBV reads, sharded submit journal, and fine write guards #3455
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3455
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3455"
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?
@legayclightning22 on GitHub · 2026-11-27 03:10 UTC · original
legayclightning22:perf/renderer-ports-cbv-and-guards→main· +373 −9 · 8 files · 1 commits · openSummary
Adds opt-in raw constant-buffer reads (
VICTORY_PORT_CBV), sharded submit journaling (VICTORY_PORT_JOURNAL), and finer-grained write guards (VICTORY_PORT_GUARD) while keeping default behavior safe and preserving bounded root descriptor tables.Changes
ROOT_CBV_SPACE), sharded submit journal updates (SHARDS), and per-block write guards (GUARDS/BUSY) acrossvictory-gpuandvictory-shader.0/off by default) and bounded for low-memory configurations.Verification
cargo test --locked -p victory-gpu --libandcargo test --locked -p victory-shader --libcargo clippy --locked -p victory-gpu -p victory-shader --all-targets --all-features -- -D warningscargo xtask policy@oni-swr on GitHub · 2026-11-27 05:06 UTC · original
WARP test report (Windows, software adapter only; no GPU, no game files). AI-assisted, Claude.
--lockedVICTORY_WARP=1,VICTORY_D3D12_WARP=163bcca4(main). Head:0c72875(this PR, a fast-forward of main, no conflicts)--features diagnostics,--test-threads=1)VICTORY_PORT_CBV=1 VICTORY_PORT_JOURNAL=1 VICTORY_PORT_GUARD=1emit::synthetic_tests: lane permutes, gathers, a mask-at-uniform-loop case). They look WARP-related (wave size) and are not caused by this PR.port_journal::tests::without_the_switch_every_page_is_fresh, which fails only whenVICTORY_PORT_JOURNAL=1is in the environment. It is not hermetic:enable(false)can only force the flag on, soport_journal()still reads the env switch andclaimreturns[]instead of[8, 9]. A test-only override that can force the flag off (likeCONSTANTS_RAW_HERE: Option<bool>) would fix it.Notes from reading the diff:
VICTORY_PORT_GUARD=1alone changes nothing.port_guard()is only read inside theport_journal::on()branch ofretake, so the shared-lock path needs the journal as well.light()defaults to on, so with the journal on the shared lock is used even without the guard flag.VICTORY_PORT_CBV=1the shader reads the root CBV throughroot_srv_handle, and the shader-cache key is changed. I could not see the host-side root SRV binding in this diff. If it already exists elsewhere, ignore this. Otherwise the flag-on path has no test for it.port_cbv::raw_okandport_journal::shards_ofare only compiled for tests, so they cover code that is not used outside tests. Theclaimcomment about a "journal's lock" has no matching outer lock in the code.claim, a page is noted before its mark is done. A second thread claiming the same page in that window gets an empty list while the first thread has not yet marked it. This may be harmless, but I did not check it.MutextoRwLockchange onGUARDSis the only default-path change, and the suites above pass with it.Counts only; no game data.
@futurepro62 on GitHub · 2026-11-27 08:57 UTC · original
NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head
0c72875(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 874 passed, 0 failed, 10 ignored.raw_table_views_need_sixteen_bytes,ranges_name_their_parts,claims_are_per_shard_and_per_generation,without_the_switch_every_page_is_fresh,test_flags_are_thread_local,shared_guards_yield_to_a_writer,raw_root_cbv_needs_the_switch_and_a_root_descriptor,constants_raw_is_opt_in.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@KainanP on GitHub · 2026-11-27 12:40 UTC · original
Contention numbers for this PR from a shared benchmark (for #3425).
Method. The benchmark
guard_contentionand the checkrefreshes_under_writes_lose_nothingfrom #3516, split out as a standalone test-only commit (KainanP/VIctoryperf/guard-bench: no behaviour change,guards()only times a lock it finds taken in test builds), applied unchanged to this PR's head (0c72875) and tomain(63bcca4). 256 MB write-watched pool in 64 KiB pages, copies of 32 pages, 1,400 pages dirtied before each refresh, title threads writing a random word every 20 µs while the copies are taken and copied. Release builds, i7-14650HX (24 threads), Windows 11. 31 rounds, builds interleaved and rotated each round, each run = median of 5 refreshes after a warm-up; table = medians over the 31 runs, plus the median (and quartiles) of the per-round PR/main ratio. Foreign load: other agents'rustcjobs were running (≈8 % of the CPU in a spot sample); the paired ratio is what to read.GUARDS, msRun with
VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1(light refresh on, the default).Reading. No measurable change in any config (paired ratios 0.99–1.05). That's expected rather than a verdict on the PR: the shared lock is only taken in
retake, while the waits this bench measures are the write-fault handler andTracked::take, both of which still takeGUARDSexclusively (guards()→write()). If the fault handler's read-mostly part could run underread(), this bench would show it.Correctness.
refreshes_under_writes_lose_nothingpasses on this head (3 × 1,000 rounds), as do the existingwatch::tests. It doesn't callretake, so the shared-lock path itself isn't covered by it.AI use: Claude Code (Claude Opus 5.5).
0c728750c4toa4284695d0@legayclightning22 on GitHub · 2026-11-27 15:30 UTC · original
Thanks @oni-swr, @futurepro62, and @KainanP for the WARP, RTX 5070 Ti, and contention benchmark reports! Pushed
a428469making the thread-local flag overridesOption<bool>sowithout_the_switch_every_page_is_freshpasses hermetically even whenVICTORY_PORT_JOURNAL=1is set in the environment, cleaning up the#[cfg(test)]-only helpers and staleclaimlock comment, and clarifyingVICTORY_PORT_GUARD/VICTORY_PORT_JOURNALgating. Re-verifiedvictory-gpuandvictory-shadertests (both default and with all flags set),clippy --all-targets --all-features -- -D warnings, andcargo xtask policy.@upipibi on GitHub · 2026-11-27 22:24 UTC · original · edited 2026-11-27 22:29 UTC
A note on the write-guard part (
VICTORY_PORT_GUARD), from readinga4284695and a local benchmark: as it stands, the switch does not touch the path the fork's measured gain came from.on_write(crates/victory-gpu/src/watch.rs:978) takesguards()(:994), which isGUARDS.write()(:260-262) whatever the switch says. So each fault still waits behind every other fault and refresh, as with the oldMutex.guards_shared()(:265-267) is used outside tests only in the narrow mark at:903-904, insideif crate::port_journal::on()(:898). WithVICTORY_PORT_GUARD=1alone, nothing takes the lock shared.GUARDS/BUSY)", butBUSYdoes not appear in the diff.For comparison, port 6 in the fork this is ported from (gleaf-6/VIctory-7900XTX-
42ddb597, Belobug'swatch.rs) takes the lock shared in the faults (open_faulted), the refreshes andpublish. Each block's state there sits in atomic words with a claim per block, and only mapping changes, kernel writes and frees take it alone. Its measurement (36-41 → 2-6 ms a frame of all threads' waiting, at 352-392 write faults a frame) is from that fault path. On upstream's own stack, #3425's frame budget (RTX 5090) puts the same cost at 52 ms a frame: the title's write-fault handler queueing behindGUARDS, which our own paths hold about 49 ms a frame.Benchmark (local only, not proposed): an ignored test in
watch::tests. 1, 4, 8 and 16 threads write one byte per 4 KiB into freshly takenpool(64)memory, so each first write per block faults throughon_write, 40 rounds each.PORT_GUARD_IN_TESTis set from the variable on every writer thread, since the handler reads it on the faulting thread. Release build, 3 alternating runs per setting:VICTORY_PORT_GUARD=0, µs a round=1, µs a roundThere is no difference beyond run-to-run noise (the machine had other GPU work running), as expected with the handler on the exclusive lock. With the fork's change, this is the benchmark that should move.
AI-assisted (Claude Code, Claude Opus 5.5 read the code, wrote and ran the local benchmark).
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.