watch: interval-skip absent placeholders, coalesce VirtualProtect runs, O(dirty) re-arm (#1238) #1279

Open
github-bot wants to merge 1 commit from github-bot/gh-1279 into main AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 09:52 UTC · original
Vladimir-Human:perf/watch-guard-coalesce-dirty → main · +2678 −371 · 2 files · 1 commits · open

Summary

Optimizes watch::guard and view-memory protection/unprotection in victory-gpu (crates/victory-gpu/src/watch.rs, crates/victory-gpu/src/inplace.rs) to eliminate per-block guard walks, repeated VirtualQuery probing of unmapped placeholder blocks, and per-block VirtualProtect syscalls reported in #1238.

What changed

  1. Coalesced interval tracking & fast absent/placeholder skip (watch.rs):

    • Replaced per-block BTreeSet<usize> / BTreeMap<usize, u64> sets in Guards (protected, clean, absent, aliased, viewed, holes, verified) with disjoint coalesced half-open interval containers (BlockSet and VerifiedMap) plus placeholder_absent: BlockSet.
    • guard_locked checks g.clean.covers(first, last) in O(log K) with zero allocations and jumps across contiguous clean and absent intervals instead of iterating first..=last block-by-block.
    • Uncommitted spans confirmed via NtQueryVirtualMemory(MemoryRegionInformationEx) to lie in MEM_RESERVE_PLACEHOLDER reservations are tracked in placeholder_absent and skipped with zero VirtualProtect and zero VirtualQuery syscalls until title_memory_remapped / title_memory_committed clears them (VICTORY_ABSENT_ONCE=0 opts out; ordinary non-placeholder MEM_RESERVE / SEC_RESERVE reservations still probe via VirtualQuery per region; guard_at honors its explicit keep parameter; look_at_holes clears placeholder_absent/absent if a hole is silently filled).
    • Added word-level Bits::set_range / Bits::clear_range (clamped to BITS_MAX_BLOCK, skipping unallocated 4 GiB pieces).
  2. Contiguous run coalescing, O(dirty) re-arm, & single lock hold (watch.rs, inplace.rs):

    • writes_as uses try_guard_if_known to verify known-view membership and run guard_locked under a single GUARDS lock hold (with post-install() re-check so there is no TOCTOU window).
    • guard_locked marks already-protected blocks (e.g. alias-guarded views) clean in O(dirty) without re-calling VirtualProtect, and coalesces adjacent unprotected dirty blocks into contiguous runs.
    • protect_here, protect_alias_run, and unprotect_run_os (open / open_here) issue a single coalesced VirtualProtect per contiguous run, falling back to VirtualQuery-guided OS VM region stepping on VAD boundaries or uncommitted gaps (1 syscall per committed VAD, 0 failing VirtualProtect calls on uncommitted holes, protected ∩ absent == ∅ enforced by construction in note_protected, checked_mul(BLOCK) overflow guards).
    • Added lock-batched inplace::aliases_in_range and inplace::aliases_for_blocks (preserving lock order MAPPING -> JOURNAL -> GUARDS -> VIEWS), a zero-allocation single-block unaliased fast path in open for VEH write faults, and strict PUBLISHED clearing for both primary and alias blocks before any PAGE_READWRITE transition.
  3. Unit, stress, & deterministic benchmark tests (watch.rs):

    • block_set_and_verified_map_interval_invariants
    • sparse_placeholder_gaps_are_skipped_without_probing_or_protecting
    • contiguous_runs_coalesce_guard_and_unguard_syscalls
    • aliased_views_coalesce_protect_open_and_o_dirty_rearm
    • ordinary_reserve_is_not_placeholder_and_silent_commit_is_detected
    • protected_and_absent_sets_remain_disjoint_after_protect
    • unprotect_run_os_skips_uncommitted_gap_without_per_block_failures
    • concurrent_writers_and_guard_readers_stay_coherent
    • benchmark_guard_coalesce_and_absent_skip

Measurements (--release, live Windows placeholders & aliased views)

Workload Metric Baseline After Reduction / Speedup
Sparse placeholders (192 blocks, 128 split 64 KiB holes, 60 submissions, 4 dirty/sub) VirtualProtect calls 493 125 3.9x fewer
Sparse placeholders (same) VirtualQuery calls 7,808 132 (0 steady-state) 59.2x fewer
Sparse placeholders (same) Wall-clock time 2.977 ms 0.504 ms 5.9x faster
Dual-aliased contiguous view (64 blocks x 2 views, 30 open+guard cycles) VirtualProtect calls 5,855 122 48.0x fewer
Dual-aliased contiguous view (same) Wall-clock time 3.293 ms 1.844 ms 1.8x faster

Verification

  • cargo test -p victory-gpu (parallel): 221 passed; 0 failed; 6 ignored
  • cargo test -p victory-gpu --features diagnostics -- watch: 29 passed; 0 failed; 1 ignored
  • cargo test --release -p victory-gpu -- watch::tests::benchmark_guard_coalesce_and_absent_skip --exact --nocapture: PASS
  • cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated (default & --features diagnostics): 0 warnings/errors in modified files (only 3 pre-existing AtomicU32::fetch_update deprecation warnings in untouched object.rs on rustc 1.100.0)
  • cargo run -p xtask -- policy --staged: asset policy: 2 files ok

Related: #1238

**@⁠Vladimir-Human** on GitHub · 2026-11-26 09:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279) `Vladimir-Human:perf/watch-guard-coalesce-dirty` → `main` · +2678 −371 · 2 files · 1 commits · open ## Summary Optimizes `watch::guard` and view-memory protection/unprotection in `victory-gpu` (`crates/victory-gpu/src/watch.rs`, `crates/victory-gpu/src/inplace.rs`) to eliminate per-block guard walks, repeated `VirtualQuery` probing of unmapped placeholder blocks, and per-block `VirtualProtect` syscalls reported in #1238. ### What changed 1. **Coalesced interval tracking & fast absent/placeholder skip (`watch.rs`)**: - Replaced per-block `BTreeSet<usize>` / `BTreeMap<usize, u64>` sets in `Guards` (`protected`, `clean`, `absent`, `aliased`, `viewed`, `holes`, `verified`) with disjoint coalesced half-open interval containers (`BlockSet` and `VerifiedMap`) plus `placeholder_absent: BlockSet`. - `guard_locked` checks `g.clean.covers(first, last)` in `O(log K)` with zero allocations and jumps across contiguous `clean` and `absent` intervals instead of iterating `first..=last` block-by-block. - Uncommitted spans confirmed via `NtQueryVirtualMemory(MemoryRegionInformationEx)` to lie in `MEM_RESERVE_PLACEHOLDER` reservations are tracked in `placeholder_absent` and skipped with zero `VirtualProtect` and zero `VirtualQuery` syscalls until `title_memory_remapped` / `title_memory_committed` clears them (`VICTORY_ABSENT_ONCE=0` opts out; ordinary non-placeholder `MEM_RESERVE` / `SEC_RESERVE` reservations still probe via `VirtualQuery` per region; `guard_at` honors its explicit `keep` parameter; `look_at_holes` clears `placeholder_absent`/`absent` if a hole is silently filled). - Added word-level `Bits::set_range` / `Bits::clear_range` (clamped to `BITS_MAX_BLOCK`, skipping unallocated 4 GiB pieces). 2. **Contiguous run coalescing, O(dirty) re-arm, & single lock hold (`watch.rs`, `inplace.rs`)**: - `writes_as` uses `try_guard_if_known` to verify known-view membership and run `guard_locked` under a single `GUARDS` lock hold (with post-`install()` re-check so there is no TOCTOU window). - `guard_locked` marks already-`protected` blocks (e.g. alias-guarded views) `clean` in `O(dirty)` without re-calling `VirtualProtect`, and coalesces adjacent unprotected dirty blocks into contiguous runs. - `protect_here`, `protect_alias_run`, and `unprotect_run_os` (`open` / `open_here`) issue a single coalesced `VirtualProtect` per contiguous run, falling back to `VirtualQuery`-guided OS VM region stepping on VAD boundaries or uncommitted gaps (1 syscall per committed VAD, 0 failing `VirtualProtect` calls on uncommitted holes, `protected ∩ absent == ∅` enforced by construction in `note_protected`, `checked_mul(BLOCK)` overflow guards). - Added lock-batched `inplace::aliases_in_range` and `inplace::aliases_for_blocks` (preserving lock order `MAPPING -> JOURNAL -> GUARDS -> VIEWS`), a zero-allocation single-block unaliased fast path in `open` for VEH write faults, and strict `PUBLISHED` clearing for both primary and alias blocks before any `PAGE_READWRITE` transition. 3. **Unit, stress, & deterministic benchmark tests (`watch.rs`)**: - `block_set_and_verified_map_interval_invariants` - `sparse_placeholder_gaps_are_skipped_without_probing_or_protecting` - `contiguous_runs_coalesce_guard_and_unguard_syscalls` - `aliased_views_coalesce_protect_open_and_o_dirty_rearm` - `ordinary_reserve_is_not_placeholder_and_silent_commit_is_detected` - `protected_and_absent_sets_remain_disjoint_after_protect` - `unprotect_run_os_skips_uncommitted_gap_without_per_block_failures` - `concurrent_writers_and_guard_readers_stay_coherent` - `benchmark_guard_coalesce_and_absent_skip` ### Measurements (`--release`, live Windows placeholders & aliased views) | Workload | Metric | Baseline | After | Reduction / Speedup | |---|---|---:|---:|---:| | Sparse placeholders (192 blocks, 128 split 64 KiB holes, 60 submissions, 4 dirty/sub) | `VirtualProtect` calls | 493 | 125 | **3.9x fewer** | | Sparse placeholders (same) | `VirtualQuery` calls | 7,808 | 132 (0 steady-state) | **59.2x fewer** | | Sparse placeholders (same) | Wall-clock time | 2.977 ms | 0.504 ms | **5.9x faster** | | Dual-aliased contiguous view (64 blocks x 2 views, 30 open+guard cycles) | `VirtualProtect` calls | 5,855 | 122 | **48.0x fewer** | | Dual-aliased contiguous view (same) | Wall-clock time | 3.293 ms | 1.844 ms | **1.8x faster** | ### Verification - `cargo test -p victory-gpu` (parallel): **221 passed; 0 failed; 6 ignored** - `cargo test -p victory-gpu --features diagnostics -- watch`: **29 passed; 0 failed; 1 ignored** - `cargo test --release -p victory-gpu -- watch::tests::benchmark_guard_coalesce_and_absent_skip --exact --nocapture`: **PASS** - `cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated` (default & `--features diagnostics`): **0 warnings/errors** in modified files (only 3 pre-existing `AtomicU32::fetch_update` deprecation warnings in untouched `object.rs` on `rustc 1.100.0`) - `cargo run -p xtask -- policy --staged`: **asset policy: 2 files ok** Related: #1238
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:19:43 +00:00
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 09:56 UTC · original

