GPU: a marked page goes back at its first access (VICTORY_LAZY_COPY_BACK) #3118
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!3118
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3118"
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?
@borosf on GitHub · 2026-11-26 08:44 UTC · original
borosf:vibe/lazy-copy-back-842ca5→main· +348 −9 · 3 files · 5 commits · openSummary
Shadow::copy_back_markedbrings every page its shaders marked as written back into title memory — on the card that is 60–127 ms a frame, 95 % of it waiting (FIND-33: the snapshot's pages fetched, and the waits around them; the host-side merge is 2.4–2.9 ms, the write 0.4–0.5 ms). The world marks ~2,250 pages a frame; most are never read by title code before a later pass overwrites them.VICTORY_LAZY_COPY_BACK=1(opt-in, off by default — behavior is unchanged without it), a marked page leaves the submission sealed no-access. The first read faults that one page back; the first write faults it back and then lands as the title's own over it (the merge happens underneath, as eager copy-back would have); a page nothing touched is written by the next submission's copy-back and never holds the critical path.watch): sealed pages holding their copy alive, and the vectored handler — which today services write faults — also taking read faults on those pages, servicing exactly one page each time. Arming is oneVirtualProtectper run of pages.Shadow::update,copy_back,copy_back_page), writes the guards do not see drain before they mark (watch::writing— kernel reads, DirectStorage), and remaps, retakes and new aliases drop the wait and unseal (title_memory_remapped,retake,title_memory_aliased). In-process reads of a sealed page fault into the handler and service transparently.Verification
-D warnings,cargo test --workspace --locked); with the switch off the suite is unchanged.marked_pages_leave_the_submission_and_go_back_at_their_first_accessdrives the real fault handler on the Intel Arc B580: the submission leaves pages sealed (asserted viaVirtualQuery, arming counters(3, 0, 0)— sealed, none refused), aread_volatilefaults the GPU's byte back and the page is guarded again, awrite_volatilemerges underneath and lands on top, an untouched page is written by the next copy-back, and the ledger ends empty.cargo clippy -p victory-gpu --all-targets --locked -- -D warningsclean;cargo test -p victory-gpu --lib --lockedgreen except the two known Intel heap-cap failures (#1744) pristine main also fails.claiming: FIND-33 — lazy copy-back on read (marked pages go back at their first access), the 95 %-wait copy-back stall (#1633 comment, per the ledger)
@Dukestar69 on GitHub · 2026-11-26 08:48 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11/11 passed on RTX 5090 and WARP (includingmarked_pages_leave_the_submission_and_go_back_at_their_first_access).cargo test -p victory-gpu --lib watch:: -- --test-threads=1: 15/15 passed.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed on RTX 5090.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Clean opt-in
VICTORY_LAZY_COPY_BACKmechanism deferring marked-page copy-backs until first CPU access.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.