hle(xmem),gpu(watch): mark decommitted and released pages written in watch journal #147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/147"
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?
Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T16:08:45Z.
Problem
When a title decommits or releases virtual memory via
VirtualFreeorXMemFreeDefault, Windows does not set write-watch dirty bits for those pages (nor when zero-filling pages upon later recommit). As a result, host copies tracked byvictory-gpu::watchcan retain stale non-zero contents after memory is freed and reallocated/recommitted.Changes
crates/victory-gpu/src/watch.rs&crates/victory-gpu/src/lib.rs:title_memory_decommitted(at, len)to mark decommitted/released pages as written (WHOLE) in the watchJournal(intersecting liveshadow::spans()for very large region releases exceeding1 << 18pages).many_askers_tests::title_memory_decommitted_marks_pages_written_in_journal.crates/victory-hle/src/modules/xmem.rs:HOST_PAGE,host_pages,allocation_span, andfreed_spanhelpers to resolve the exact byte span affected byVirtualFreedecommit/release calls (ignoring placeholder split/coalesce and invalid flag combinations).victory_gpu::title_memory_decommittedafter successfulVirtualFreeintitle_virtual_freeand theALLOC_32BITrelease path ofXMemFreeDefault.tests::freed_span_covers_decommits_and_releases_without_placeholders.Verification
Ran locally on
feat/iter148-xmem-decommit-dirty-and-live-commit:cargo xtask policy:304 files okcargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle xmem:: --locked:26 passed; 0 failed; 1 ignoredcargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu watch:: --locked -- --test-threads=1:50 passed; 0 failedclippy --all-targets -- -D warnings(default and--features diagnostics): 0 warningsImported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T16:16:08Z.
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
Logic and safety look solid, CI is passing, and both crates include targeted unit tests covering the new behavior.
What was checked
crates/victory-gpu/src/watch.rs&crates/victory-gpu/src/lib.rs:title_memory_decommitted(at, len)marks affected 64 KiB watch pages asWHOLEinJournalunderjournal_mut(), advancesj.ahead_askedtonowso activeask_aheadreaders stay consistent with the new stamp, and falls back to intersecting livecrate::shadow::spans()when the span exceedsMOST(1 << 18pages = 16 GiB).many_askers_tests::title_memory_decommitted_marks_pages_written_in_journalverifies the journal stamp advances past the priorwrites()ask stamp.crates/victory-hle/src/modules/xmem.rs:host_pages,allocation_span, andfreed_spanaccurately resolve the byte range affected byMEM_DECOMMITandMEM_RELEASE(both sized and zero-sized) while ignoring placeholder split/coalesce (MEM_PRESERVE_PLACEHOLDER,MEM_COALESCE_PLACEHOLDERS) and invalid flag combinations.title_virtual_freeand theALLOC_32BITpath ofXMemFreeDefaultcapturefreed_spanbeforeVirtualFreeand callvictory_gpu::title_memory_decommittedonly whenVirtualFreesucceeds (ok != 0).XMemFreeDefaultalso now callsvictory_gpu::title_memory_freedbefore releasing.tests::freed_span_covers_decommits_and_releases_without_placeholdersexercises the span helpers across commit/decommit/release/placeholder cases.Minor non-blocking notes
allocation_spanincrates/victory-hle/src/modules/xmem.rsuses plain+(info.BaseAddress as usize + info.RegionSize) andtitle_memory_decommitteduses(start + bytes) as usizein the> MOSTbranch;saturating_add(matchingwatch.rs::allocation_end) would be slightly more defensive, though neither overflows for valid user-mode spans.Next step
Because this touches
victory-gpu::watchjournal stamping (JOURNALwrite lock andahead_asked) on every titleVirtualFree/XMemFreeDefault, run a local real-GPU title smoke test to confirm no frame-time regression, lock contention spikes, or stale host-copy artifacts before merging.Generated with Antigravity CLI (
agy).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T16:41:29Z.
Automated RTX 4060 Ti 8 GB hardware verification PASSED (
playtest/wave4-no141vsorigin/main17a2f09— 5/5 A/B gates PASS):cargo test(RTX 4060 Ti):victory39 passed, 0 failed;victory-gpu552 passed, 0 failed (37 ignored).scripts/verify-world.ps1, DLSS Quality + golden autosave):11.9 fps(84.15 ms) vs11.2 fps(88.9 ms) baseline (+0.70 fps, min improved7.0vs4.6, preparing43.2 msvs45.1 ms)5641 MBvs5760 MB(-119 MB,0 MBover budget)final_waiting=5924vs5753(PASS)mapped_rate=8.69 ms/svs14.96 ms/s(-42%)frame-3923.png,frame-3955.png), luma66.54, edge energy2.1, magenta0.0%.