Nice work on the syscall counts. Do you have in-game numbers too? For instance the frame log's "a submission's preparing by part" line (write-watch share) or the usual frame time, before/after, in a world scene. On an RTX 3080 the write-watch part is ~11.8 ms of ~79 ms the submit worker spends preparing per frame (boat mission), so it would be a real gain there. Happy to run an A/B here if that helps.

**@⁠Garu667** on GitHub · 2026-11-26 09:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7188671506) Nice work on the syscall counts. Do you have in-game numbers too? For instance the frame log's "a submission's preparing by part" line (write-watch share) or the usual frame time, before/after, in a world scene. On an RTX 3080 the write-watch part is ~11.8 ms of ~79 ms the submit worker spends preparing per frame (boat mission), so it would be a real gain there. Happy to run an A/B here if that helps.
Author
Owner

@⁠HLVM04 on GitHub · 2026-11-26 09:56 UTC · original

In-game data point for the placeholder skip, from a separate local change of ours (not this PR's code): native Windows, RTX 5070 Ti, Series S profile, fork stack in the first gameplay scene. Absent blocks inside placeholder reservations (which the runtime already reports) are no longer queried with VirtualQuery every frame; that cost went from 9.3 to 0.7 ms a frame. We did not count VirtualProtect calls or measure the alias-view coalescing part, and it is a few runs on one scene, so it says nothing about this PR's other changes.

**@⁠HLVM04** on GitHub · 2026-11-26 09:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7188677668) In-game data point for the placeholder skip, from a separate local change of ours (not this PR's code): native Windows, RTX 5070 Ti, Series S profile, fork stack in the first gameplay scene. Absent blocks inside placeholder reservations (which the runtime already reports) are no longer queried with `VirtualQuery` every frame; that cost went from 9.3 to 0.7 ms a frame. We did not count `VirtualProtect` calls or measure the alias-view coalescing part, and it is a few runs on one scene, so it says nothing about this PR's other changes.
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 11:00 UTC · original

Rebased cleanly onto main (06702fe -> 4bc254c), preserving C::WatchKnownUs / C::WatchFailedUs diagnostics in writes_as, adapting unchanged_known to O(log K) BlockSet::covers, and keeping inplace::views_between / inplace::pages_of for host.rs. Re-verified cargo test -p victory-gpu -- --test-threads=1 (222 passed, 0 failed, 6 ignored), --features diagnostics -- watch (29 passed, 0 failed), clippy (0 warnings in touched files), and xtask policy (220 files ok).

@⁠Garu667 Thanks for the offer! We do not have local title assets here, so we cannot run in-game world-scene captures ourselves—our numbers above are from the live-Win32 synthetic benchmark (benchmark_guard_coalesce_and_absent_skip). An RTX 3080 A/B on 06702fe vs this PR looking at "a submission's preparing by part" (write-watch share) and the new WatchKnownUs / WatchFailedUs / GuardUs counters would be very helpful.

@⁠HLVM04 Thanks for sharing that native Windows 9.3 -> 0.7 ms/frame data point on placeholder skipping. This PR takes the same NtQueryVirtualMemory(MemoryRegionInformationEx) MEM_RESERVE_PLACEHOLDER skip inside Guards' coalesced BlockSet intervals (placeholder_absent, plus PUBLISHED bitset support under VICTORY_LIGHT_REFRESH=1 + VICTORY_ABSENT_MS=told, while keeping ordinary MEM_RESERVE/SEC_RESERVE probing intact and VICTORY_ABSENT_ONCE=0 as opt-out), and pairs it with single-lock try_guard_if_known, O(dirty) re-arm for already-protected alias blocks, and VirtualQuery-guided coalesced VirtualProtect across primary and peer alias views.

**@⁠Vladimir-Human** on GitHub · 2026-11-26 11:00 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7190129973) Rebased cleanly onto `main` (`06702fe` -> `4bc254c`), preserving `C::WatchKnownUs` / `C::WatchFailedUs` diagnostics in `writes_as`, adapting `unchanged_known` to `O(log K)` `BlockSet::covers`, and keeping `inplace::views_between` / `inplace::pages_of` for `host.rs`. Re-verified `cargo test -p victory-gpu -- --test-threads=1` (222 passed, 0 failed, 6 ignored), `--features diagnostics -- watch` (29 passed, 0 failed), `clippy` (0 warnings in touched files), and `xtask policy` (220 files ok). @⁠Garu667 Thanks for the offer! We do not have local title assets here, so we cannot run in-game world-scene captures ourselves—our numbers above are from the live-Win32 synthetic benchmark (`benchmark_guard_coalesce_and_absent_skip`). An RTX 3080 A/B on `06702fe` vs this PR looking at `"a submission's preparing by part"` (write-watch share) and the new `WatchKnownUs` / `WatchFailedUs` / `GuardUs` counters would be very helpful. @⁠HLVM04 Thanks for sharing that native Windows `9.3 -> 0.7 ms/frame` data point on placeholder skipping. This PR takes the same `NtQueryVirtualMemory(MemoryRegionInformationEx)` `MEM_RESERVE_PLACEHOLDER` skip inside `Guards`' coalesced `BlockSet` intervals (`placeholder_absent`, plus `PUBLISHED` bitset support under `VICTORY_LIGHT_REFRESH=1` + `VICTORY_ABSENT_MS=told`, while keeping ordinary `MEM_RESERVE`/`SEC_RESERVE` probing intact and `VICTORY_ABSENT_ONCE=0` as opt-out), and pairs it with single-lock `try_guard_if_known`, `O(dirty)` re-arm for already-protected alias blocks, and `VirtualQuery`-guided coalesced `VirtualProtect` across primary and peer alias views.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 11:05 UTC · original

Will do: we have a fresh baseline on 06702fe running right now (RTX 3080, boat mission, standing), and will run this PR on the same base next, with the preparing-by-part line and the WatchKnownUs / WatchFailedUs / GuardUs counters. Numbers here within the hour.

**@⁠Garu667** on GitHub · 2026-11-26 11:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7190253159) Will do: we have a fresh baseline on `06702fe` running right now (RTX 3080, boat mission, standing), and will run this PR on the same base next, with the preparing-by-part line and the `WatchKnownUs` / `WatchFailedUs` / `GuardUs` counters. Numbers here within the hour.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 11:38 UTC · original

A/B as promised. RTX 3080 10 GB, Windows 11, diagnostics build, Series X profile, first boat mission, character standing ~3 min, README set + CARD_SYNC_BATCH=1 CARD_HASH_WIDE=1. One launch each, same checkpoint:

06702fe (run 65) 06702fe + this PR (run 67)
world fps, median 9.1 10.0
usual frame (last 4 readings) 80 / 99 / 101 / 102 ms 86 / 86 / 88 / 86 ms
submit worker at work 87.7 ms 69.7 ms
guards (frame log) 10.1 ms 3.4 ms
asks not made, known guarded view memory 1,647 in 11.93 ms 1,669 in 2.81 ms
preparing: refreshes (the flush) 14.1 ms 7.9 ms
preparing: write-watch + look under flights (settles included) 12.8 ms 26.1 ms
submit thread waiting for the card in settles 6.4 ms 14.8 ms

