Write watch: guarded view memory asked unguarded asks no kernel #2745
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2745"
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 gabrielecabrini on 2026-11-29T16:46:41Z.
What
A texture refresh (
texture.rs,refresh_timed) askswatch::writes(start, end, false)first and, givenNone, asks again guarded. For a texture in view memory that the guards hold read-only (PROTECTED), the unguarded asking still went toGetWriteWatch, which refuses memory that is not write-watched. The answer was the sameNone, but only after a kernel call, once per such texture per refresh.Evidence
Same scene of a Linux run (boat, Series S, RTX 4070 SUPER, Proton Experimental, diagnostics build), before and after, 2026-11-29:
The frame rate did not move (about 22 fps): the submitting thread's whole work stays near the frame, and the card now idles 6 to 12 ms a frame instead of 22. The two samples are different moments of the same scene, so the small differences carry noise; the large ones do not.
Fix
crates/victory-gpu/src/watch.rs,writes():PROTECTEDreturnsNonebeforeAsking::hold, as the kernel would have answered.refusedshortcut, which already skips the kernel for such memory when asked guarded.PROTECTEDis a lock-free bit set, so write-watched memory pays one bit test.Tests
guarded_view_memory_asked_unguarded_asks_no_kernel:Noneand the guarded one still answers;ASKS[10]);watch::tests under Proton: 59 pass. These four fail with and without this change, onmaintoo:many_askers_tests::bits_and_holes_with_faults_that_take_no_lockmany_askers_tests::holes_are_known_until_the_runtime_tellsmany_askers_tests::no_mapping_is_lost_between_askerstests::what_is_left_alone_is_no_known_holeclippy -p victory-gpureports nothing in the changed lines; thewatch.rswarning about an unusednothing_new_withis already onmain.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-29T17:48:59Z.
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch
janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with--profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series S with ray tracing, and Series X, DLSS Quality). Frame times will follow here.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CopiiDeco on 2026-11-29T19:42:10Z.
Measured this on Windows; flagging a possible correctness side effect.
Rig: Ryzen 5 5600X (6C/12T), RTX 3080 10 GB (driver 616.92), 32 GB DDR4-3600, B450 (PCIe 3.0), Windows 11 26200.
Setup: diagnostics build,
scripts/bench.ps1 -Dlss performance -FrameGen off -RayTracing off, Series S profile,VICTORY_WC_BAR=1 VICTORY_WINDOWS_BAR_MB=2048, same save and opening cutscene each run, 30 s warm-up + 120 s measured, pipelines precompiled.829188e9On its own it is neutral in fps with somewhat better tails, but the warning above (the safety net catching a write that the watch/guards did not report) goes from 30 to ~200 in a run, which suggests guarded view memory asked unguarded now misses some writes. Textures are re-uploaded by that net; buffers may not be. On top of the other three PRs it also costs about 1.3 fps and a worse p99 here.
One run per configuration, about ±0.4 fps run-to-run noise on this rig, so the fps deltas are indicative; the warning count is the part I'd look at. Happy to rerun with other switches or a timeline.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CopiiDeco on 2026-11-29T19:56:52Z.
Correction to my comment above: please disregard the "a texture picked by index changed after its upload with nothing to tell of it" counts. I counted that warning across all of today's runs of unmodified main on this rig and it is bimodal from run to run (8, 27, 30, 52, 124, 160, 200, 201, 204 …), so the ~200 I saw with this PR is within main's own range and says nothing about missed writes. Sorry for the noise.
The rest stands as measured (one run per configuration, so treat the fps deltas as indicative).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gabrielecabrini on 2026-11-29T21:18:44Z.
Thanks for measuring. With #2776 its REFUSED memo already skips nearly every refused kernel asking this PR saves, so on top of it #2745 is little more than a bit test in place of a mutex; it matters mostly under Proton, where each refusal costs about 1.3 ms, against microseconds on Windows.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gabrielecabrini on 2026-11-29T22:08:21Z.
Closing: #2776's REFUSED memo already skips nearly every refused kernel asking this saved, so what is left is a bit test in place of a mutex. Not worth a review on its own.
Pull request closed