Repository navigation
Conversation
The snapshot that tells what the GPU wrote covered a buffer copy from the first declared range to the last, in buffers the submission grew, copied and freed. Each declared byte is now kept once, in one block of memory that is reused: in a looped world frame this saves about 270 ms of submission work. A copy dropped with a range not copied back gives its part up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verified on Win10 21H2 / RTX 3080 (driver 621.24) stacked with #986 and #1260: the 174 MB heap-union re-copy was a large part of the ~400 ms/frame copy cost; with this the world runs ~20 fps with no device removal. Combined result on #986. AI use: Qwen Code (model name not disclosed); user-confirmed. |
|
Merged at The conflict. The tester tree has #261's
Without In the title: diagnostics build, DRED off, same settings and save for both runs. Frames are binned by draws per frame because the runs weren't in the same scene at the same time:
Most of the gain is copy-back, about 190 ms down to about 125 ms per frame. No device removal in either run. AI-assisted (Claude Code). |
|
Thanks both for merging and measuring this, and @ChruutvoLuzi for tracing the |
|
Linux + Proton + NVIDIA RTX 5080 runtime data point (filling in the "NVIDIA / Linux and Proton / in-game frame time" items in Note on attribution: I stacked Setup
A/B comparison on the same machine & setup (
Observations
AI-assisted log analysis and summary; built and run locally on my own retail copy, no game files or raw logs attached. |
|
Measured with the benchmark in #1743, which replays a world frame's refreshes, snapshots and copy-back on a made-up 174 MB heap (36 submissions, 24 overlapping declared ranges each). This PR was merged alone onto
|
Main's copy-back of each 64 KiB piece once per submission, writes that stay in the copy and the copy counters are kept; the snapshot segments become the parts of this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main in (fast-forward): its compared-once set, kept writes and counters stay, its snapshot segments become this PR's parts. 1277 perf/view-memory-cache : DROP (reported only, not closed)No local ref. Main's new change tracking asks about the memory once per host copy (watch::track), not at each check: the cost this PR removes is gone, and the function it changes (guard) no longer exists. 1010 perf/user-mode-title-copies : PUSHlocal ref: prready/1010 (caa937c), GitHub head 79c9b93 139 perf/shader-address-sums : PUSHlocal ref: prready/139 (90cf2f6), GitHub head 697c4bc 999 perf/shader-lane-condition-search : MERGED, CENSUS BEFORE THE PUSHlocal ref: prready/999 (255377d), GitHub head 3ca9456 No push needed (mergeable, no failing check, no open question)prready/1000, 993, 188, 172, 153, 126 = head + main, only to prove that they merge and build: do not push. Worktree: C:\Users\theo_\victory-prs (detached at origin/main). |
|
Automated triage for the maintainers. This pull request does not merge cleanly into It will be reviewed once it is rebased onto the current Generated by Claude Code |
… per submission Snapshots of shader-written ranges shared one reused block per submission (SNAPSHOTS) instead of a 2 GiB POOL of per-copy segments: each declared byte is kept once, nothing between ranges. Ported the update_busy hunk (title writes under busy ranges) to the new Part representation; conflicts none. From TG0000/perf/declared-snapshots.
The bytes a refresh puts into a busy range go into the parts kept for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… queue\n\nUpstream cd94d35+940d32f: translated shaders mark the 64 KiB pages they\nwrite through unordered buffer views (tables, heap, root UAVs) in a\nper-copy bitmap; copy-backs compare/write only marked pages instead of\nsnapshotting+comparing declared GBs. Our live logs showed exactly that\nbottleneck (2.5-3.8 GB snapshots + 2.3-3.9 GB compares per frame).\n\nPort notes (no accuracy change, our faster paths kept):\n- Marvisak#1267 Part-based snapshots kept over upstream segments; writing()\ngains the marked fast path (arm, no snapshot) with our parallel fill on\nthe unmarked path; Drop merges snapshot-forget and mark give-back.\n- copy_back_marks runs before our parallel run_back loop (marks first,\nloop disarms — upstream order); back-loop destructuring unchanged.\n- copy_back gains upstream disarm; marked entries find no snapshot\nparts and skip, as designed.\n- Tests: kept buffer_states test (new() now returns Arc); ours +\nupstream marked tests updated to 3-arg writing(); fuzz/valu helpers\ngain view_marks fields per upstream pattern.\n- Cache safety verified: shader disk cache folders key on translator\nsources, pipeline names hash root-sig+code, prebuilt tag covers\nSOURCE_HASH — old no-marks entries cannot be served. Marvisak#1824 opcode-key\nfix intact in the rewritten op cache.\n- First run after this rebuilds shaders+pipelines (new keys); measure\nsteady state on the run after.\n\nVerified: gpu 161 + full workspace suite green, clippy --all-targets\n--all-features -D warnings clean, policy 186 ok.
|
Merged main 940d32f in (fast-forward). Two things of main are kept with it: ranges whose shaders mark their writes take no snapshot, and what a refresh puts into a busy range now goes into the parts kept for it (that code merged without a conflict but used the old segments). Because marked ranges take no snapshot any more, what is left to gain is smaller than in the description. Neither the benchmark nor the frame time was measured again on this head. Windows (RX 6800 and WARP, one thread): victory-gpu 147 and victory-shader 247 passed; clippy |
Why
Before a submission's shaders run, the copy of a buffer is kept so that copy-back can tell what the GPU wrote. The snapshot covers everything from the first declared range to the last. World frames declare ranges that are far apart, and overlapping ones, in a 174 MB heap dozens of times, so most of what is copied is never written, and each new range copies the whole union again.
What
Measured
Time of a looped world frame's submissions (preparation, GPU, copy-back), all ways in one launch (RX 6800, Windows; 8 frames, each repeated with every way; a frame has 36 submissions). This is not frame time, and nothing here is an fps claim. One launch, one area of the world, in a build of
main(ffe310e) with measuring tools and other local changes, the same in every row; about 1,400 of 5,000 draws a frame are still dropped there.mainThe last row is the median of the paired differences, the range is over the 8 frames. A control (the same switches in another order) differed by 9 ms.
Other ways to make the same snapshots cheaper, as my own ports into that tool, 2 frames only, so a hint and not a result: with this change 307 ms, with #440's in its place 464 ms, with #991's 469 ms. These are ports of other people's pull requests; their authors' code may do better.
A model (only the memory copies of each way, with 64 distinct ranges declared 4 times each in a 174 MB block, not the code itself):
main785.5 MB, 68 ms; #1186 at c1dd5b1 8,363.5 MB, 658 ms (it lost the early return for a range the snapshot already covers); this change 16.0 MB, 2.6 ms.Tests
shadow::snapshot_tests): each declared byte once; only changed declared bytes come back; a dropped copy leaves no snapshot; two copies in one submission do not share theirs. The last two fail without theDrop.cargo test --workspace --locked, clippy with-D warningswith and without--all-featureson Windows, clippy on macOS: pass at 4cefaac (346 tests).frame::tests::waits_end_on_ticks_and_count_framesmeasures time: it failed in two runs while a game ran beside it, passes 10 of 10 alone onmainand here, and the run counted above is clean.main's way and this one: title memory and the copies are byte for byte equal in every run, with the writes as recorded and with random ones added (shader writes, undeclared host writes, title writes before copy-back). Seven sets (no change, each of five, all five), 504 runs, 34.7 GB compared, with synthetic overlapping declared ranges too: 0 differences; 0 snapshots left over. Three deliberate faults put into this change are all found with the overlapping ranges (two of three without). The set covers only one frame, and title writes come before, not during, the copy-back.Not handled on purpose
A list reset while its submission is in flight keeps its snapshots until the copy is dropped.
executereturns only after copy-back, inside the title'sExecuteCommandLists, so such a reset is already an error and ends infail(); dropping parts fromreset()could take those of another submission that has the same range.Overlapping copy-backs can replay an earlier CPU edit; that is so on
mainand unchanged here (#1186 is about it).Not verified
Conflicts
shadow.rsconflicts with #440, #991, #1124 and #1186; the other open pull requests that touch this code (#943, #1010, #1024, #1215) merge cleanly.AI-assisted (Claude Code).
🤖 Generated with Claude Code