So the guard and known-view work drops ~3-4x in game too, and the submit worker does ~18 ms less work a frame. Part of that time now shows up as waiting for the card (the write-watch line includes settles), which is expected once the worker gets ahead. Net ~+10 % fps here. Picture unchanged (distinct colours per capture 86-88k vs 88-90k, same scene), no device loss. Merged onto 06702fe with no conflict.

**@⁠Garu667** on GitHub · 2026-11-26 11:38 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7190978678) A/B as promised. RTX 3080 10 GB, Windows 11, diagnostics build, Series X profile, first boat mission, character standing ~3 min, README set + `CARD_SYNC_BATCH=1 CARD_HASH_WIDE=1`. One launch each, same checkpoint: | | `06702fe` (run 65) | `06702fe` + this PR (run 67) | |---|---|---| | world fps, median | 9.1 | **10.0** | | usual frame (last 4 readings) | 80 / 99 / 101 / 102 ms | 86 / 86 / 88 / 86 ms | | submit worker at work | 87.7 ms | **69.7 ms** | | guards (frame log) | 10.1 ms | **3.4 ms** | | asks not made, known guarded view memory | 1,647 in 11.93 ms | 1,669 in **2.81 ms** | | preparing: refreshes (the flush) | 14.1 ms | 7.9 ms | | preparing: write-watch + look under flights (settles included) | 12.8 ms | 26.1 ms | | submit thread waiting for the card in settles | 6.4 ms | 14.8 ms | So the guard and known-view work drops ~3-4x in game too, and the submit worker does ~18 ms less work a frame. Part of that time now shows up as waiting for the card (the write-watch line includes settles), which is expected once the worker gets ahead. Net ~+10 % fps here. Picture unchanged (distinct colours per capture 86-88k vs 88-90k, same scene), no device loss. Merged onto `06702fe` with no conflict.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 14:43 UTC · original

