perf: transient windows leave out pages that hold what they last sent (VICTORY_WINDOW_SKIP_SAME) #340

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

@⁠Skyfrye on GitHub · 2026-11-26 08:25 UTC · original
Skyfrye:nep/window-skip-same-pr → main · +582 −7 · 4 files · 1 commits · open

Change

VICTORY_WINDOW_SKIP_SAME, a new switch whose default (unset) sends what was sent before. With VICTORY_CARD_WINDOW_UPLOAD=1 (in the launcher's set) a window outside buffers keeps no CPU side, only its card buffer ("transient"). Every page the write watch or the guards call written is copied into pooled upload memory and sent up whole, without comparing it to anything. In the world that is about 70 MB a frame. A page that was written can still hold the same bytes as before: the title rewrites constant data.

Each transient window now keeps a 64-bit print per 4 KiB page of the bytes it last sent for that page (Card::prints, 8 bytes a page, made at the window's first copy: 8 KiB for a 4 MiB window). The print is page_print, an XXH3-style accumulate over eight lanes with keys that depend on position. It adds no crate (xxh3 is not in the tree, and blake3 is far too slow at 4 KiB) and runs at about 40 GB/s on one core.

VICTORY_WINDOW_SKIP_SAME What is sent What is compared
unset (default) everything, as before one 4 KiB page in 16 (picked by its address, the same pages each time) is read again and compared; the counts are multiplied by 16, an estimate
1 only the 4 KiB pages whose print is not the one last sent every page: title memory is read 256 KiB at a time into a buffer of the thread's, printed, and each run of other pages goes into a chunk of its own
0 everything nothing (the code path as before)

A new line comes with the frame-rate line, only while VICTORY_CARD_WINDOW_UPLOAD=1: title memory transient windows took per frame: N MB sent up, L MB left out; of what they took, S MB held the bytes the window last sent for their 4 KiB page, O MB other bytes, U MB nothing to compare with (VICTORY_WINDOW_SKIP_SAME=...). U covers pages never sent before, pages taken only in part, and windows that shaders are said to write. The ram line's window upload: part also gives the prints' memory.

Why the card side still holds a page that was left out:

  • Only the window's own sends write its card buffer, and Host::card_before copies them in the order they were copied. The dirty and masked-patch path, the merges and the copy-backs already skip transient windows.
  • A declared shader write to a transient window (unordered access, a title buffer copy on the card, title memory by address) is already a bug that is counted and logged (Shadow::transient_written). Such a window compares nothing from then on and sends everything it takes.
  • A page taken only in part loses its print, because the card then holds bytes from two reads. A window made again starts with no prints. The print is taken from the exact bytes that are sent, never from a second read.
  • The prints stay locked from the read until the chunks are noted, so with refreshes running in parallel, a print is always the one of the last chunk noted for its page.

Remaining risk: two different pages with the same 64-bit print (about 2^-64 per compare) would leave the older bytes on the card until the title writes the page again.

The default does not change. Unset only samples and sends everything as before, and the launcher's set is not touched. 1 is for whoever wants to try it.

Linked issue: none.

Verification

Windows 11 26300, Rust 1.98.1 (MSVC), on upstream main at c4c93bd, from third_party/victory:

cargo build --locked --release -p victory                                          -> Finished, no new warning
VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --lib -- --test-threads=1  -> 187 passed, 3 failed

The 3 failures are those of main: spans_say_the_next_start_and_the_lowest_level_viewed, warp_card_fetch_copies_flagged_pieces_to_their_slots, warp_card_patch_writes_the_masked_bytes_and_no_others. 4 new tests, CPU only (shadow::window_same_tests). None of them builds without this change:

  • a_print_changes_with_any_change_of_the_page: every single-bit flip, word swap, stripe swap and block swap of a page changes its print.
  • a_page_is_the_same_only_after_the_same_bytes_were_taken_whole: same, other, nothing to compare with, and a page taken in part keeps no print.
  • the_card_side_holds_the_titles_bytes_with_the_same_pages_left_out: a model of a window against a fake card side. It runs fixed cases and then 300 random rounds of writes, set-backs and partial ranges, and after each refresh checks that the card side equals title memory over the refreshed range and that only the pages that changed were sent. With the same pages sent again (a temporary mutant in window_copy) it fails: 1,048,576 bytes sent where 0 were expected.
  • one_page_in_sixteen_is_compared_and_counted_sixteen_times: the sample without the switch.

In the world of GTA VI (my own copy), running as a Series S (--console series-s, 1280x720), launcher set with #308 and VICTORY_INDIRECT_RAW=3, the same exe both ways, runs of 300 s alternating:

VICTORY_WINDOW_SKIP_SAME fps (median of the last minute)
unset 18.5 (machine 54 % loaded, not trustworthy), 20.1
1 20.7, 21.2

Of the bytes the transient windows took per frame, 67-73 MB held what the window last sent for their 4 KiB page, 0.9 MB differed, and 3.6-4.1 MB had nothing to compare with. With 1, those ~70 MB a frame were left out. No exception and no device lost in the 4 runs. With a single trustworthy run without the switch, the frame-rate gain is small (20.1 fps against 20.7 and 21.2). The firm part is the bytes left out.

The exe of these runs was built from the branch this PR comes from. That branch has the same skip code on top of a wider counter line and another switch that is off by default (VICTORY_REFRESH_4K, not set in these runs). This PR carries only the skip and the windows' part of that line.

Oracle and test data

No game file. The counts and frame rates come from my own runs of my copy of the game. The tests use generated bytes.

Checklist

  • The PR covers a single reviewable behaviour (transient windows leave out the 4 KiB pages that hold what they last sent, behind a switch that is off by default).
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Nothing unimplemented here.)
  • README: not touched.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: frame rates and byte counts of my own runs; no title code.
  • Code taken from another project: none (the print follows the shape of XXH3's accumulate; no code from it).

AI assistance: written with Claude Code. Claude Opus 5.5 subagents designed and wrote the change and its tests, ported it onto main for this PR and wrote this description. Claude Opus 5.5 (coordinating) ran the game A/B.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 08:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/340) `Skyfrye:nep/window-skip-same-pr` → `main` · +582 −7 · 4 files · 1 commits · open ## Change `VICTORY_WINDOW_SKIP_SAME`, a new switch whose default (unset) sends what was sent before. With `VICTORY_CARD_WINDOW_UPLOAD=1` (in the launcher's set) a window outside buffers keeps no CPU side, only its card buffer ("transient"). Every page the write watch or the guards call written is copied into pooled upload memory and sent up whole, without comparing it to anything. In the world that is about 70 MB a frame. A page that was written can still hold the same bytes as before: the title rewrites constant data. Each transient window now keeps a 64-bit print per 4 KiB page of the bytes it last sent for that page (`Card::prints`, 8 bytes a page, made at the window's first copy: 8 KiB for a 4 MiB window). The print is `page_print`, an XXH3-style accumulate over eight lanes with keys that depend on position. It adds no crate (xxh3 is not in the tree, and blake3 is far too slow at 4 KiB) and runs at about 40 GB/s on one core. | `VICTORY_WINDOW_SKIP_SAME` | What is sent | What is compared | |---|---|---| | unset (default) | everything, as before | one 4 KiB page in 16 (picked by its address, the same pages each time) is read again and compared; the counts are multiplied by 16, an estimate | | `1` | only the 4 KiB pages whose print is not the one last sent | every page: title memory is read 256 KiB at a time into a buffer of the thread's, printed, and each run of other pages goes into a chunk of its own | | `0` | everything | nothing (the code path as before) | A new line comes with the frame-rate line, only while `VICTORY_CARD_WINDOW_UPLOAD=1`: `title memory transient windows took per frame: N MB sent up, L MB left out; of what they took, S MB held the bytes the window last sent for their 4 KiB page, O MB other bytes, U MB nothing to compare with (VICTORY_WINDOW_SKIP_SAME=...)`. U covers pages never sent before, pages taken only in part, and windows that shaders are said to write. The ram line's `window upload:` part also gives the prints' memory. Why the card side still holds a page that was left out: - Only the window's own sends write its card buffer, and `Host::card_before` copies them in the order they were copied. The dirty and masked-patch path, the merges and the copy-backs already skip transient windows. - A declared shader write to a transient window (unordered access, a title buffer copy on the card, title memory by address) is already a bug that is counted and logged (`Shadow::transient_written`). Such a window compares nothing from then on and sends everything it takes. - A page taken only in part loses its print, because the card then holds bytes from two reads. A window made again starts with no prints. The print is taken from the exact bytes that are sent, never from a second read. - The prints stay locked from the read until the chunks are noted, so with refreshes running in parallel, a print is always the one of the last chunk noted for its page. Remaining risk: two different pages with the same 64-bit print (about 2^-64 per compare) would leave the older bytes on the card until the title writes the page again. The default does not change. Unset only samples and sends everything as before, and the launcher's set is not touched. `1` is for whoever wants to try it. Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), on upstream `main` at `c4c93bd`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished, no new warning VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --lib -- --test-threads=1 -> 187 passed, 3 failed ``` The 3 failures are those of `main`: `spans_say_the_next_start_and_the_lowest_level_viewed`, `warp_card_fetch_copies_flagged_pieces_to_their_slots`, `warp_card_patch_writes_the_masked_bytes_and_no_others`. 4 new tests, CPU only (`shadow::window_same_tests`). None of them builds without this change: - `a_print_changes_with_any_change_of_the_page`: every single-bit flip, word swap, stripe swap and block swap of a page changes its print. - `a_page_is_the_same_only_after_the_same_bytes_were_taken_whole`: same, other, nothing to compare with, and a page taken in part keeps no print. - `the_card_side_holds_the_titles_bytes_with_the_same_pages_left_out`: a model of a window against a fake card side. It runs fixed cases and then 300 random rounds of writes, set-backs and partial ranges, and after each refresh checks that the card side equals title memory over the refreshed range and that only the pages that changed were sent. With the same pages sent again (a temporary mutant in `window_copy`) it fails: 1,048,576 bytes sent where 0 were expected. - `one_page_in_sixteen_is_compared_and_counted_sixteen_times`: the sample without the switch. In the world of GTA VI (my own copy), running as a Series S (`--console series-s`, 1280x720), launcher set with #308 and `VICTORY_INDIRECT_RAW=3`, the same exe both ways, runs of 300 s alternating: | `VICTORY_WINDOW_SKIP_SAME` | fps (median of the last minute) | |---|---| | unset | 18.5 (machine 54 % loaded, not trustworthy), 20.1 | | `1` | 20.7, 21.2 | Of the bytes the transient windows took per frame, 67-73 MB held what the window last sent for their 4 KiB page, 0.9 MB differed, and 3.6-4.1 MB had nothing to compare with. With `1`, those ~70 MB a frame were left out. No exception and no device lost in the 4 runs. With a single trustworthy run without the switch, the frame-rate gain is small (20.1 fps against 20.7 and 21.2). The firm part is the bytes left out. The exe of these runs was built from the branch this PR comes from. That branch has the same skip code on top of a wider counter line and another switch that is off by default (`VICTORY_REFRESH_4K`, not set in these runs). This PR carries only the skip and the windows' part of that line. ## Oracle and test data No game file. The counts and frame rates come from my own runs of my copy of the game. The tests use generated bytes. ## Checklist - [x] The PR covers a single reviewable behaviour (transient windows leave out the 4 KiB pages that hold what they last sent, behind a switch that is off by default). - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Nothing unimplemented here.) - [x] README: not touched. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: frame rates and byte counts of my own runs; no title code. - [x] Code taken from another project: none (the print follows the shape of XXH3's accumulate; no code from it). AI assistance: written with Claude Code. Claude Opus 5.5 subagents designed and wrote the change and its tests, ported it onto `main` for this PR and wrote this description. Claude Opus 5.5 (coordinating) ran the game A/B. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The windows without a CPU side (VICTORY_CARD_WINDOW_UPLOAD=1) copy every page the
write watch or the guards name into an upload chunk and send it up whole: some
70 MB a frame in the world (Series S run, 20 fps). A page written need not hold
other bytes; nothing compared them.

Each such window now keeps a 64-bit print of the bytes it last sent for each
4 KiB page (an XXH3-style accumulate of eight lanes, some 40 GB/s on one core;
8 bytes a page). With VICTORY_WINDOW_SKIP_SAME=1 a page whose bytes give the
same print is neither copied nor sent: title memory is read 256 KiB at a time
into memory of the thread's, printed, and each run of other pages goes into a
chunk of its own. The card side still holds those bytes: nothing but the
window's sends writes it, in the order they were copied; a page sent only in
part keeps no print; a window made again starts with none; and a window that
shaders are said to write (unordered access, a title buffer copy on the card,
title memory by address: a bug, counted and logged) compares nothing from
then on.

Unset (the default), the pages are sent as before and one 4 KiB page in 16,
picked by its address, is read again and compared, so the new line can say how
much of what the windows send is the bytes they sent last time.
VICTORY_WINDOW_SKIP_SAME=0 compares nothing (the code path as before). The new
line, with the frame-rate line while there are transient windows, gives what
they took per frame: sent up and left out, and of it the bytes that held what
the window last sent, other bytes, and nothing to compare with. The ram line
gives the prints' memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:29:02 +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/340/head:github-bot/gh-340'
git switch 'github-bot/gh-340'

Merge

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