host: rewire lock-free nothing_new_with and wide_chunk in refresh_front and flush_all #2175

Open
github-bot wants to merge 2 commits from github-bot/gh-2175 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-29 10:14 UTC · original
qlfu:pr/rewire-lockfree-refresh-checks → main · +150 −56 · 1 files · 2 commits · open

What it changes

Re-wires the lock-free Shadow::nothing_new_with(&ahead_snap, ...) refresh checks and wide_chunk() / MANY_REFRESH_CHUNK chunking in crates/victory-gpu/src/host.rs that were accidentally disconnected during the wave 1–6 merge onto main (829188e9), also clearing five dead-code / unused-variable warnings (ahead_snap, MANY_CHUNK, shadow::wide_chunk, Shadow::nothing_new_with, watch::nothing_new_with):

  1. Batch::refresh_front: Snapshots ahead_snapshot_into(&mut self.ahead_snap) once instead of taking JOURNAL locks per span in shadow.nothing_new(...). When kept is active without VICTORY_FRONT_SIFT and spans.len() > FEW, checks nothing_new_with inline in a single chunked wide_each_scoped pass (MANY_REFRESH_CHUNK = 8); when ask_ahead will run or VICTORY_FRONT_SIFT=1, sifts spans in parallel via lock-free sift_spans before ask_ahead and dispatches remaining spans using crate::shadow::wide_chunk().
  2. Batch::flush_all & Batch::refresh_ahead: Uses &self.ahead_snap with shadow.nothing_new_with(...) in both the <= FEW retain loop and the parallel check_noop wide_each_scoped loop (MANY_REFRESH_CHUNK), and replaces sift_front/sift_refreshes (which cloned Arc<Vec<_>> and used locked nothing_new) with the shared zero-clone lock-free sift_spans helper.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4070 Ti 12 GB + Ryzen 7 5700X (64 GB RAM), Series X, 2560×1440 native, DLSS Balanced, NoFG (VICTORY_PORT_CONSTANTS=1, VICTORY_WAIT_RESIDENT=textures), clean 90s A/B gameplay runs on 829188e9 (0 WARNs / 0 ERRORs in both runs):
  • Before (origin/main 829188e9, victory-nvidia-20261129-120600.log):
    • refreshes med 14.05 ms, steps med 25.05 ms, sub_all med 44.00 ms (mean 46.55 ms)
    • FPS med 16.80 (mean 17.76, p10 9.3), 1,830 frames in 104s, >50ms 55.5%, p95 91.3 ms, max 249.8 ms
  • After (this PR on 829188e9, victory-nvidia-20261129-124952.log):
    • refreshes med 11.05 ms (-3.00 ms / -21.4%), steps med 22.60 ms (-2.45 ms), sub_all med 41.15 ms (-2.85 ms, mean 41.19 ms -5.36 ms / -11.5%)
    • FPS med 17.40 (mean 18.25, p10 10.3 +1.0 FPS), 1,927 frames in 104s (+5.3%), >50ms 48.3% (-7.2%), p95 84.7 ms (-6.6 ms), max 196.6 ms (-53.2 ms)
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes).
  • cargo test passed for the crates it touches: yes (cargo test -p victory-gpu --lib --locked -- --test-threads=1 — 915 passed, 0 failed; cargo clippy -p victory-gpu --lib --tests --locked — exit 0, 5 pre-existing dead-code warnings cleared, 0 new warnings).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2049 (adds Batch hot caches in host.rs, does not touch refresh_front/flush_all nothing_new_with rewiring), supersedes #1676 (closing #1676 in favor of this focused PR since ahead_contains, Shadow::copied/ranged_lockfree, and watch::is_kept already merged on main).