Important follow-up to my A/B above: the gain holds standing, but while driving the boat this PR loses the device. RTX 3080, same checkpoint: 58de9bf alone ran 9 min, driving most of it, with no loss; 58de9bf + this PR lost the device (DRED "hung") after ~40 s standing and ~15 s of driving; two earlier driving runs with it in a combined build were lost the same way (3 of 3 with it, 0 of 1 without). Standing runs never lost it, so it seems tied to the heavy remapping and streaming while moving (those frames show 100k-1M page faults and hundreds of remaps each). Happy to rerun with diagnostics, e.g. a switch that turns parts of it off.

**@⁠Garu667** on GitHub · 2026-11-26 14:43 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7195236345) Important follow-up to my A/B above: the gain holds standing, but while **driving** the boat this PR loses the device. RTX 3080, same checkpoint: `58de9bf` alone ran 9 min, driving most of it, with no loss; `58de9bf` + this PR lost the device (DRED "hung") after ~40 s standing and **~15 s of driving**; two earlier driving runs with it in a combined build were lost the same way (3 of 3 with it, 0 of 1 without). Standing runs never lost it, so it seems tied to the heavy remapping and streaming while moving (those frames show 100k-1M page faults and hundreds of remaps each). Happy to rerun with diagnostics, e.g. a switch that turns parts of it off.
github-bot force-pushed github-bot/gh-1279 from 4bc254cdb2 to 328706091b 2026-11-26 16:40:37 +00:00 Compare
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 16:36 UTC · original

