GPU: deduplicate per-submission write-watch askings over nested buffers (#776) #1351
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!1351
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1351/head"
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-24 17:34 UTC · original
wbkepler:gpu/write-watch-dedupe-nested→main· +469 −30 · 2 files · 1 commits · closed without mergingSummary
Implements #776:
MEM_WRITE_WATCHaskings over nested/overlapping buffers incrates/victory-gpu/src/{watch.rs,host.rs}via largest-firstBatch::flushand per-submission sweep tracking.GetWriteWatch/ page-reset overhead when multiple nested views reference the same title memory region.Verification
cargo clippy -p victory-gpu --all-targets— passedcargo test -p victory-gpu— passedcargo xtask policy— passed@maplerouteadmin-dev on GitHub · 2026-11-24 19:17 UTC · original
Tested in the title on an RTX 5070 (driver 32.0.16.2114), Ryzen 5 5600X, 32 GB, Windows 11; Xbox Series 1.0.2.1; diag build. Base:
mainffe310e+ #966 + Peppacodesexp/mesh-host-lanes+ a #951 port (needed to reach the world on NVIDIA) + #1350. Same scripted input every run (VICTORY_KEYS), 165 s per run, builds alternated, one process at a time. No game data used.The deduplication works, but as is it makes copies larger, because some copies stop being write-watched.
When a sweep leaves a gap that starts in an unmapped hole of view memory,
query_gap→guardgives up (guardchecksVirtualQuery(start).Type == MEM_MAPPEDat the gap's start, which is not mapped there, while the range's own start is).writesreturnsNone, andShadow::update_freemarks the copyNOT_WATCHEDfor good: every later refresh copies the whole range. With a log line at that point, entering the world:0xb2…–0xcf…);GetWriteWatchfails with error 87 andguardreturnsNonefor the gap, e.g. gap0xb3f7c0000..0xb415e0000of a refresh0xb3f5d2000..0xb415d5000in the copy at0xb3e000000+64 MBSuggested fix (12 lines in
writes): when a gap fails, ask about the whole range once, as without a sweep:With it: 0 copies became unwatched (the guard gave up on a gap 108 times; the whole-range retry succeeded every time).
cargo test -p victory-gpuand both clippy configurations pass.Medians over world frames (5 s frame-rate lines with frames over 500 ms, pooled per build):
Draws per frame differ between runs (the scene moves), so per-draw figures are the fairer comparison.
Caveats. Frame times are noisy, and the world is not stable on this card: device removal (TDR) in several runs of every build, and one hard system freeze during a #1350-only run. Two runs of the fixed build ended in title access violations: one at the same title address as a crash on the plain base without either PR (
+0x23cf683, write to 0), one at loading (+0x164a298, read 0x2c) seen once in about 20 runs. I can't tie either to these changes.@maplerouteadmin-dev on GitHub · 2026-11-24 21:15 UTC · original
Correction to my earlier numbers on #1350 and #1351. After posting them I found a background GPU process on the test machine (a hidden CUDA miner, since removed) holding about 2.8 GB of VRAM and using the GPU. Every build was measured under the same conditions, so the comparisons between builds hold, but the absolute frame times and some of the device removals were inflated by it. Re-measured on the clean machine:
RTX 5070 12 GB (driver 32.0.16.2114), Ryzen 5 5600X, 32 GB, Windows 11; Xbox Series 1.0.2.1; diag build; same scripted input (
VICTORY_KEYS), 240 s per run, builds alternated, one process at a time. Base =mainffe310e+ #966 + Peppacodesexp/mesh-host-lanes+ a #951 port. Medians over world frame-rate lines (frames over 500 ms). No game data used.Same conclusions as before: #1350 cuts the copy cost sharply; #1351 as is copies more per draw (the copies left unwatched after a failed gap, see my comment on #1351); with the gap fix it is the fastest of the four. The device removals are real on this card without the background process too: about one run in two, on every build, so they are not caused by either PR.
@Marvisak on GitHub · 2026-11-25 00:38 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Deduplicates per-submission GetWriteWatch askings over nested buffers; main asks the system nothing per submission any more (per-copy trackers marked by guard faults).
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed