Repository navigation
Conversation
A page only partly inside a requested range was copied in part and never marked as copied, so every later range in the same page copied it again. With many small, unaligned ranges in the same pages (directly indexed SRVs in Marvisak#185, close to a million per world frame) this came to about 11 GB of copies per frame. Widen each range to its first and last pages' bounds (within the buffer) when no pending range overlaps what that adds, so the page is marked and copied again only after the title writes to it. Next to a pending range the old behaviour stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update: #185 has since been reworked (8 more commits, 04:04–04:57 UTC, after this PR was opened). Its Measured on the same machine and input (RTX 5080, Linux / proton-cachyos, world frames, median over the same window after world entry, with #493 in all three):
So if #185 lands as it is now, this PR is not needed and I'd close it. It only still helps AI-assisted (Claude Code). |
|
Merged onto This is not GPU-specific, so CI should show it too on the next push. Checked with CI's steps (both clippy runs with |
Status (2026-11-24): not needed if #185 lands as it is now. #185 was reworked after this PR was opened; its
copy_stalekeeps exact partial-page coverage, which does what this PR does more precisely, and the two conflict incopy_stale. Measured (world frames, median): old #185 6.1 s, old #185 + this and #462, #515, #600 4.3 s, new #185 alone 2.9 s. This PR only still helpsmainwithout #185. Details in the comments below; the rest of this description is as written before.Problem
Shadow::copy_stalecopies a 64 KiB page that is only partly inside the requested range in part, and never marks it as copied, so every later range in the same page copies it again. With few, large ranges that costs little. With many small, unaligned ranges in the same pages it dominates: #185 refreshes directly indexed SRVs before each submission (close to a million ranges per world frame), and there it came to about 11 GB of copies per frame.Change
copy_stalewidens the range to its first and last pages' bounds (within the buffer) when no pending range (shaders of a submission may be writing there) overlaps what that adds. The page is then marked and copied again only after the title writes to it. Next to a pending range the old behaviour stays.Measured
RTX 5080, Linux (proton-cachyos, vkd3d-proton 3.2.0), Series X 1.0.2.1. Diagnostics build of
maind2a4bae+ #185 + #259, #177, #151 (needed to reach the world here), with this change on and off in the same binary (a local switch), one 7 min run each, Enter into story mode at about 35 s, numbers from the first 2–3 min in the world:untracked_filled_mb)Xid 109(CTX SWITCH TIMEOUT) about 3 min into the world, then the title's watchdog crash (without #493; see the note above)mainalone this is not measured. World on an RTX 5070 Ti: where the ~0.8 s per frame go, and four open copy PRs measured against main #400 reports 25–29 GB requested per world frame there, mostly unchanged; how much of that this saves is open.Related
Shadow::writing,copy_back); same file, different functions.main(Windows, RTX 5070 Ti), including how much of each world frame goes to refreshes.Tests
Two tests in
shadow.rs: small ranges in one page copy it once (and again after a title write), and edge pages stay cut next to pending writes (the copy's GPU-written bytes are kept). Both fail without the change (16 bytes copied instead of 65,536, and 16 instead of 32).victory-gputests under Wine: the same 4 unrelated tests fail with and without it (watch::tests::written_pages_are_reported_to_every_asker,resource::tests::buffer_data_reaches_the_host_texture,indirect::tests::argument_clamp_builds,pipeline::library::tests::a_rejected_blob_gives_an_empty_library).AI-assisted (Claude Code).
🤖 Generated with Claude Code