**@⁠qlfu** on GitHub · 2026-11-29 10:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2175) `qlfu:pr/rewire-lockfree-refresh-checks` → `main` · +150 −56 · 1 files · 2 commits · open ## What it changes Re-wires the lock-free `Shadow::nothing_new_with(&ahead_snap, ...)` refresh checks and `wide_chunk()` / `MANY_REFRESH_CHUNK` chunking in `crates/victory-gpu/src/host.rs` that were accidentally disconnected during the wave 1–6 merge onto `main` (`829188e9`), also clearing five dead-code / unused-variable warnings (`ahead_snap`, `MANY_CHUNK`, `shadow::wide_chunk`, `Shadow::nothing_new_with`, `watch::nothing_new_with`): 1. **`Batch::refresh_front`:** Snapshots `ahead_snapshot_into(&mut self.ahead_snap)` once instead of taking `JOURNAL` locks per span in `shadow.nothing_new(...)`. When `kept` is active without `VICTORY_FRONT_SIFT` and `spans.len() > FEW`, checks `nothing_new_with` inline in a single chunked `wide_each_scoped` pass (`MANY_REFRESH_CHUNK = 8`); when `ask_ahead` will run or `VICTORY_FRONT_SIFT=1`, sifts spans in parallel via lock-free `sift_spans` before `ask_ahead` and dispatches remaining spans using `crate::shadow::wide_chunk()`. 2. **`Batch::flush_all` & `Batch::refresh_ahead`:** Uses `&self.ahead_snap` with `shadow.nothing_new_with(...)` in both the `<= FEW` retain loop and the parallel `check_noop` `wide_each_scoped` loop (`MANY_REFRESH_CHUNK`), and replaces `sift_front`/`sift_refreshes` (which cloned `Arc<Vec<_>>` and used locked `nothing_new`) with the shared zero-clone lock-free `sift_spans` helper. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4070 Ti 12 GB + Ryzen 7 5700X (64 GB RAM), Series X, 2560×1440 native, DLSS Balanced, NoFG (`VICTORY_PORT_CONSTANTS=1`, `VICTORY_WAIT_RESIDENT=textures`), clean 90s A/B gameplay runs on `829188e9` (`0 WARNs / 0 ERRORs` in both runs): - Before (`origin/main` `829188e9`, `victory-nvidia-20261129-120600.log`): - `refreshes` med `14.05 ms`, `steps` med `25.05 ms`, `sub_all` med `44.00 ms` (mean `46.55 ms`) - FPS med `16.80` (mean `17.76`, p10 `9.3`), 1,830 frames in 104s, `>50ms` `55.5%`, p95 `91.3 ms`, max `249.8 ms` - After (this PR on `829188e9`, `victory-nvidia-20261129-124952.log`): - `refreshes` med **`11.05 ms`** (**`-3.00 ms` / `-21.4%`**), `steps` med **`22.60 ms`** (**`-2.45 ms`**), `sub_all` med **`41.15 ms`** (**`-2.85 ms`**, mean **`41.19 ms`** **`-5.36 ms` / `-11.5%`**) - FPS med **`17.40`** (mean **`18.25`**, p10 **`10.3`** `+1.0 FPS`), **1,927 frames** in 104s (`+5.3%`), `>50ms` **`48.3%`** (`-7.2%`), p95 **`84.7 ms`** (`-6.6 ms`), max **`196.6 ms`** (`-53.2 ms`) - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes). - `cargo test` passed for the crates it touches: yes (`cargo test -p victory-gpu --lib --locked -- --test-threads=1` — 915 passed, 0 failed; `cargo clippy -p victory-gpu --lib --tests --locked` — exit 0, 5 pre-existing dead-code warnings cleared, 0 new warnings). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2049 (adds `Batch` hot caches in `host.rs`, does not touch `refresh_front`/`flush_all` `nothing_new_with` rewiring), supersedes #1676 (closing #1676 in favor of this focused PR since `ahead_contains`, `Shadow::copied`/`ranged_lockfree`, and `watch::is_kept` already merged on `main`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 10:17:27 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 10:22 UTC · original · approved these changes

