Streaming stores for the big copies of the preparing thread (snapshots, sends to card copies, refreshes) #98
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!98
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-98"
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?
@Joly0 on GitHub · 2026-11-26 03:23 UTC · original
Joly0:pr/streaming-copies→main· +306 −7 · 3 files · 3 commits · openWhat
Three commits on
c9c932c. Each copy path has its own switch, and both are off by default: unset, everything copies as before.VICTORY_STREAM_COPY=1turns it on). The snapshots of the ranges shaders may write (about 90 MB a frame) and the bytes of copies in the card's memory sent through upload memory are written with AVX2 streaming stores when a copy is 4 KiB or more.VICTORY_STREAM_REFRESH=1turns it on).safecopy::copy_streamingworks likesafecopy::copy, with streaming stores. A fault goes to its failing exit, and a guard page it hits keeps its guard flag, through the same handler as the other copies (fa11650).Shadow::copyuses it for copies of 4 KiB and more. A copy that fails is done again the old way, and every other caller ofcopy_mappedis unchanged.Why
On the PC this was measured on, the limit is memory writes, not threads. Copies of 512 MB, with nothing else running:
memcpy/rep movsbA plain copy reads every destination line before writing it. These destinations are not read by the CPU again soon: snapshots are compared only after the card has run, and upload memory and host copies are read by the card. So skipping that read is a good fit.
Measurements
Only one PC: RX 7800 XT 16 GB, i9-12900K, 32 GB DDR5-5200 (2 × 16), Windows 11, the settings of
scripts\play.ps1. Each switch was flipped within one run withVICTORY_AB, so both sides saw the same scene.On this branch (
VICTORY_AB=10,VICTORY_STREAM_COPY,VICTORY_STREAM_REFRESH: all four combinations in turn, 240 s, no errors). In the stable part, about 4,900–5,100 draws, median frames were:VICTORY_STREAM_COPY: 60.9 and 59.2 ms;VICTORY_STREAM_REFRESH: 61.0 and 63.2 ms;That is one or two phases per combination, so it is a rough picture; the refresh switch alone shows no clear gain there.
Earlier, before the rebase:
VICTORY_STREAM_COPY(VICTORY_AB=8,VICTORY_STREAM_COPY), about 900 draws: median frame 34.2 ms with it (35.2, 34.1, 34.0, 33.9, 34.0) and 37.3 ms without (37.8, 36.5, 36.8, 37.5, 37.7). The snapshots took 5.4–5.9 ms of the preparing thread instead of 7.0–7.9 ms.VICTORY_STREAM_REFRESH(VICTORY_AB=10,VICTORY_STREAM_REFRESH), 3,000–6,000 draws: in each pair of neighbouring phases with similar draw counts, the refreshes took less with it (15.3 → 13.2, 17.0 → 14.8, 15.3 → 14.6, 27.0 → 22.8 ms) and the median frame was shorter (77.5 → 71.6, 67.8 → 66.2, 64.1 → 63.1, 81.5 → 78.2 ms). That is about 1–2 ms; most of a refresh's time is asking the write watch, not copying.The gain may be smaller on a PC with more memory bandwidth, such as a 7900 XTX with 64 GB. One run with
VICTORY_AB=10,VICTORY_STREAM_COPY,VICTORY_STREAM_REFRESHshows all four combinations there.Tests
shadow::wide_tests::a_streaming_copy_copies_the_range_and_nothing_beside: lengths and alignments of both sides, and no byte written outside the range. It streams whatever the switch says, and asserts that AVX2 is there.safecopy::tests::streams_every_length_and_alignment.safecopy::tests::a_stream_from_missing_memory_fails: a source page missing or not readable in the head, the blocks or the tail.safecopy::tests::a_guard_page_fails_the_streaming_copy_and_stays_a_guard_page.0x80000001for the guard test);cargo test -p victory-gpu --features diagnosticson WARP: 436 pass, which is main's 432 plus the 4 new ones.depth_bounds_pipeline_loads_and_filters_drawsfails on main too.watch::port7_tests::no_write_is_lost_with_port_7failed once in a full run and passed 3 of 3 alone, on main and on this branch. I did not run the whole workspace.--all-targets, with and without--all-features): 1 finding each, the same as main.🤖 Generated with Claude Code
@HrHd on GitHub · 2026-11-26 06:26 UTC · original
Took both commits of this onto the
-Safeset of an 8 GB / 15.7 GB box and measured, with a 2 s process watcher rather than sampled looks:0x8007000Eatmake_prelude), so the streaming copies do help there;0x8007000Efrom the fetch of what shaders wrote ("what shaders wrote to the card's memory could not be fetched") on-Safe, and with0x887A0006(device removed) on the fast path;VICTORY_CARD_WINDOWS_MB=4 VICTORY_MEMORY_CARD_MB=2048 VICTORY_KEEP_SNAPSHOTS_MB=4, withCARD_BUFFERS_MIN_MB=1) did not change that either way.That matches
#124's finding that the fast paths want more desktop VRAM than 8 GB and that the failure comes back whatever the switches; this PR still removes one of the two walls, so it looks worth having.github-bot referenced this pull request2026-11-26 06:46:47 +00:00
@avatarmanz on GitHub · 2026-11-26 07:33 UTC · original
Left open: conflicts with main (safecopy.rs), and the streaming stores are on by default; needs a rebase and an in-game check on the 7900 XTX.
9a3006bb52to0d87742f23@Joly0 on GitHub · 2026-11-26 16:57 UTC · original
Rebased onto
c9c932c, and the streaming copies are now off by default.Conflict: the only conflict in
safecopy.rswas in the tests (changed_records_are_found_and_takenlanded where the streaming tests go); all of them are kept.Guard pages (
fa11650): the streaming copy is registered infailing_exit, so a guard page it hits gets its flag set again by the same handler as the other copies. A new test checks this:a_guard_page_fails_the_streaming_copy_and_stays_a_guard_page. Without the failing exit, the test process dies of the guard fault (0x80000001).Off by default (new third commit):
VICTORY_STREAM_COPY=1andVICTORY_STREAM_REFRESH=1turn them on; with both unset the copies are as before. The description above still says "on by default" and=0; read it with that in mind.Checks on this branch:
cargo test -p victory-gpu --features diagnosticson WARP: 436 pass, which is main's 432 plus the 4 new ones.depth_bounds_pipeline_loads_and_filters_drawsfails on main too.no_write_is_lost_with_port_7failed once in a full run and passed 3 of 3 alone, on main and on this branch.--all-features, the same as main.Game run: one 240 s run on an RX 7800 XT with
VICTORY_AB=10,VICTORY_STREAM_COPY,VICTORY_STREAM_REFRESH, which cycles through all four combinations; no errors. In the stable part (about 4,900–5,100 draws), median frames were:That is one or two phases per combination, so it is a rough picture; the refresh switch alone shows no clear gain there.
The same
VICTORY_ABsetting should give the 7900 XTX check in a single run.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.