GPU: experiment with allocation-level write-watch classification (FIND-44) #3485

Open
github-bot wants to merge 7 commits from github-bot/gh-3485 into main AGit
Owner

@⁠srijann07 on GitHub · 2026-11-27 07:50 UTC · original
srijann07:perf/watch-allocation-classification → main · +195 −2 · 1 files · 7 commits · open

Summary

Experimental opt-in write-watch classification optimization for FIND-44.

  • Uses allocation-level metadata instead of expensive region scanning.
  • Preserves existing fallback classification.
  • No persistent address cache or write-watch reset.
  • Enable using VICTORY_WATCH_REGION_PROBE=1.
  • Disabled by default.

Benchmark results

Windows release build, synthetic allocations only:

Allocation Clean-memory speedup Dirty-memory overhead
16 MiB 5.2x 74%
64 MiB 15.4x 55%
256 MiB 43.5x 30%

Validation

  • 236 GPU tests passed.
  • Five new regression tests passed.
  • Workspace tests passed.
  • Both Clippy configurations passed.
  • No game assets used.
  • No workflow changes in the final diff.

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.

**@⁠srijann07** on GitHub · 2026-11-27 07:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3485) `srijann07:perf/watch-allocation-classification` → `main` · +195 −2 · 1 files · 7 commits · open ## Summary Experimental opt-in write-watch classification optimization for FIND-44. - Uses allocation-level metadata instead of expensive region scanning. - Preserves existing fallback classification. - No persistent address cache or write-watch reset. - Enable using `VICTORY_WATCH_REGION_PROBE=1`. - Disabled by default. ## Benchmark results Windows release build, synthetic allocations only: | Allocation | Clean-memory speedup | Dirty-memory overhead | |---|---:|---:| | 16 MiB | 5.2x | 74% | | 64 MiB | 15.4x | 55% | | 256 MiB | 43.5x | 30% | ## Validation - 236 GPU tests passed. - Five new regression tests passed. - Workspace tests passed. - Both Clippy configurations passed. - No game assets used. - No workflow changes in the final diff. CI: https://github.com/srijann07/VIctory/actions/runs/45959646990 Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 ## Limitations Dirty-memory overhead remains. Windows/Wine compatibility and actual gameplay performance require further validation. No overall FPS improvement is claimed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 07:55:42 +00:00
Author
Owner

@⁠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=1 and VICTORY_D3D12_WARP=1, with --features diagnostics on victory-gpu (without that feature VICTORY_D3D12_WARP is compiled out in host.rs and the default adapter would be used). VICTORY_DXIL = Windows SDK 10.0.26100.0 dxil.dll (1.8.2502.11). Command: cargo test -j 4 -p victory-gpu --features diagnostics --locked. The PR's merge-base is ffe310e, so base is main 63bcca43 and head is a clean test merge of 475dd48e onto 63bcca43 (only watch.rs differs). watch.rs has changed a lot on main since the merge-base, so the review below is of the merged file.

Tests

passed failed ignored
base 63bcca43 246 0 1
head, probe off 251 0 2
head, VICTORY_WATCH_REGION_PROBE=1 251 0 2

The +5 passes are the five new region_probe_* tests; the +1 ignored is region_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 recompiled victory-gpu.

Benchmark. The author's region_probe_benchmark (--release --ignored), repeated on this host. PAGE is 64 KiB, so 256 pages = 16 MiB. Clean memory, per 100 calls:

range slow fast speedup
16 MiB 585 µs 121 µs 4.8x
64 MiB 2.26 ms 133 µs 17x
256 MiB 8.85 ms 177 µs 50x

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 + RegionSize does bound the allocation. I checked QueryVirtualMemoryInformation(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 same AllocationBase, RegionSize = 32 MiB (the whole allocation, not "from the queried address") and CommitSize = committed bytes. For a 32 MiB reservation with 8 MiB committed, CommitSize is 8 MiB. So CommitSize == RegionSize means no uncommitted page anywhere in the allocation, and end <= base + RegionSize is an exact bound.
  • The 4 KiB watched() probe is enough. MEM_WRITE_WATCH is set for the whole reservation, so if the first page is watched, every page of that private allocation is.
  • It cannot return pages the slow path would exclude. The slow path's first shortcut (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 MiB MEM_COMMIT allocation reports flags 0x1, and a write-watch one 0x401). Nothing is cached, and the PR's test confirms GetWriteWatch is not reset.
  • Risks, none blocking for an opt-in, default-off change:
    1. QueryVirtualMemoryInformation is imported at load time (windows-sys links it from api-ms-win-core-memory-l1-1-4.dll), even with the probe off. It is not exported by kernel32.dll: my probe that imported it from kernel32 failed with STATUS_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. A GetProcAddress lookup would remove the risk.
    2. For a private, fully committed 16 MiB+ allocation that is not write-watched (for example a heap segment), each call pays the extra query plus a small GetWriteWatch before falling back, with no gain.
    3. The speedup applies only to clean pools. Whether it helps in the game depends on how often big pools are clean at classification time, which a synthetic test cannot show.

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).