Tested locally merged onto main (829188e9).

  • Merge: Clean merge in crates/victory-gpu/src/host.rs.
  • Tests (RTX 5090):
    • cargo test -p victory-gpu --lib host::refresh_tests:: passed.
    • cargo test -p victory-gpu --lib shadow:: passed (71 passed; 0 failed; 5 ignored).
  • 0 new warnings.

Clean rewiring of lock-free nothing_new_with and wide_chunk in refresh_front and flush_all. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-29 10:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2175#pullrequestreview-6102455104) · **approved these changes** Tested locally merged onto `main` (`829188e9`). - **Merge**: Clean merge in `crates/victory-gpu/src/host.rs`. - **Tests (RTX 5090)**: - `cargo test -p victory-gpu --lib host::refresh_tests::` passed. - `cargo test -p victory-gpu --lib shadow::` passed (`71 passed; 0 failed; 5 ignored`). - 0 new warnings. Clean rewiring of lock-free `nothing_new_with` and `wide_chunk` in `refresh_front` and `flush_all`. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Nazzgy on GitHub · 2026-11-29 11:36 UTC · original

Independent Series S run on an RTX 3080 with the exact c4ff2452 release build. Both builds used the same checkpoint, the same logged gameplay settings, 1080p DLSS Performance with FSR 3 2x, and a copy of the same prepared host library. FRONT_SIFT and WIDE_CHUNK stayed at their defaults. The candidate visibly reached the expected scene.

In 30-second gameplay samples with similar draw counts, the median copy refresh cost was 24.30 ms on 829188e and 21.80 ms on this PR. Median draw counts were 5,436 and 5,483. Rendered FPS medians were 14.0 and 11.7, with 6 and 5 periodic reports. GPU time was also different in those samples. These observations support a lower cost for the refresh step on this rig. Overall frame pacing needs a repeated comparison.

The candidate took longer to reach the same view, so these windows began at different times after the first upscale. Check the rendered scene and loading phase before interpreting periodic FPS during startup.

**@⁠Nazzgy** on GitHub · 2026-11-29 11:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2175#issuecomment-7255226712) Independent Series S run on an RTX 3080 with the exact c4ff2452 release build. Both builds used the same checkpoint, the same logged gameplay settings, 1080p DLSS Performance with FSR 3 2x, and a copy of the same prepared host library. FRONT_SIFT and WIDE_CHUNK stayed at their defaults. The candidate visibly reached the expected scene. In 30-second gameplay samples with similar draw counts, the median copy refresh cost was 24.30 ms on 829188e and 21.80 ms on this PR. Median draw counts were 5,436 and 5,483. Rendered FPS medians were 14.0 and 11.7, with 6 and 5 periodic reports. GPU time was also different in those samples. These observations support a lower cost for the refresh step on this rig. Overall frame pacing needs a repeated comparison. The candidate took longer to reach the same view, so these windows began at different times after the first upscale. Check the rendered scene and loading phase before interpreting periodic FPS during startup.
Author
Owner

@⁠iBooM72 on GitHub · 2026-11-29 13:49 UTC · original

I tested this PR at c4ff2452 against its base, 829188e9. Refreshes were about 4-5% faster, but I saw no FPS gain. This is a small test (1 base run and 2 PR runs), so both results could be normal variation.

System: RTX 4070 Ti 12 GB (driver 621.01), i7-14700K, 32 GB RAM, Windows 11 build 26300.

Settings: Series X, 1080to1440, DLSS Quality, frame generation and ray tracing off, 120 FPS cap, VICTORY_PATCH_SSE4A=0, VICTORY_KEEP_SHOWN=checked. VICTORY_FRONT_SIFT, VICTORY_FLUSH_SIFT and VICTORY_WIDE_CHUNK weren't set. The logs list identical Victory settings for all three runs, apart from folder paths.

