GPU: ask whether guarded memory is a view once per block, not per asking #490
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!490
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/490/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 04:02 UTC · original
wbkepler:gpu/guard-view-cache→main· +225 −22 · 1 files · 2 commits · closed without mergingStacked on #464. This branch contains #464's commit; only the second commit is new. Review that commit alone, or after #464 merges.
Problem
Memory that can't be write-watched (physical-page views) goes through
watch::guard. Each asking began withVirtualQueryon its start to check that the memory is a view. In the world, the 174 MB GPU heap and blocks inside it are asked about thousands of times a frame. With temporary timers on #464, that one query took 94–235 ms per world frame. By comparison, the rest of the guard took 4–7 ms ofVirtualProtectand 4–10 ms of opening blocks.Change
crates/victory-gpu/src/watch.rsonly:Guardsgains aviewsset: the blocks where an asking began and that the query found to be in a view. A later asking starting in such a block skips the query.title_memory_remappedtakes that lock and drops the blocks in its range fromviews, so a block's entry can't outlive a map or unmap. The runtime calls the hook after mapping a view and before unmapping one.Measured
Diagnostics build, RTX 5090, same save, start screen to world. One run each: #464 alone, then #464 plus this change. These are the
copystatworld windows. The guard time is the temporary timer aroundguard; the other numbers come from the existing counters.Example world lines:
2.5 fps, 400.0 ms/frame (195.0 preparing: copies 129.6 ms ...),5475 watches 118.62 ms1.8 fps, 550.0 ms/frame (268.9 preparing: copies 151.9 ms ...)2.0 fps, 488.8 ms/frame (194.7 preparing: copies 67.3 ms ...), 1572 draws/frame,5475 watches 38.35 ms, 39817.9 MB checkedFrame-to-frame scenes vary a lot. The watch-time drop is the clear signal; preparing improves less visibly within the noise.
I also tried walking a guarded range by runs of blocks instead of looking up every block. It made no measurable difference, so it isn't included: the query was the cost, not the walk.
Tests
watch::tests::views_are_queried_once_until_remapped. A test-only per-thread counter shows that a view is queried once per start block, and again aftertitle_memory_remapped. Private memory is queried, and refused, every time.cargo fmt --check(watch.rs),cargo clippy --workspace --all-targets,cargo clippy -p victory --features diagnostics --all-targets(no new warnings),cargo test --workspace, andcargo xtask policyall pass.🤖 Generated with Claude Code
@pablogonz12 on GitHub · 2026-11-24 16:20 UTC · original
Measured on Linux (RX 9070 XT, RADV/Mesa 26.3.1, GE-Proton11-14, vkd3d-proton master, diagnostics build), 240 s world runs, last 8 frame-rate lines, 2 runs per side. Head e6f9159 (+#464) merged onto our tree, which also carries #393/#124 — the watch.rs conflict was resolved into one
writeswith #393's journal fast path over this PR'sviews/absentbookkeeping:No device removed, no panics. victory-gpu tests under Wine: watch 7/7, shadow 4/4.
Not tested: native Windows; in-game on this PR alone (the row above is the merged tree).
@wbkepler on GitHub · 2026-11-24 20:50 UTC · original
Rebased onto current main (
ffe310e) as1d46278, on top of the rebased #464 (9dd1507, which keeps main'ssaturating_addguard); no content conflicts after restacking. Gate clean.AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.
Pull request closed