@⁠Garu667 Thank you for the detailed follow-up and driving repro. Rebased onto main (e4245f3 -> 3287060) with the following fixes and diagnostic bisect switches:

Changes

  1. skip_placeholders is now OFF by default: Previously absent_mode_raw() == 0 enabled an infinite TTL on placeholder_absent, skipping VirtualQuery probes on placeholder holes permanently unless title_memory_remapped / title_memory_committed fired. guard_policy() now keeps skip_placeholders OFF by default—enabled only with VICTORY_PLACEHOLDER_SKIP=1, or with VICTORY_ABSENT_ONCE=1 + VICTORY_ABSENT_MS=told when VICTORY_PLACEHOLDER_SKIP is unset—while keeping O(1)-per-OS-region uncommitted_end() region skipping active.
  2. Concurrent remap PAGE_READWRITE restoration in title_memory_remapped: Our new multi-threaded remap + write-fault stress test caught a concrete race where guard() protects newly mapped pages between MapViewOfFile3 and xmem::map's title_memory_remapped(), which previously evicted those runs from g.protected without calling VirtualProtect(..., PAGE_READWRITE) and left orphaned PAGE_READONLY pages (0xc0000005 on write). title_memory_remapped now restores PAGE_READWRITE (unprotect_run_os_with) when evicting guarded runs.
  3. !alias_batch lock-free clear ordering & VEH OnceLock pre-warming: open_with(..., alias_batch=false) now clears PUBLISHED + g.aliased across all aliases before making primary blocks writable, and install() pre-warms watch_coalesce() and watch_alias_batch() alongside light_kept().

Zero-overhead OnceLock<bool> bisect switches

If anything still reproduces under heavy driving/streaming on 3287060, these switches isolate each subsystem independently:

  • VICTORY_PLACEHOLDER_SKIP=0|1 (default 0, unless VICTORY_ABSENT_ONCE=1 + VICTORY_ABSENT_MS=told)
  • VICTORY_WATCH_COALESCE=0|1 (default 1; 0 falls back to per-block VirtualProtect in protect_here, protect_alias_run, unprotect_run_os)
  • VICTORY_WATCH_ALIAS_BATCH=0|1 (default 1; 0 falls back to per-block views_between + pages_of)
  • VICTORY_WATCH_SINGLE_LOCK=0|1 (default 1; 0 disables try_guard_if_known single-lock fast path)

Verification (on e4245f3 -> 3287060)

  • cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings -A deprecated (default & --features diagnostics): 0 warnings in watch.rs / inplace.rs (only 3 pre-existing deprecated warnings in object.rs).
  • VICTORY_D3D12_DEBUG=1 cargo test --locked -p victory-gpu --lib -- --test-threads=1:
    • default features: 235 passed; 0 failed; 6 ignored
    • --features diagnostics: 254 passed; 0 failed; 7 ignored
    • Includes new tests: default_placeholder_redetects_silent_map_without_remapped_notification, remap_notification_restores_writable_after_concurrent_protect, bisect_switches_parse_and_disable_paths_correctly, and concurrent_remap_and_write_fault_stress.
**@⁠Vladimir-Human** on GitHub · 2026-11-26 16:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7197876402) @⁠Garu667 Thank you for the detailed follow-up and driving repro. Rebased onto `main` (`e4245f3` -> `3287060`) with the following fixes and diagnostic bisect switches: ### Changes 1. **`skip_placeholders` is now OFF by default:** Previously `absent_mode_raw() == 0` enabled an infinite TTL on `placeholder_absent`, skipping `VirtualQuery` probes on placeholder holes permanently unless `title_memory_remapped` / `title_memory_committed` fired. `guard_policy()` now keeps `skip_placeholders` OFF by default—enabled only with `VICTORY_PLACEHOLDER_SKIP=1`, or with `VICTORY_ABSENT_ONCE=1` + `VICTORY_ABSENT_MS=told` when `VICTORY_PLACEHOLDER_SKIP` is unset—while keeping `O(1)`-per-OS-region `uncommitted_end()` region skipping active. 2. **Concurrent remap `PAGE_READWRITE` restoration in `title_memory_remapped`:** Our new multi-threaded remap + write-fault stress test caught a concrete race where `guard()` protects newly mapped pages between `MapViewOfFile3` and `xmem::map`'s `title_memory_remapped()`, which previously evicted those runs from `g.protected` without calling `VirtualProtect(..., PAGE_READWRITE)` and left orphaned `PAGE_READONLY` pages (`0xc0000005` on write). `title_memory_remapped` now restores `PAGE_READWRITE` (`unprotect_run_os_with`) when evicting guarded runs. 3. **`!alias_batch` lock-free clear ordering & VEH `OnceLock` pre-warming:** `open_with(..., alias_batch=false)` now clears `PUBLISHED` + `g.aliased` across all aliases before making primary blocks writable, and `install()` pre-warms `watch_coalesce()` and `watch_alias_batch()` alongside `light_kept()`. ### Zero-overhead `OnceLock<bool>` bisect switches If anything still reproduces under heavy driving/streaming on `3287060`, these switches isolate each subsystem independently: - `VICTORY_PLACEHOLDER_SKIP=0|1` (default `0`, unless `VICTORY_ABSENT_ONCE=1` + `VICTORY_ABSENT_MS=told`) - `VICTORY_WATCH_COALESCE=0|1` (default `1`; `0` falls back to per-block `VirtualProtect` in `protect_here`, `protect_alias_run`, `unprotect_run_os`) - `VICTORY_WATCH_ALIAS_BATCH=0|1` (default `1`; `0` falls back to per-block `views_between` + `pages_of`) - `VICTORY_WATCH_SINGLE_LOCK=0|1` (default `1`; `0` disables `try_guard_if_known` single-lock fast path) ### Verification (on `e4245f3` -> `3287060`) - `cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings -A deprecated` (default & `--features diagnostics`): 0 warnings in `watch.rs` / `inplace.rs` (only 3 pre-existing `deprecated` warnings in `object.rs`). - `VICTORY_D3D12_DEBUG=1 cargo test --locked -p victory-gpu --lib -- --test-threads=1`: - default features: `235 passed; 0 failed; 6 ignored` - `--features diagnostics`: `254 passed; 0 failed; 7 ignored` - Includes new tests: `default_placeholder_redetects_silent_map_without_remapped_notification`, `remap_notification_restores_writable_after_concurrent_protect`, `bisect_switches_parse_and_disable_paths_correctly`, and `concurrent_remap_and_write_fault_stress`.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 23:07 UTC · original

An in-game data point for the placeholder part, from a much smaller change than this PR (so it says nothing about the interval containers or the coalesced VirtualProtect runs).

What I measured first. RTX 3090 Ti, Ryzen 9 9950X3D, Windows 11, Series S profile, prologue cell, on #994's head + #911 + #868. The sampling profiler had the submitting thread 8.5 ms a frame in VirtualQuery directly under watch::guard. VICTORY_VIEW_KNOWN=1 did not move it, so it is not is_view: it is uncommitted_end, asked once per run of absent blocks at every asking, because an ordinary reservation can be committed with no word to the guards.

The small version: the runtime tells the guards which reservations are placeholders (from XMemVirtualAlloc, where it makes them), and guard leaves a block noted absent inside one as it is. Only xmem::map makes memory appear there, and it already calls title_memory_remapped, which forgets the blocks' absence. Ordinary reservations are asked as before. About 90 lines: 3524388 (VICTORY_ABSENT_ONCE=0 turns it off).

before with it
VirtualQuery under watch::guard, submitting thread 8.5 ms a frame not in the profile
"copies" on the frame line 25.5 ms 15.8 ms
frame 64.5 ms 61 ms

Picture the same in the cell, 0 exceptions, one 6-minute run each way. That matches the 9.3 → 0.7 ms @⁠HLVM04 reported above for the same idea. If the maintainers would rather have the narrow change than wait for the larger one, I can open it as a PR against main; it has not been built or run on main yet.

Numbers and text only. AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 23:07 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7205279166) An in-game data point for the placeholder part, from a much smaller change than this PR (so it says nothing about the interval containers or the coalesced `VirtualProtect` runs). **What I measured first.** RTX 3090 Ti, Ryzen 9 9950X3D, Windows 11, Series S profile, prologue cell, on #994's head + #911 + #868. The sampling profiler had the submitting thread 8.5 ms a frame in `VirtualQuery` directly under `watch::guard`. `VICTORY_VIEW_KNOWN=1` did not move it, so it is not `is_view`: it is `uncommitted_end`, asked once per run of absent blocks at every asking, because an ordinary reservation can be committed with no word to the guards. **The small version:** the runtime tells the guards which reservations are placeholders (from `XMemVirtualAlloc`, where it makes them), and `guard` leaves a block noted absent inside one as it is. Only `xmem::map` makes memory appear there, and it already calls `title_memory_remapped`, which forgets the blocks' absence. Ordinary reservations are asked as before. About 90 lines: [3524388](https://github.com/KyleS98/VIctory-Neo/commit/3524388) (`VICTORY_ABSENT_ONCE=0` turns it off). | | before | with it | |---|---|---| | `VirtualQuery` under `watch::guard`, submitting thread | 8.5 ms a frame | not in the profile | | "copies" on the frame line | 25.5 ms | 15.8 ms | | frame | 64.5 ms | 61 ms | Picture the same in the cell, 0 exceptions, one 6-minute run each way. That matches the 9.3 → 0.7 ms @⁠HLVM04 reported above for the same idea. If the maintainers would rather have the narrow change than wait for the larger one, I can open it as a PR against `main`; it has not been built or run on `main` yet. Numbers and text only. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 23:30 UTC · original

A correction to my comment above: I offered to open the narrow change as a PR against main, but main already has it. I had measured on an older base (#994's head) and had not looked at current main before writing.

main carries VICTORY_ABSENT_ONCE=1 (commit 44bff61, off by default): a block found uncommitted is not asked about again for VICTORY_ABSENT_MS (100 ms), and with VICTORY_ABSENT_MS=told not until the runtime tells of it, which is the rule my change applies to placeholders. So there is nothing for me to send; the numbers above (8.5 ms a frame of VirtualQuery under watch::guard gone, 64.5 → 61 ms a frame on an RTX 3090 Ti) can be read as a data point for that switch's told form on another card, measured on another tree.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 23:30 UTC · [original](https://github.com/fxceless/victory-fork/pull/1279#issuecomment-7205600730) A correction to my comment above: I offered to open the narrow change as a PR against `main`, but `main` already has it. I had measured on an older base (#994's head) and had not looked at current `main` before writing. `main` carries `VICTORY_ABSENT_ONCE=1` (commit `44bff61`, off by default): a block found uncommitted is not asked about again for `VICTORY_ABSENT_MS` (100 ms), and with `VICTORY_ABSENT_MS=told` not until the runtime tells of it, which is the rule my change applies to placeholders. So there is nothing for me to send; the numbers above (8.5 ms a frame of `VirtualQuery` under `watch::guard` gone, 64.5 → 61 ms a frame on an RTX 3090 Ti) can be read as a data point for that switch's `told` form on another card, measured on another tree. AI-assisted (Claude Code, Claude Fable 5.2).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/watch.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1279'
git switch 'github-bot/gh-1279'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1279'
git switch 'github-bot/gh-1279'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1279'
git switch 'main'
git merge --squash 'github-bot/gh-1279'
git switch 'main'
git merge --ff-only 'github-bot/gh-1279'
git switch 'main'
git merge 'github-bot/gh-1279'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.