Method: I built both versions with cargo build --release --locked -p victory. Each had its own folder and one preload and warm-up run that isn't counted. The save and settings were reset before every run, and the planned route was the same. Runs were in the order base, PR, PR, with about 3 minutes in the world each. The table shows medians from 60 s after the first reading with over 1,000 draws until the last one (about 2 minutes, 24-25 FPS readings per run).

Base PR, run 1 PR, run 2
FPS 23.6 22.1 23.0
Frame time (ms) 42.3 45.3 43.5
p95 frame time, median of the one-second values (ms) 62.9 66.7 63.4
Refreshes (ms) 11.3 10.9 10.7
Refreshes asked for 8,809 8,956 9,083
Time per refresh asked for (µs) 1.28 1.22 1.18
List steps (ms) 18.5 17.8 18.2
Submitting thread (ms) 37.7 37.7 37.1
GPU time, title lists (ms) 33.2 33.5 33.1
Draws per frame 7,445 7,380 7,536
  • Stability: no crashes, failed pipelines or memory guard put-offs. VRAM stayed within its budget, and every run closed normally.
  • Tests: cargo test -p victory-gpu --lib --locked -- --test-threads=1 gave 915 passed, 0 failed and 57 ignored on both commits.
  • Build warnings: victory-gpu had 16 with the PR and 21 on base. The PR removes the nothing_new_with, wide_chunk, MANY_CHUNK and ahead_snap ones.
  • CI: Clippy stopped on unwind_copy in victory-loader/src/crash.rs, which this PR doesn't change.

Limits: with only one base run, I can't tell how much base varies. #1151 reports about 2.5 FPS of noise between runs, and the two PR runs differed by 0.9. I didn't record background activity or compare graphics, so this doesn't rule out visual differences. Other CPUs may show a different result.

Logs (redacted): the full play logs of the three runs in the table. The warm-up logs aren't included.

Analysed and written with an AI assistant (Claude Code); the game runs were on my PC.

pr2175-three-runs.zip

**@⁠iBooM72** on GitHub · 2026-11-29 13:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2175#issuecomment-7256826618) I tested this PR at `c4ff2452` against its base, `829188e9`. **Refreshes were about 4-5% faster, but I saw no FPS gain.** This is a small test (1 base run and 2 PR runs), so both results could be normal variation. **System:** RTX 4070 Ti 12 GB (driver 621.01), i7-14700K, 32 GB RAM, Windows 11 build 26300. **Settings:** Series X, `1080to1440`, DLSS Quality, frame generation and ray tracing off, 120 FPS cap, `VICTORY_PATCH_SSE4A=0`, `VICTORY_KEEP_SHOWN=checked`. `VICTORY_FRONT_SIFT`, `VICTORY_FLUSH_SIFT` and `VICTORY_WIDE_CHUNK` weren't set. The logs list identical Victory settings for all three runs, apart from folder paths. **Method:** I built both versions with `cargo build --release --locked -p victory`. Each had its own folder and one preload and warm-up run that isn't counted. The save and settings were reset before every run, and the planned route was the same. Runs were in the order base, PR, PR, with about 3 minutes in the world each. The table shows medians from 60 s after the first reading with over 1,000 draws until the last one (about 2 minutes, 24-25 FPS readings per run). | | Base | PR, run 1 | PR, run 2 | |---|---|---|---| | FPS | 23.6 | 22.1 | 23.0 | | Frame time (ms) | 42.3 | 45.3 | 43.5 | | p95 frame time, median of the one-second values (ms) | 62.9 | 66.7 | 63.4 | | **Refreshes (ms)** | **11.3** | **10.9** | **10.7** | | Refreshes asked for | 8,809 | 8,956 | 9,083 | | Time per refresh asked for (µs) | 1.28 | 1.22 | 1.18 | | List steps (ms) | 18.5 | 17.8 | 18.2 | | Submitting thread (ms) | 37.7 | 37.7 | 37.1 | | GPU time, title lists (ms) | 33.2 | 33.5 | 33.1 | | Draws per frame | 7,445 | 7,380 | 7,536 | - **Stability:** no crashes, failed pipelines or memory guard put-offs. VRAM stayed within its budget, and every run closed normally. - **Tests:** `cargo test -p victory-gpu --lib --locked -- --test-threads=1` gave 915 passed, 0 failed and 57 ignored on both commits. - **Build warnings:** `victory-gpu` had 16 with the PR and 21 on base. The PR removes the `nothing_new_with`, `wide_chunk`, `MANY_CHUNK` and `ahead_snap` ones. - **CI:** Clippy stopped on `unwind_copy` in `victory-loader/src/crash.rs`, which this PR doesn't change. **Limits:** with only one base run, I can't tell how much base varies. #1151 reports about 2.5 FPS of noise between runs, and the two PR runs differed by 0.9. I didn't record background activity or compare graphics, so this doesn't rule out visual differences. Other CPUs may show a different result. **Logs (redacted):** the full play logs of the three runs in the table. The warm-up logs aren't included. Analysed and written with an AI assistant (Claude Code); the game runs were on my PC. [pr2175-three-runs.zip](https://github.com/user-attachments/files/35572833/pr2175-three-runs.zip)
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-30 07:58 UTC · original · edited 2026-11-30 09:57 UTC

