GPU: reuse unchanged page checks across shadow copy-back ranges #124

Closed
github-bot wants to merge 1 commit from gh-pr/124/head into gh-pr/124/base
Owner

@⁠TG0000 on GitHub · 2026-11-24 00:42 UTC · original
TG0000:perf/shadow-copyback-page-cache → main · +200 −8 · 1 files · 1 commits · closed without merging

Summary

GPU buffer copy-back compares each declared write range with the pre-submission snapshot. Distinct ranges can cover many of the same pages. This change remembers fully compared unchanged 64 KiB pages until the snapshot is released. Changed pages and unchecked parts of pages still go through the existing comparison and write-back path.

Synthetic release benchmark

On Windows MSVC with a Ryzen 9 5900X, the median of five CPU comparison runs dropped from 269.9 ms to 12.6 ms (21.5×). The fixture generates 24 distinct overlapping ranges across 128 MiB and changes one byte on every 64th page. Both paths report the same changed-page count. In-game frame time remains unmeasured.

cargo +stable-x86_64-pc-windows-msvc test --release -p victory-gpu benchmark_overlapping_copy_back -- --ignored --nocapture

Verification

  • cargo +stable-x86_64-pc-windows-msvc test --workspace (258 passed, four ignored by default)
  • cargo +stable-x86_64-pc-windows-msvc clippy --workspace --all-targets (existing warnings)
  • cargo +stable-x86_64-pc-windows-msvc xtask policy (151 files passed)

AI-assisted.

**@⁠TG0000** on GitHub · 2026-11-24 00:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/124) `TG0000:perf/shadow-copyback-page-cache` → `main` · +200 −8 · 1 files · 1 commits · closed without merging ## Summary GPU buffer copy-back compares each declared write range with the pre-submission snapshot. Distinct ranges can cover many of the same pages. This change remembers fully compared unchanged 64 KiB pages until the snapshot is released. Changed pages and unchecked parts of pages still go through the existing comparison and write-back path. ## Synthetic release benchmark On Windows MSVC with a Ryzen 9 5900X, the median of five CPU comparison runs dropped from 269.9 ms to 12.6 ms (21.5×). The fixture generates 24 distinct overlapping ranges across 128 MiB and changes one byte on every 64th page. Both paths report the same changed-page count. In-game frame time remains unmeasured. ```powershell cargo +stable-x86_64-pc-windows-msvc test --release -p victory-gpu benchmark_overlapping_copy_back -- --ignored --nocapture ``` ## Verification - `cargo +stable-x86_64-pc-windows-msvc test --workspace` (258 passed, four ignored by default) - `cargo +stable-x86_64-pc-windows-msvc clippy --workspace --all-targets` (existing warnings) - `cargo +stable-x86_64-pc-windows-msvc xtask policy` (151 files passed) AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:11 +00:00
github-bot closed this pull request 2026-11-26 03:51:11 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:52 UTC · original

Tested a6deb46 under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.

  • victory_gpu: 40 passed, 3 failed, 1 ignored — this PR adds 4 tests and they pass.
  • The 3 failures are the environment-only ones from main (argument_clamp_builds, a_rejected_blob_gives_an_empty_library, #128's VirtualQuery upload skip). Note the last one goes through the same shadow copy-back path this PR optimises, so if it is ever fixed (#128), re-running here would exercise the new reuse path end to end.
  • shadow::tests::benchmark_overlapping_copy_back stays ignored (synthetic CPU benchmark).

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7118517296) Tested `a6deb46` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**. - `victory_gpu`: **40 passed, 3 failed, 1 ignored** — this PR adds 4 tests and they pass. - The 3 failures are the environment-only ones from `main` (`argument_clamp_builds`, `a_rejected_blob_gives_an_empty_library`, #128's `VirtualQuery` upload skip). Note the last one goes through the same shadow copy-back path this PR optimises, so if it is ever fixed (#128), re-running here would exercise the new reuse path end to end. - `shadow::tests::benchmark_overlapping_copy_back` stays ignored (synthetic CPU benchmark). No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠KevinPratap on GitHub · 2026-11-24 13:27 UTC · original

Measured in the world on an RTX 4050 Laptop (Windows 11, title 1.0.2.1, diagnostics build of an integration branch with per-page snapshots, scripted input): the same idea, a page that copy-back already went over in this submission is skipped by later ranges, took copying back from 1.1-4.2 s to about 0.2 s per frame, and world frames from 9-13 s to about 1 s.

Before it, stack samples of world frames found the submitting thread in copy_back's comparison in 12 of 17 samples. The world declares dozens of overlapping views of the 174 MB heap per submission, so each page was compared once per declared range.

On that branch the snapshot is per page, so the mark is a done submission number on each page's snapshot. Any write to the snapshot resets it, and it counts only when the whole snapshot part of the page was gone over.

AI-assisted.

**@⁠KevinPratap** on GitHub · 2026-11-24 13:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7132850157) Measured in the world on an RTX 4050 Laptop (Windows 11, title 1.0.2.1, diagnostics build of an integration branch with per-page snapshots, scripted input): the same idea, a page that copy-back already went over in this submission is skipped by later ranges, took **copying back from 1.1-4.2 s to about 0.2 s per frame**, and world frames from 9-13 s to about 1 s. Before it, stack samples of world frames found the submitting thread in `copy_back`'s comparison in 12 of 17 samples. The world declares dozens of overlapping views of the 174 MB heap per submission, so each page was compared once per declared range. On that branch the snapshot is per page, so the mark is a `done` submission number on each page's snapshot. Any write to the snapshot resets it, and it counts only when the whole snapshot part of the page was gone over. AI-assisted.
Author
Owner

@⁠Yaekai on GitHub · 2026-11-24 16:20 UTC · original

Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head a6deb46:

  • cargo test -p victory-gpu --lib: 43 passed, 0 failed.
  • cargo clippy -p victory-gpu -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): verified shadow copy-back page-check reuse with zero corruption or stalls. Ready to merge!
**@⁠Yaekai** on GitHub · 2026-11-24 16:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7137522094) Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head `a6deb46`: - `cargo test -p victory-gpu --lib`: 43 passed, 0 failed. - `cargo clippy -p victory-gpu -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): verified shadow copy-back page-check reuse with zero corruption or stalls. Ready to merge!
Author
Owner

@⁠TG0000 on GitHub · 2026-11-24 16:30 UTC · original

Thanks for testing it in a long world run on another GPU vendor, that is the case I could not cover on an RX 6800.

AI-assisted (Claude Code).

**@⁠TG0000** on GitHub · 2026-11-24 16:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/124#issuecomment-7137784716) Thanks for testing it in a long world run on another GPU vendor, that is the case I could not cover on an RX 6800. _AI-assisted (Claude Code)._

Pull request closed

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/Marvisak--VIctory!124
No description provided.