victory-gpu: open write-faulted guarded blocks without the guards' lock by default, and build soft runs once per guard pass #516

Open
github-bot wants to merge 1 commit from github-bot/gh-516 into main AGit
Owner

@⁠henriazz10 on GitHub · 2026-11-27 23:54 UTC · original
henriazz10:perf/cpu-copies-rtx50 → main · +28 −13 · 1 files · 1 commits · open

Summary

  • Root-cause profiling (copystat diagnostics build on RTX 5080):
    • In the 12-minute user log (victory-nvidia-play-20261127-220810-11640.log), the last 60s ran at 4.0–5.7 fps (175.4–246.9 ms/frame) with CPU copies at 56.3–61.9 ms (116.4–157.8 MB) and refreshes at 51.7 ms, while GPU busy time was 12–21% and live shader/pipeline compilation had mostly subsided (72 shader translated, 3 host pipeline shaders=).
    • A copystat run (victory-nvidia-play-20261127-224637-55336.log) showed guards holding GUARDS.lock() for 49.5 ms/frame (450 watches 53.65 ms, 474 blocks made read-only) while write-fault handling (VICTORY_FAULT_UNLOCKED off by default) spent 43.63 ms per frame waiting on GUARDS.lock() across threads (429 faults/frame).
  • Change (crates/victory-gpu/src/watch.rs, commit f5bde6b (rebased on main 64d4931)):
    • Enabled VICTORY_FAULT_UNLOCKED by default (unlocked_from_env returns true unless VICTORY_FAULT_UNLOCKED=0).
    • Hoisted soft_runs(first * BLOCK, (last - first) * BLOCK) out of GUARDS.lock() in guard(), passing &soft into protect() / protect_here().
    • Added unit test watch::many_askers_tests::unlocked_defaults_on_unless_zero.
  • Negative control:
    • Temporarily switching unlocked_from_env back to val.is_some_and(|v| v == "1") caused cargo test -p victory-gpu --lib --locked unlocked_defaults_on_unless_zero to fail (exit code 1):
      thread 'watch::many_askers_tests::unlocked_defaults_on_unless_zero' (31036) panicked at crates\victory-gpu\src\watch.rs:5294:9: assertion failed: super::unlocked_from_env(None)

Before / After Measurements (Plain Release Build, 130s VICTORY_WARMUP_RESTART=0)

  • Baseline 1 (victory-nvidia-play-20261127-225157-24736.log): 12.6 fps, 79.5 ms/frame (66.0 preparing: copies 34.3 ms 42.3 MB, textures 3.1 ms 24.0 MB; 0.0 on the GPU; 9.5 copying back 0.5 MB), 3576 draws/frame; refreshes 27.1–36.1 ms.
  • Baseline 2 (victory-nvidia-play-20261127-225454-59896.log): 8.3 fps, 120.0 ms/frame (80.3 preparing: copies 44.4 ms 82.1 MB, textures 4.1 ms 57.4 MB; 2.8 on the GPU; 9.3 copying back 0.7 MB), 3862 draws/frame; refreshes 20.0–50.7 ms.
  • After 1 (victory-nvidia-play-20261127-231559-54768.log): 11.9 fps, 84.2 ms/frame (66.9 preparing: copies 32.2 ms 61.0 MB, textures 18.1 ms 40.1 MB; 2.7 on the GPU; 6.3 copying back 0.5 MB), 3743 draws/frame; refreshes 16.1–26.0 ms.
  • After 2 (victory-nvidia-play-20261127-231853-57360.log): 11.1 fps, 90.2 ms/frame (73.8 preparing: copies 46.4 ms 69.7 MB, textures 3.9 ms 29.0 MB; 0.8 on the GPU; 8.4 copying back 0.5 MB), 3161 draws/frame; refreshes 25.1–37.3 ms.
  • Note: refreshes narrowed from 20.0–50.7 ms to 16.1–37.3 ms, while CPU copies remained 32.2–46.4 ms because remaining contention/copy cost is dominated by GUARDS.lock() across 8 GPU worker threads in guard() (620 waits, 175.03 ms in copystat) and soft_read (43.47–46.58 ms).

Reviewer notes (Claude Code)

  • Rebased on main 64d4931. On that same main, without this change, the CI commands fail the same way on this Windows checkout: cargo fmt --check (CRLF from core.autocrlf=true), clippy (clippy::precedence in victory-formats/src/texture.rs, missing_transmute_annotations in victory-loader/src/write_sites.rs) and the same 2 tests in victory-gpu::indirect::tests. This PR adds no new failure.
  • The 130 s before/after runs above are within run-to-run noise; the numbers do not prove a frame-rate gain by themselves.
  • Hand test by the user on the RTX 5080, about 10 minutes of play (prison, streets, police chase, boat): called playable; the window title showed roughly 5-20 fps, versus 3-5 fps and a near-black picture on the first try with df2daaf. That first try had no warm shader cache, so part of that difference is the cache, not this change.
  • Behaviour change to review: VICTORY_FAULT_UNLOCKED is now on by default (VICTORY_FAULT_UNLOCKED=0 restores the old path).