We ran a test of this PR on current main (41adb551 with this PR merged), on a CPU-bound machine.

We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms.

CPU prep (ms/frame) main at that point fps main at that point
round 1 64.4 60.7 14.2 14.3
round 2 58.6 60.1 15.5 15.3
mean difference +1.1 ms +0.3 %

No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR.

The submitting thread's refreshes, which this PR aims at: 20.4 and 18.9 ms a frame, against 18.9 to 21.2 on main.

Picture: 0 defects in 160 frames.

Setup:

  • Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11;
  • Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off;
  • the PR merged locally onto main 41adb551 (only its own commits on top), against 41adb551 itself;
  • a warm-up run per build, then 150 s runs in two rounds (the second in reverse order), with five main runs spread through the session;
  • every run starts from the same save, restored before each run;
  • CPU prep is the median of the submitting thread's 5 s lines, fps the median of the host's 5 s lines, on the light-view seconds after the first 20 s; each run is compared with main's runs interpolated in time.

Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame.

AI Assisted

**@⁠DoubleD17** on GitHub · 2026-11-30 07:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2175#issuecomment-7272335354) · edited 2026-11-30 09:57 UTC We ran a test of this PR on current main (41adb551 with this PR merged), on a CPU-bound machine. We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms. | | CPU prep (ms/frame) | main at that point | fps | main at that point | |---|---|---|---|---| | round 1 | 64.4 | 60.7 | 14.2 | 14.3 | | round 2 | 58.6 | 60.1 | 15.5 | 15.3 | | **mean difference** | **+1.1 ms** | | **+0.3 %** | | No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR. The submitting thread's refreshes, which this PR aims at: 20.4 and 18.9 ms a frame, against 18.9 to 21.2 on main. **Picture:** 0 defects in 160 frames. **Setup:** - Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11; - Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off; - the PR merged locally onto main 41adb551 (only its own commits on top), against 41adb551 itself; - a warm-up run per build, then 150 s runs in two rounds (the second in reverse order), with five main runs spread through the session; - every run starts from the same save, restored before each run; - CPU prep is the median of the submitting thread's 5 s lines, fps the median of the host's 5 s lines, on the light-view seconds after the first 20 s; each run is compared with main's runs interpolated in time. Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame. AI Assisted
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2175'
git switch 'github-bot/gh-2175'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2175'
git switch 'github-bot/gh-2175'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2175'
git switch 'main'
git merge --squash 'github-bot/gh-2175'
git switch 'main'
git merge --ff-only 'github-bot/gh-2175'
git switch 'main'
git merge 'github-bot/gh-2175'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2175
No description provided.