GPU: VICTORY_COLD_SKIP=1: refreshes pass over 2 MiB chunks with no write since (off by default) #1358

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

@⁠TG0000 on GitHub · 2026-11-26 18:08 UTC · original
TG0000:pr/cold-skip → main · +580 −72 · 4 files · 1 commits · open

AI-assisted (Claude). Off by default. This branch has not been run in the game: the numbers below come from an earlier version of the change on a local stack. Reports from other GPUs and CPUs are very welcome.

What

A refresh of a host copy walks every 64 KiB page of its range and compares the page's last copy with its last noted write (Shadow::copy_stale). A large copy that many submissions refresh is walked whole each time, mostly to find nothing.

With VICTORY_COLD_SKIP=1:

  • the write journal numbers every page it notes and keeps, per 2 MiB chunk, the number of the last one (its mark);
  • a copy remembers, per chunk, the mark it saw when a walk last left every page of the chunk fresh;
  • while the mark has not moved, the chunk is passed over.

Marks are read under the same lock as the written pages. A page still stale after its copy (taken in part, or numbered after a standing asking) keeps its chunk walked, so the same pages are copied as without the switch.

VICTORY_COLD_SKIP=alt turns it on and off every 20 s. A log line with the frame-rate line says how many pages were passed over. With the switch unset no marks are kept and every page is looked at as before.

Measured

AMD Radeon RX 6800 16 GB (RDNA2), Adrenalin 26.11.2, Ryzen 9 5900X, Windows 11, 1440p internal. One 240 s launch alternating the switch, 43 paired blocks, on a local stack with many other switches on (older base than this branch).

paired median change with the switch 95 % interval
frame time (base median 107.4 ms) -3.95 ms (30 of 43 blocks) -8.4 to -2.2
preparing -2.35 ms -6.9 to +1.1 (not distinguishable from zero)
GPU time +0.85 ms -1.3 to +3.0 (no change)
  • Pages passed over in the world: about 78 % (70 to 80).
  • A separate 180 s launch with VICTORY_REFRESH_CHECK=1: no "stale after its refresh" line. That check samples the first 256 bytes of each 64 KiB block, so it is evidence, not proof.
  • One machine, one launch each. Please do not read the 3.95 ms as a promise.

Difference from the measured version: while porting I found that it could remember a chunk holding a page that was still stale (written after a standing asking), and so not take that page again as the walk without the switch does. This PR keeps such a chunk walked; there is a test for it. The fixed version has not been measured.

Checks (on this branch, rebased on 52ac4ec0)

Built on macOS (Apple M3 Pro), cross-targeting Windows where noted:

  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, target x86_64-pc-windows-msvc: clean.
  • The victory-gpu and victory-shader Windows test binaries build. They were not run.
  • Native cargo test for victory-core, victory-formats, victory-pipeline, victory-shader: pass.
  • cold_skip.rs (standard library only): 9 of 9 tests pass with rustc --test, including a randomized comparison of the copied runs with and without the skip, with standing askings and partly held pages. These tests model the walk; they do not drive Shadow::copy_stale itself.
  • cargo xtask policy reports two files over the size limit (host.rs, lower.rs). Both already are on main, and this PR touches neither.
  • VICTORY_LIGHT_REFRESH=1 already returns early for a range with nothing new. This works per 2 MiB chunk, so it also helps when part of a range changed, and it does not need that switch. The two together are untested, as is VICTORY_DIRTY_4K.
  • #1178 also makes this walk cheaper, as one part of a larger change (a bitmask of pages never copied); the two would conflict in copy_stale.
  • #979 speeds up the guards' walk, a different one.

To try it

VICTORY_COLD_SKIP=alt and compare the two phases; once, VICTORY_COLD_SKIP=1 VICTORY_REFRESH_CHECK=1 and look for "stale after its refresh". Please report GPU, CPU, driver, the "passed over" percentage and both phases' preparing and frame times.

🤖 Generated with Claude Code

