Guards: a submission's view memory guarded in one go, beside its asking (VICTORY_GUARD_BATCH, VICTORY_GUARD_BESIDE) #4876
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4876"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kenzim on 2026-12-01T12:28:55Z.
Who waits for the guards' lock, measured: in the street scene it was taken 440 times a frame, 198 of them behind another thread, waited for 28.7 ms and held for 5.1 ms, summed over threads. Nearly all of it is the refreshes in front of a submission (eight
victory-widethreads plus the submitting thread). The lock is held for about 12 µs at a time, and a wait is about 150 µs: threads sleep for a lock that is free again long before they wake.What changes:
watch::guard_ahead: a submission guards, in one go, every range its lists'Step::Refreshsteps refresh of guarded copies (Shadow::guarded_copy).guard's locked body becomesguard_locked(the lock handed in and back).guard.victory-guard,guard_ahead_begin) when the submission's one asking of the write watch begins, and waited for when the asking is made, before the first refresh. The asking is of write-watched memory and the guards are of views; neither reads what the other makes.VICTORY_GUARD_BATCH,VICTORY_GUARD_BESIDE.Measurements (RTX 3090, 32 threads, native 2560x1440, DLSS off, street scene; switches flipped inside one run with
VICTORY_AB), per frame:The lock waits are consistent over three runs. The 1.2 ms on the submitting thread (21.2 -> 20.0) rests on one clean run.
Correctness: under
VICTORY_REFRESH_CHECK=1, 0 stale-copy warnings in twelve phases with the batch and eleven without. The picture was intact in the A/B runs.In this card-bound scene the frame time does not move. The gains are in the processor stages named above.
Not measured: scenes other than the street. The
victory-guardthread itself is not exercised by a unit test (tests run the batch on the submitting thread).To restore the old behaviour:
VICTORY_GUARD_BATCH=0(every refresh guards its own range, as before);VICTORY_GUARD_BESIDE=0(batch made on the submitting thread after its asking).Shader cache / translator key: not affected.
Tests:
watch::many_askers_tests::no_write_to_views_is_lost_with_batched_guards(batches before half the askings, many threads, faults with and without the lock).watch::70 pass. Clippy onvictory-gpuis clean apart from the five errors main already has (#4152).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Freeman022026 on 2026-12-01T14:04:32Z.
Tested stacked together with #4875 and #4877 (
VICTORY_REFRESH_WITHINonly, keeping #4571's 512 KiBask_oncegap) on an RTX 4090 24 GB (driver 621.14), Ryzen 7 7800X3D, 64 GB RAM, Windows 11, Series X profile at 2560x1440, DLSS Performance, 2x DLSS Frame Generation, ray tracing off. Local MSVC release build (rustc 1.99.1) onv2026.11.30.02(84bd61e2) with a local PR stack.Comparing gameplay seconds with at least 180 title lists per frame between the prior run (first 1,000 gameplay seconds) and the run with #4875, #4876, and #4877 added (554 gameplay seconds):
refreshes: median dropped from 14.50 ms (p90 19.20 ms) to 10.80 ms (p90 13.00 ms).lists' steps: median dropped from 20.65 ms (p90 28.00 ms) to 17.20 ms (p90 20.40 ms).asking the write watch: median rose from 4.20 ms (p90 5.30 ms) to 7.40 ms (p90 8.90 ms) becausebeside.wait()sits inside that timed span, while total submitting-thread p90 fell from 42.80 ms to 37.10 ms (median 32.40 ms to 31.40 ms).One merge note: this PR defines
pub(crate) fn guard_aheadincrates/victory-gpu/src/watch.rs, which collides with #3411'spub(crate) fn guard_aheadwhen both are in the same tree. Renaming this PR's function locally resolved the conflict cleanly, and theguard_ahead,guard_batch, andrefresh_withintests passed.Not tested: #4876 isolated on clean
mainor a fixed input replay (the two runs were separate live gameplay sessions).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by albertik322-sudo on 2026-12-01T17:00:44Z.
Tested as part of a batch cherry-picked onto main @
5fabb46e(with #4294, #4340, #4493, #4206). PC: RTX 3070 Laptop 8 GB, i7-11800H, 32 GB RAM, Windows 11. Series S, DLSS Performance, FG x4.No isolated measurement, but the batch dropped fixed cost per frame from ~47 ms to ~25.5 ms and nothing in the guard path regressed: the write-watch asking line stayed ~12-16 ms with no new stalls, no corruption in hours of play. Confirming it is safe at least on a laptop where the guard/write-watch path is genuinely hot.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:29:41Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed