GPU: experiment with allocation-level write-watch classification (FIND-44) #3485
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!3485
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3485"
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?
@srijann07 on GitHub · 2026-11-27 07:50 UTC · original
srijann07:perf/watch-allocation-classification→main· +195 −2 · 1 files · 7 commits · openSummary
Experimental opt-in write-watch classification optimization for FIND-44.
VICTORY_WATCH_REGION_PROBE=1.Benchmark results
Windows release build, synthetic allocations only:
Validation
CI: https://github.com/srijann07/VIctory/actions/runs/45959646990
Claim: #1633
Limitations
Dirty-memory overhead remains. Windows/Wine compatibility
and actual gameplay performance require further validation.
No overall FPS improvement is claimed.
@oni-swr on GitHub · 2026-11-27 08:35 UTC · original
Independent WARP verification of #3485 (head
475dd48e)Setup. Windows 11 Pro 10.0.26200, AMD Ryzen 7 5700X3D, rustc 1.98.1. No physical GPU used:
VICTORY_WARP=1andVICTORY_D3D12_WARP=1, with--features diagnosticsonvictory-gpu(without that featureVICTORY_D3D12_WARPis compiled out inhost.rsand the default adapter would be used).VICTORY_DXIL= Windows SDK 10.0.26100.0dxil.dll(1.8.2502.11). Command:cargo test -j 4 -p victory-gpu --features diagnostics --locked. The PR's merge-base isffe310e, so base ismain63bcca43and head is a clean test merge of475dd48eonto63bcca43(onlywatch.rsdiffers).watch.rshas changed a lot on main since the merge-base, so the review below is of the merged file.Tests
63bcca43VICTORY_WATCH_REGION_PROBE=1The +5 passes are the five new
region_probe_*tests; the +1 ignored isregion_probe_benchmark. Note for anyone repeating this: with one target dir shared by several worktrees, cargo's mtime fingerprints can reuse the other tree's binary. I touched the sources before every run and checked that each run recompiledvictory-gpu.Benchmark. The author's
region_probe_benchmark(--release --ignored), repeated on this host.PAGEis 64 KiB, so 256 pages = 16 MiB. Clean memory, per 100 calls:Dirty memory (every page written): 16 MiB 62 → 104 µs (+67%), 64 MiB about 72-91 → 116 µs, 256 MiB 118 → 161 µs (+37%). Below 16 MiB both paths are identical, as designed. This reproduces the PR's table: the clean-memory speedup and the dirty-memory overhead (about 40 µs per call) are both real.
Review of the fast path
AllocationBase + RegionSizedoes bound the allocation. I checkedQueryVirtualMemoryInformation(MemoryRegionInfo)on this host with a standalone probe. For a 32 MiB private allocation, queries at the base, at +8 MiB, at a PAGE_NOACCESS page and at a guard page all return the sameAllocationBase,RegionSize= 32 MiB (the whole allocation, not "from the queried address") andCommitSize= committed bytes. For a 32 MiB reservation with 8 MiB committed,CommitSizeis 8 MiB. SoCommitSize == RegionSizemeans no uncommitted page anywhere in the allocation, andend <= base + RegionSizeis an exact bound.watched()probe is enough.MEM_WRITE_WATCHis set for the whole reservation, so if the first page is watched, every page of that private allocation is.watched(aligned, end - aligned)) already returns every page whenever the whole range is write-watched, and it ignores protection, guard/no-access pages, mixed protections and type. The fast path only answers(first..last)where that shortcut would succeed too, so the result is identical. Images and mapped views fail the private-flag check. Partly committed, non-watched and foreign ranges fall through to the unchanged slow path (a plain 32 MiBMEM_COMMITallocation reports flags 0x1, and a write-watch one 0x401). Nothing is cached, and the PR's test confirmsGetWriteWatchis not reset.QueryVirtualMemoryInformationis imported at load time (windows-sys links it fromapi-ms-win-core-memory-l1-1-4.dll), even with the probe off. It is not exported bykernel32.dll: my probe that imported it from kernel32 failed withSTATUS_ENTRYPOINT_NOT_FOUND. On a host whose loader or Wine/Proton build lacks the export, the binary may fail to start at all. I could not test Wine. AGetProcAddresslookup would remove the risk.GetWriteWatchbefore falling back, with no gain.Blocking findings: none for an opt-in change. Risk 1 should be checked on Wine/Proton before this is ever made the default.
No game files, dumps, install paths, shader names or hashes were used. AI-assisted: Claude Code (Claude Sonnet 5.5).
@cloph-dsp on GitHub · 2026-11-27 09:30 UTC · original
Independent verification of PR #3485 (CPU-only, synthetic inputs, no game data).
Windows / Rust 1.100.0 / MSVC, per-worktree CARGO_TARGET_DIR=D:\Victory-Contrib\target-3485-verify, CARGO_BUILD_JOBS=2.
Head
475dd48, base/merge base63bcca4.Commands and results:
cargo test --locked -p victory-gpu --lib -- watch::tests::region_probe_matches_baseline_after_address_reuse --exact --test-threads=1 --quiet-> 1 passed, 0 failed, 237 filtered, exit 0.git grep -F region_probe_matches_baseline_after_address_reuse 63bcca4 -- crates/victory-gpu/src/watch.rs-> no hits (test new on this PR).git diff --check 63bcca4 HEAD-> clean.Notes: only the named synthetic test was replayed; full crate suite not run. Only pre-existing
fetch_updatedeprecation warnings. GPU/driver N/A for this CPU-only test. AI-assisted (Hy4 flash). No game data or extracted assets used.@futurepro62 on GitHub · 2026-11-27 18:56 UTC · original
NVIDIA full-suite run, to go with the reports above by cloph-dsp, oni-swr, since none of them names a GPU run. Tested exact head
475dd48(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 871 passed, 0 failed, 11 ignored.region_probe_matches_baseline_after_address_reuse,region_probe_matches_baseline_across_protections,region_probe_matches_baseline_for_dirty_and_partial_ranges,region_probe_matches_baseline_for_mixed_commit_states,region_probe_does_not_reset_write_watch.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.