**@⁠TG0000** on GitHub · 2026-11-26 18:08 UTC · [original](https://github.com/fxceless/victory-fork/pull/1358) `TG0000:pr/cold-skip` → `main` · +580 −72 · 4 files · 1 commits · open **AI-assisted (Claude).** Off by default. **This branch has not been run in the game**: the numbers below come from an earlier version of the change on a local stack. Reports from other GPUs and CPUs are very welcome. ## What A refresh of a host copy walks every 64 KiB page of its range and compares the page's last copy with its last noted write (`Shadow::copy_stale`). A large copy that many submissions refresh is walked whole each time, mostly to find nothing. With `VICTORY_COLD_SKIP=1`: - the write journal numbers every page it notes and keeps, per 2 MiB chunk, the number of the last one (its mark); - a copy remembers, per chunk, the mark it saw when a walk last left every page of the chunk fresh; - while the mark has not moved, the chunk is passed over. Marks are read under the same lock as the written pages. A page still stale after its copy (taken in part, or numbered after a standing asking) keeps its chunk walked, so the same pages are copied as without the switch. `VICTORY_COLD_SKIP=alt` turns it on and off every 20 s. A log line with the frame-rate line says how many pages were passed over. With the switch unset no marks are kept and every page is looked at as before. ## Measured AMD Radeon RX 6800 16 GB (RDNA2), Adrenalin 26.11.2, Ryzen 9 5900X, Windows 11, 1440p internal. One 240 s launch alternating the switch, 43 paired blocks, on a local stack with many other switches on (older base than this branch). | | paired median change with the switch | 95 % interval | |---|---|---| | frame time (base median 107.4 ms) | **-3.95 ms** (30 of 43 blocks) | -8.4 to -2.2 | | preparing | -2.35 ms | -6.9 to +1.1 (not distinguishable from zero) | | GPU time | +0.85 ms | -1.3 to +3.0 (no change) | - Pages passed over in the world: about 78 % (70 to 80). - A separate 180 s launch with `VICTORY_REFRESH_CHECK=1`: no "stale after its refresh" line. That check samples the first 256 bytes of each 64 KiB block, so it is evidence, not proof. - One machine, one launch each. Please do not read the 3.95 ms as a promise. **Difference from the measured version:** while porting I found that it could remember a chunk holding a page that was still stale (written after a standing asking), and so not take that page again as the walk without the switch does. This PR keeps such a chunk walked; there is a test for it. The fixed version has not been measured. ## Checks (on this branch, rebased on `52ac4ec0`) Built on macOS (Apple M3 Pro), cross-targeting Windows where noted: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`, target `x86_64-pc-windows-msvc`: clean. - The `victory-gpu` and `victory-shader` Windows test binaries build. **They were not run.** - Native `cargo test` for `victory-core`, `victory-formats`, `victory-pipeline`, `victory-shader`: pass. - `cold_skip.rs` (standard library only): 9 of 9 tests pass with `rustc --test`, including a randomized comparison of the copied runs with and without the skip, with standing askings and partly held pages. These tests model the walk; they do not drive `Shadow::copy_stale` itself. - `cargo xtask policy` reports two files over the size limit (`host.rs`, `lower.rs`). Both already are on `main`, and this PR touches neither. ## Related - `VICTORY_LIGHT_REFRESH=1` already returns early for a range with nothing new. This works per 2 MiB chunk, so it also helps when part of a range changed, and it does not need that switch. The two together are untested, as is `VICTORY_DIRTY_4K`. - #1178 also makes this walk cheaper, as one part of a larger change (a bitmask of pages never copied); the two would conflict in `copy_stale`. - #979 speeds up the guards' walk, a different one. ## To try it `VICTORY_COLD_SKIP=alt` and compare the two phases; once, `VICTORY_COLD_SKIP=1 VICTORY_REFRESH_CHECK=1` and look for "stale after its refresh". Please report GPU, CPU, driver, the "passed over" percentage and both phases' preparing and frame times. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A refresh of a host copy walks every 64 KiB page of its range, comparing the
page's last copy with its last noted write. A large copy refreshed by many
submissions is walked whole each time, mostly to find nothing.

With the switch the write journal numbers every page it notes and keeps, per
2 MiB chunk, the number of the last one (its mark). A copy remembers per chunk
the mark it saw when a walk last left every page of the chunk fresh; while the
mark has not moved, the chunk is passed over. Marks are read under the same
lock as the written pages. A page still stale after its copy (taken in part, or
numbered after a standing asking) keeps its chunk walked, so the same pages are
copied as without the switch. VICTORY_COLD_SKIP=alt takes it in turns of 20 s.

Off by default: no marks are kept and every page is looked at as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:09:41 +00:00
This pull request can be merged automatically.
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/1358/head:github-bot/gh-1358'
git switch 'github-bot/gh-1358'

Merge

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