**@⁠oni-swr** on GitHub · 2026-11-27 08:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3485#issuecomment-7213710029) ## 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=1` and `VICTORY_D3D12_WARP=1`, with `--features diagnostics` on `victory-gpu` (without that feature `VICTORY_D3D12_WARP` is compiled out in `host.rs` and the default adapter would be used). `VICTORY_DXIL` = Windows SDK 10.0.26100.0 `dxil.dll` (1.8.2502.11). Command: `cargo test -j 4 -p victory-gpu --features diagnostics --locked`. The PR's merge-base is `ffe310e`, so base is `main` 63bcca43 and head is a clean test merge of `475dd48e` onto 63bcca43 (only `watch.rs` differs). `watch.rs` has changed a lot on main since the merge-base, so the review below is of the merged file. **Tests** | | passed | failed | ignored | |---|---:|---:|---:| | base 63bcca43 | 246 | 0 | 1 | | head, probe off | 251 | 0 | 2 | | head, `VICTORY_WATCH_REGION_PROBE=1` | 251 | 0 | 2 | The +5 passes are the five new `region_probe_*` tests; the +1 ignored is `region_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 recompiled `victory-gpu`. **Benchmark.** The author's `region_probe_benchmark` (`--release --ignored`), repeated on this host. `PAGE` is 64 KiB, so 256 pages = 16 MiB. Clean memory, per 100 calls: | range | slow | fast | speedup | |---:|---:|---:|---:| | 16 MiB | 585 µs | 121 µs | 4.8x | | 64 MiB | 2.26 ms | 133 µs | 17x | | 256 MiB | 8.85 ms | 177 µs | 50x | 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 + RegionSize` does bound the allocation. I checked `QueryVirtualMemoryInformation(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 same `AllocationBase`, `RegionSize` = 32 MiB (the whole allocation, not "from the queried address") and `CommitSize` = committed bytes. For a 32 MiB reservation with 8 MiB committed, `CommitSize` is 8 MiB. So `CommitSize == RegionSize` means no uncommitted page anywhere in the allocation, and `end <= base + RegionSize` is an exact bound. - The 4 KiB `watched()` probe is enough. `MEM_WRITE_WATCH` is set for the whole reservation, so if the first page is watched, every page of that private allocation is. - It cannot return pages the slow path would exclude. The slow path's first shortcut (`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 MiB `MEM_COMMIT` allocation reports flags 0x1, and a write-watch one 0x401). Nothing is cached, and the PR's test confirms `GetWriteWatch` is not reset. - Risks, none blocking for an opt-in, default-off change: 1. `QueryVirtualMemoryInformation` is imported at load time (windows-sys links it from `api-ms-win-core-memory-l1-1-4.dll`), even with the probe off. It is not exported by `kernel32.dll`: my probe that imported it from kernel32 failed with `STATUS_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. A `GetProcAddress` lookup would remove the risk. 2. For a private, fully committed 16 MiB+ allocation that is not write-watched (for example a heap segment), each call pays the extra query plus a small `GetWriteWatch` before falling back, with no gain. 3. The speedup applies only to clean pools. Whether it helps in the game depends on how often big pools are clean at classification time, which a synthetic test cannot show. **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).
Author
Owner

@⁠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 base 63bcca4.

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_update deprecation warnings. GPU/driver N/A for this CPU-only test. AI-assisted (Hy4 flash). No game data or extracted assets used.

**@⁠cloph-dsp** on GitHub · 2026-11-27 09:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3485#issuecomment-7214771175) 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 base 63bcca4. 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_update` deprecation warnings. GPU/driver N/A for this CPU-only test. AI-assisted (Hy4 flash). No game data or extracted assets used.
Author
Owner

@⁠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 base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo 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.
  • The new tests ran and passed: 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.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#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_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-27 18:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/3485#issuecomment-7226019630) 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 base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo 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**. - The new tests ran and passed: `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`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#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_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3485/head:github-bot/gh-3485'
git switch 'github-bot/gh-3485'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3485'
git switch 'github-bot/gh-3485'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3485'
git switch 'github-bot/gh-3485'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3485'
git switch 'main'
git merge --squash 'github-bot/gh-3485'
git switch 'main'
git merge --ff-only 'github-bot/gh-3485'
git switch 'main'
git merge 'github-bot/gh-3485'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3485
No description provided.