perf: transient windows leave out pages that hold what they last sent (VICTORY_WINDOW_SKIP_SAME) #340
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!340
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-340"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Skyfrye on GitHub · 2026-11-26 08:25 UTC · original
Skyfrye:nep/window-skip-same-pr→main· +582 −7 · 4 files · 2 commits · merged 2026-11-26 14:21 UTCChange
VICTORY_WINDOW_SKIP_SAME, a new switch whose default (unset) sends what was sent before. WithVICTORY_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 ispage_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_SAME10A 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'swindow upload:part also gives the prints' memory.Why the card side still holds a page that was left out:
Host::card_beforecopies them in the order they were copied. The dirty and masked-patch path, the merges and the copy-backs already skip transient windows.Shadow::transient_written). Such a window compares nothing from then on and sends everything it takes.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.
1is for whoever wants to try it.Linked issue: none.
Verification
Windows 11 26300, Rust 1.98.1 (MSVC), on upstream
mainatc4c93bd, fromthird_party/victory: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 inwindow_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 andVICTORY_INDIRECT_RAW=3, the same exe both ways, runs of 300 s alternating:VICTORY_WINDOW_SKIP_SAME1Of 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
E_NOTIMPL), never a fake success. (Nothing unimplemented here.)AI assistance: written with Claude Code. Claude Opus 5.5 subagents designed and wrote the change and its tests, ported it onto
mainfor 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 10:43 UTC · original
Back to draft: do not merge. Looking at the window (Series X, first cutscene, build = main
c4c93bd+ #308 + this PR,VICTORY_INDIRECT_RAW=3): withVICTORY_WINDOW_SKIP_SAME=1a rectangle of multicoloured noise covers a character's face; the same build and scene without the switch draws the face correctly. So a page left out is not always one the card already holds (the comparison with what the window last sent misses something, likely what the card side holds after other writes). Also, the frame rates in the description were measured with--console series-s, which draws only the UI (the 3D scene is black, see #338), so they do not show a gain. I judged those runs by the frame log alone; that was wrong.🤖 Generated with Claude Code
@KainanP on GitHub · 2026-11-26 10:55 UTC · original
Test report for #340 on three adapters.
Merges cleanly onto current main. Setup: current
origin/main(afa30ce) merged with this PR, Windows 11,cargo test --lockedinthird_party/victory. Nothing underthird_party/victorychanged sincec4c93bd, so the main column is c4c93bd's run. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is--features diagnostics+VICTORY_D3D12_WARP=1. victory-gpu runs with--test-threads=1.victory-gpu --lib"main's 3" =
descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed,indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots,indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others. They fail on all three adapters on main too. The 4 newshadow::window_same_testspass everywhere (CPU only). No new failure, no new warning.Notes from reading the diff:
Sample, not the old path. Each transient window gets a prints table at its first copy, and after each copy one page in 16 is read again and printed. So the bytes sent change only with1, but unset adds CPU work and memory to the launcher's set (it hasVICTORY_CARD_WINDOW_UPLOAD=1).0is the old path. If the sample only feeds the new line, a default of0(sample on request) would make "the default does not change" literally true.Samplethe print comes from a second read (window_sample→read_into) aftercopy_mappedinto the chunk, so the title can write between them. That only skews the counts:Samplenever leaves a page out, and the mode is read once. The description's "never from a second read" holds for1only.Skip, acopy_mappedread that fails leavesscratchwith the previous block's bytes (the buffer is thread-local and not cleared). The page is then printed and sent with those bytes. Before, the chunk held "whatever", so this is not worse, but now the print records those bytes as sent. Zeroing the block before the read, or setting the page's print to 0 when the read fails, would keep the print honest.printsstays locked acrosswindowup::allocand the chunk copies for the whole range. That serializes two refreshes of one window, which is what keeps the order right. One line saying so incopy_to_chunks_skippingwould stop a later change from narrowing the lock.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.