Checks

  • cargo test -p victory-gpu --lib --locked watch::: exit code 0 (48 passed; 0 failed)
  • cargo fmt --all -- --check: exit code 1 (pre-existing formatting diffs across untouched files; zero diffs in our added/modified lines in crates/victory-gpu/src/watch.rs)
  • cargo clippy --workspace --all-targets --locked -- -D warnings: exit code 101 (pre-existing clippy::precedence error in crates/victory-formats/src/texture.rs:1346)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: exit code 101 (same pre-existing clippy::precedence error in crates/victory-formats/src/texture.rs:1346)
  • cargo test --workspace --locked: exit code 101 (victory: 23 passed, census: 2 passed, victory-core: 13 passed, victory-formats: 42 passed; 5 ignored, victory-game: 3 passed, victory-gpu: 423 passed; 2 failed; 35 ignored — indirect::tests::host_list_budget_starts_empty_at_each_submission and indirect::tests::warp_batch_charges_every_execution also fail identically with VICTORY_FAULT_UNLOCKED=0)
  • git diff --check: exit code 0

Environment & Untested Scope

  • Environment: Windows 11 build 26300, NVIDIA RTX 5080, driver 616.92.
  • Not tested: Extended open-world driving past the 130s startup/prologue sequence; the 4 out-of-scope picture issues are left for separate pull requests.

AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.

🤖 Generated with Claude Code

**@⁠henriazz10** on GitHub · 2026-11-27 23:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/516) `henriazz10:perf/cpu-copies-rtx50` → `main` · +28 −13 · 1 files · 1 commits · open ## Summary - **Root-cause profiling (`copystat` diagnostics build on RTX 5080)**: - In the 12-minute user log (`victory-nvidia-play-20261127-220810-11640.log`), the last 60s ran at 4.0–5.7 fps (175.4–246.9 ms/frame) with CPU `copies` at 56.3–61.9 ms (116.4–157.8 MB) and `refreshes` at 51.7 ms, while GPU busy time was 12–21% and live shader/pipeline compilation had mostly subsided (72 `shader translated`, 3 `host pipeline shaders=`). - A `copystat` run (`victory-nvidia-play-20261127-224637-55336.log`) showed `guards` holding `GUARDS.lock()` for `49.5 ms/frame` (`450 watches 53.65 ms`, `474` blocks made read-only) while write-fault handling (`VICTORY_FAULT_UNLOCKED` off by default) spent `43.63 ms` per frame waiting on `GUARDS.lock()` across threads (`429` faults/frame). - **Change (`crates/victory-gpu/src/watch.rs`, commit `f5bde6b (rebased on main 64d4931)`)**: - Enabled `VICTORY_FAULT_UNLOCKED` by default (`unlocked_from_env` returns `true` unless `VICTORY_FAULT_UNLOCKED=0`). - Hoisted `soft_runs(first * BLOCK, (last - first) * BLOCK)` out of `GUARDS.lock()` in `guard()`, passing `&soft` into `protect()` / `protect_here()`. - Added unit test `watch::many_askers_tests::unlocked_defaults_on_unless_zero`. - **Negative control**: - Temporarily switching `unlocked_from_env` back to `val.is_some_and(|v| v == "1")` caused `cargo test -p victory-gpu --lib --locked unlocked_defaults_on_unless_zero` to fail (exit code `1`): `thread 'watch::many_askers_tests::unlocked_defaults_on_unless_zero' (31036) panicked at crates\victory-gpu\src\watch.rs:5294:9: assertion failed: super::unlocked_from_env(None)` ## Before / After Measurements (Plain Release Build, 130s `VICTORY_WARMUP_RESTART=0`) - **Baseline 1** (`victory-nvidia-play-20261127-225157-24736.log`): `12.6 fps, 79.5 ms/frame (66.0 preparing: copies 34.3 ms 42.3 MB, textures 3.1 ms 24.0 MB; 0.0 on the GPU; 9.5 copying back 0.5 MB), 3576 draws/frame`; `refreshes` `27.1–36.1 ms`. - **Baseline 2** (`victory-nvidia-play-20261127-225454-59896.log`): `8.3 fps, 120.0 ms/frame (80.3 preparing: copies 44.4 ms 82.1 MB, textures 4.1 ms 57.4 MB; 2.8 on the GPU; 9.3 copying back 0.7 MB), 3862 draws/frame`; `refreshes` `20.0–50.7 ms`. - **After 1** (`victory-nvidia-play-20261127-231559-54768.log`): `11.9 fps, 84.2 ms/frame (66.9 preparing: copies 32.2 ms 61.0 MB, textures 18.1 ms 40.1 MB; 2.7 on the GPU; 6.3 copying back 0.5 MB), 3743 draws/frame`; `refreshes` `16.1–26.0 ms`. - **After 2** (`victory-nvidia-play-20261127-231853-57360.log`): `11.1 fps, 90.2 ms/frame (73.8 preparing: copies 46.4 ms 69.7 MB, textures 3.9 ms 29.0 MB; 0.8 on the GPU; 8.4 copying back 0.5 MB), 3161 draws/frame`; `refreshes` `25.1–37.3 ms`. - Note: `refreshes` narrowed from `20.0–50.7 ms` to `16.1–37.3 ms`, while CPU `copies` remained `32.2–46.4 ms` because remaining contention/copy cost is dominated by `GUARDS.lock()` across 8 GPU worker threads in `guard()` (`620 waits, 175.03 ms` in `copystat`) and `soft_read` (`43.47–46.58 ms`). ## Reviewer notes (Claude Code) - Rebased on main `64d4931`. On that same main, without this change, the CI commands fail the same way on this Windows checkout: `cargo fmt --check` (CRLF from `core.autocrlf=true`), `clippy` (`clippy::precedence` in `victory-formats/src/texture.rs`, `missing_transmute_annotations` in `victory-loader/src/write_sites.rs`) and the same 2 tests in `victory-gpu::indirect::tests`. This PR adds no new failure. - The 130 s before/after runs above are within run-to-run noise; the numbers do not prove a frame-rate gain by themselves. - Hand test by the user on the RTX 5080, about 10 minutes of play (prison, streets, police chase, boat): called **playable**; the window title showed roughly 5-20 fps, versus 3-5 fps and a near-black picture on the first try with `df2daaf`. That first try had no warm shader cache, so part of that difference is the cache, not this change. - Behaviour change to review: `VICTORY_FAULT_UNLOCKED` is now on by default (`VICTORY_FAULT_UNLOCKED=0` restores the old path). ## Checks - `cargo test -p victory-gpu --lib --locked watch::`: exit code `0` (`48 passed; 0 failed`) - `cargo fmt --all -- --check`: exit code `1` (pre-existing formatting diffs across untouched files; zero diffs in our added/modified lines in `crates/victory-gpu/src/watch.rs`) - `cargo clippy --workspace --all-targets --locked -- -D warnings`: exit code `101` (pre-existing `clippy::precedence` error in `crates/victory-formats/src/texture.rs:1346`) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: exit code `101` (same pre-existing `clippy::precedence` error in `crates/victory-formats/src/texture.rs:1346`) - `cargo test --workspace --locked`: exit code `101` (`victory`: `23 passed`, `census`: `2 passed`, `victory-core`: `13 passed`, `victory-formats`: `42 passed; 5 ignored`, `victory-game`: `3 passed`, `victory-gpu`: `423 passed; 2 failed; 35 ignored` — `indirect::tests::host_list_budget_starts_empty_at_each_submission` and `indirect::tests::warp_batch_charges_every_execution` also fail identically with `VICTORY_FAULT_UNLOCKED=0`) - `git diff --check`: exit code `0` ## Environment & Untested Scope - **Environment**: Windows 11 build 26300, NVIDIA RTX 5080, driver 616.92. - **Not tested**: Extended open-world driving past the 130s startup/prologue sequence; the 4 out-of-scope picture issues are left for separate pull requests. AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 23:58:39 +00:00
Author
Owner

