Repository navigation
Conversation
After a submission, a page shaders wrote goes back into title memory. For marked pages (views) and pages written at computed addresses that was the whole page: read title memory, compare, then write the copy's 64 KiB over it. The title's threads write the same pages meanwhile (its GPU heap holds CPU records next to what shaders write), and a write that landed after the read was undone by the copy's older bytes. The page was then taken with those bytes, so the copy kept them for good, and a later copy-back of the page put them back over the title's again. Now only the runs of bytes the shaders changed are written (runs less than 256 bytes apart as one span, with the title's bytes between them as read: a kernel copy per run cost over 1 ms per page). The page is armed while it is read, so a title write that lands during the read saves the bytes from before it and the shaders' bytes are told apart from the title's. After the copy-back the page is taken first and the copy reads it again, so a title write before the guard is back is in the copy and one after it faults. The snapshot path writes only the bytes the GPU changed as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding the bytes the GPU changed in a copy-back compared 8 bytes per step, a call each: ~30 us per 64 KiB page, the largest part of the copy-back of the pages shaders mark (~2,250 per world frame). Equal blocks of 1 KiB are skipped whole, then 32-byte lines inside a block that differs, bytes only in a line that differs; the runs found are the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The copy-back of each page shaders marked as written through views read the page, compared it, copied title memory's bytes over the copy outside the changed runs, and took the page and read it again whole. In the world about 2,150 pages a frame are marked and a third of them hold no changed byte. - Without bytes saved by the guard, the runs are every byte that differs, so the copy's other bytes are title memory's already: they are not copied over again (a 64 KiB write per page). - A page neither we nor the title wrote during its copy-back is still taken and guarded: it is not taken and read again. - Title memory is read into a reused buffer, not a fresh zeroed one per page. - The scan of the bitmap skips zero words instead of writing each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catminou4
left a comment
There was a problem hiding this comment.
Marked-page copy-backs skip work that changes nothing — but note this re-adds the same BLOCK/LINE differing as #2280 (stacked on #2242). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. If this supersedes the #2242/#2280 stack, say so; otherwise they conflict in shadow.rs.
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:
- Skipping no-op marked-page copy-backs cleanly preserves unchanged pages and passes all shadow tests on RTX 5090 and WARP.
cargo test -p victory-gpu shadow::: 7/7 passed on RTX 5090, 7/7 passed on WARP (includingdiffering_matches_a_byte_wise_comparison,a_copy_back_puts_back_only_the_bytes_the_gpu_changed, anda_marked_page_the_shaders_left_alone_stays_taken).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.
AI-assisted (Gemini 4 Neon).
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
|
Reviewed the rewrite against the invariants the marked-page path needs — it holds up:
Two triage notes:
|
|
Setup: RTX 3080 Ti (driver 621.24), Windows 11, a local stack of open PRs merged with main 67e8ae1. b6e75cf has one conflict on a tree with two written-mark bitmaps (the title Written with Claude Code; tested locally. |
Stacked on #2280 (
gpu/copy-back-block-compare, itself on #2242); only the last commit is new. It does not need #2175: the marked-page path here uses the views' bitmap inshadow.rs, not the page-table bitmap #2175 moved.What
After a submission, every 64 KiB page shaders marked as written through views (
copy_back_marks→Shadow::copy_back_marked) is read from title memory, compared with the copy, and taken again. In the world that is about 2,150 pages per frame, and about a third of them hold no byte that changed. Four changes, all incrates/victory-gpu/src/shadow.rs:differingruns over every byte where the copy and title memory differ, so outside the runs the copy already holds title memory's bytes.take_others(a 64 KiB write per page) now runs only when saved bytes exist.Vecper page.Behaviour stays the same. The saved-bytes path, pages the title wrote, and pages the copy only partly holds all go through the same code as before.
Measured (Windows 11, NVIDIA RTX 5090)
Same 300 s world run before and after, on an integration build with the GPU-upload copies switched on. Figures are medians of the 5 s frame lines from 150 s on (n=26 each):
No device removal, no access violations, and captured world frames look the same as before.
Not done: finer write marks
I also tried marking 4 KiB blocks instead of 64 KiB pages (shader shift 12, a 2^24-bit bitmap, and a copy-back that reads and compares only the marked blocks of each page). Shaders mark about 28,400 of the ~34,400 blocks in the marked pages (83%). About 16,100 of those blocks actually change, and a third of the marked pages are written with identical bytes. So the compare barely shrinks. GPU time went up about 7 ms (91.4 vs 83.7) from the extra atomics, and copy-back came out at 124.7 ms, worse than this PR's 116 ms. I left it out.
Tests:
cargo test -p victory-gpupasses, plus the newa_marked_page_the_shaders_left_alone_stays_taken. Two tests also fail on the base on this host, unrelated to this change:dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views. The view heap has 1M descriptors on NVIDIA, belowHEAP_VIEWS. Clippy (victory-gpu,victory --features diagnostics) with-D warningsandcargo xtask policyboth pass.🤖 Generated with Claude Code