GPU: write tracking guards sparse pages in 4 KiB blocks (VICTORY_WATCH_ADAPTIVE=1) #3879
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3879"
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 Marvisak/VIctory. Originally posted by luciano-repetti on 2026-11-30T09:58:07Z.
The problem
watch.rsguards title memory in 64 KiB pages: the first write to a page faults once, and the whole page is then refreshed. 64 KiB is right for sequential writers (few faults), wrong for scattered ones: a few bytes written in a page cost a 64 KiB copy. 4 KiB guards are the reverse: about a tenth of the bytes in the sparse benchmark below (81.6 MB to 7.8 MB a frame), but many more faults under sequential ones. Neither fixed size wins everywhere.The fix
Per page, adaptive, opt-in with
VICTORY_WATCH_ADAPTIVE=1:VICTORY_WATCH_ADAPTIVE=finekeeps every page in blocks; it exists for the benchmark's fixed 4 KiB baseline.Relation to other work
Several open PRs touch
watch.rs(#3229, #3343, #3455, #3615, #3720, #3754, #3772). From a search of their diffs, not a full review: #3615 also works at 4 KiB, withGetWriteWatchon write-watched memory instead of guards, and I found no other that changes the size of a guard. This will need a rebase after whichever lands first, and I will do it.Measurements (synthetic, no game)
New
tests/watch_page_bench.rsate9f9723(this branch), release build, ms per frame (writes with their faults + takes + copies), median of 3, Core Ultra 9 185H (CPU-only bench):Adaptive stays near the best fixed size in each pattern and wins on the mixed one.
Needs the game; not run here. An in-game run with the variable on and off would tell whether real frames look like the mixed pattern.
Tests
the_adaptive_policy_tries_blocks_and_backs_off,the_adaptive_state_is_bounded,copies_stay_equal_to_memory_through_blocks_and_partial_takes,blocks_are_listed_as_runs_cut_to_the_range,kernel_reads_into_guarded_blocks_after_opening.writes_mark_every_tracker_of_their_pagestill checks the exact whole page when adaptive is off; with it on, it checks that the reported blocks cover the writes.cargo test -p victory-gpu, also withVICTORY_WATCH_ADAPTIVE=1: 236 passed, 2 failed, 1 ignored, with the variable 0 and 1. The 2 (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views) fail the same way on main63bcca4on this machine.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo run -p xtask -- policy: 192 files ok.Imported from Marvisak/VIctory. Originally posted by cobrajet302gt on 2026-11-30T12:02:29Z.
data point from our box for this lane, non-prescriptive: we single-factor-reverted a free-tracking watch change (#1849, watch.rs only, +12/-46, md5 7664575b -> 778fad8b) and armed
exceptions:page_fault_user(filter: title-arena window, error_code==4) before launch. In-window read-AVs went from six-at-one-instant to zero across two boots (Pool 98.8% at death, 34 and 74 min alive vs a 504-924 s band). Kernel fault counts before/after a guard-size change are cheap ground truth; the revert pair + trace recipe would work as a regression harness for adaptive granularity. Full data: #1633 comment 7277859599. (agent-assisted)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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.