@⁠Machad3x on GitHub · 2026-11-28 01:19 UTC · original

Tested merged on top of main (RTX 3080 Ti, Ryzen 7 5700X, 1440p DLSS Quality, title ray tracing on): 300 s alive. Together with #498, it cut the frame from 90-97 ms to 63-67 ms in the cell scene. The submitting thread went from 89.6 to 59.7 ms.

One race found in review: the guard pass now reads the soft-view runs from the runtime's books before taking the GUARDS lock. If a view is made real (title_memory_made_real) in between, it was opened before it was noted. The pass then still treats the block as guarded and clean, with no protection on it, so writes through it go unseen.

Our fix: a counter bumped under the lock in title_memory_made_real. The guard pass compares it after taking the lock and re-reads the runs if it changed. We also kept the write-fault switch going through toggled!, so it stays on by default and can still be flipped by VICTORY_AB.

**@⁠Machad3x** on GitHub · 2026-11-28 01:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/516#issuecomment-7231586741) Tested merged on top of main (RTX 3080 Ti, Ryzen 7 5700X, 1440p DLSS Quality, title ray tracing on): 300 s alive. Together with #498, it cut the frame from 90-97 ms to 63-67 ms in the cell scene. The submitting thread went from 89.6 to 59.7 ms. One race found in review: the guard pass now reads the soft-view runs from the runtime's books *before* taking the `GUARDS` lock. If a view is made real (`title_memory_made_real`) in between, it was opened before it was noted. The pass then still treats the block as guarded and clean, with no protection on it, so writes through it go unseen. Our fix: a counter bumped under the lock in `title_memory_made_real`. The guard pass compares it after taking the lock and re-reads the runs if it changed. We also kept the write-fault switch going through `toggled!`, so it stays on by default and can still be flipped by `VICTORY_AB`.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/516/head:github-bot/gh-516'
git switch 'github-bot/gh-516'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-516'
git switch 'github-bot/gh-516'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-516'
git switch 'github-bot/gh-516'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-516'
git switch 'main'
git merge --squash 'github-bot/gh-516'
git switch 'main'
git merge --ff-only 'github-bot/gh-516'
git switch 'main'
git merge 'github-bot/gh-516'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.