GPU: marked-page copy-backs skip work that changes nothing (stacked on #2280) #2409
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2409
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2409"
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?
@wbkepler on GitHub · 2026-11-25 13:07 UTC · original
wbkepler:gpu/marked-copy-back-lean→main· +332 −62 · 1 files · 3 commits · openStacked 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
@Marvisak on GitHub · 2026-11-25 15:31 UTC · original · edited 2026-11-25 16:04 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/shadow.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 16:55 UTC · original
Reviewed the rewrite against the invariants the marked-page path needs — it holds up:
arm(from,to)before the read +unarmbefore the write is the right ordering: a title write landing during the armed read gets its old bytes saved, sodiffering(host,title, |i| host[i] != before[i])correctly identifies "bytes the GPU wrote" rather than "bytes that differ now" — the write-then-read race that whole-page put-back got wrong.write_runs(span merge at 256 B) +take_others/take_and_readpreserve the post-write copy state — including the re-read that picks up title writes racing the put-back, which is what #2437 does forcopy_back_marks.write_mappedand the re-take — consistent with the measured ~1/3 unchanged rate and the reported ~24 ms/frame win at ~2,150 pages.Two triage notes:
writing(at, merged.len())suppresses the watch across the whole range while only spans are written — a racing title write in a gap would be read as ours. Harmless for correctness (the re-read picks it up) but it can skip achangedmark; same exposure as before, now slightly narrower.saved-vs-gpudistinction is the part worth keeping from this set.@Machad3x on GitHub · 2026-11-25 18:26 UTC · original
Setup: RTX 3080 Ti (driver 621.24), Windows 11, a local stack of open PRs merged with main
67e8ae1.b6e75cfhas one conflict on a tree with two written-mark bitmaps (the titlememory one apart): there only the skip of empty mark words is needed in the
scan.
victory-gputests pass and an 8-minute game run had no device removal.Written with Claude Code; tested locally.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.