perf(xmem): write-watch large XMemAllocDefault allocations #1038

Merged
shreezzz merged 2 commits from upstream-pr/1038 into main 2026-11-29 08:16:57 +00:00
shreezzz commented 2026-11-28 11:50:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by shreezzz on 2026-11-28T11:50:21Z.


Summary

Large heap allocations from XMemAllocDefault (notably a 20.1 MiB / 0x1412200 GPU-written scratch buffer) currently bypass MEM_WRITE_WATCH. Because watch::writes() returns None and the range isn't registered as view memory, Shadow refreshes copy the entire buffer whole every frame (~40.7 MB/frame) even when the CPU writes nothing to it.

This PR routes large XMemAllocDefault allocations (>= 1 MiB padded size) through write-watched virtual reservations (VICTORY_WATCH_LARGE_XMEM=0 restores the heap path, default enabled) and also tries MEM_WRITE_WATCH on eligible non-placeholder explicit-address reservations in XMemVirtualAlloc.

Changes (crates/victory-hle/src/modules/xmem.rs)

  • Route XMemAllocDefault requests >= 1 MiB padded size to VirtualAlloc2 with MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, always passing MEM_ADDRESS_REQUIREMENTS from address_range(0) (keeping 64-bit allocations out of the low 4 GiB reserved for 32-bit requests and within the 64-bit upper bound, while honoring alignments above 64 KiB including 2 MiB).
  • Ensure the header fits safely at minimum alignment and stores the exact reservation base so XMemFreeDefault releases via VirtualFree(base, 0, MEM_RELEASE).
  • Try MEM_WRITE_WATCH on eligible explicit-address non-placeholder reservations in XMemVirtualAlloc, safely falling back to the original flags if Windows refuses.

Verification

  • Unit tests: cargo test -p victory-hle --locked modules::xmem passed (22 passed, 1 benchmark ignored), including regression coverage for MEM_WRITE_WATCH and address_range(0) bounds at minimum, 64 KiB, and 2 MiB alignments (and verified with VICTORY_WATCH_LARGE_XMEM=0).
  • Workspace check: cargo check --locked --workspace passed.

Same-Binary A/B Benchmark (--release --features diagnostics)

Seeded Re-Verification on 63b902f

Tested with the identical binary (VICTORY_WATCH_LARGE_XMEM=0 vs =1) from fresh copies of the same post-intro save and warmed shader cache on RTX 3070 8 GB / 16 GB RAM (--console series-s, windowed 1920x1080), 20 settled <150 ms reports per arm after 30 s warm-up (medians; Control @ 4,452 draws, Treatment @ 4,529 draws):

Metric Control (=0) Treatment (=1) Delta
copied whole 6.95 ms / 42.50 MB 0.10 ms / 0.40 MB -99.1% volume / -6.85 ms
Total copies 27.60 ms / 114.60 MB 21.75 ms / 93.95 MB -5.85 ms / -20.65 MB
FPS / frame ms 12.70 / 78.80 ms 13.00 / 77.05 ms +0.30 fps / -1.75 ms

Initial A/B on a4d05e7

Same-binary A/B on RTX 3070 8 GB / 16 GB RAM (--console series-s, windowed 1920x1080), 28 settled reports after 30 s warm-up in the shared 5,000-5,999 draw band (medians; Control n=22 @ 5,404 draws, Treatment n=7 @ 5,921 draws):

Metric Control (=0) Treatment (=1) Delta
copied whole 6.50 ms / 41.15 MB 0.10 ms / 0.40 MB -99% volume / -6.40 ms
Total copies 23.60 ms / 106.75 MB 17.00 ms / 79.30 MB -6.60 ms / -27.45 MB
Top unwatched whole copy (+0x1412200) 40.71 MB/frame Eliminated (max 0.24 MB) Gone
+0x1412200 bus traffic 21.05 MB up, 21.04 MB back 0.00 MB up, 21.04 MB back -21.05 MB/frame up
copy-back / GPU wait 47.25 ms / 0.00 ms 50.50 ms / 7.20 ms Unchanged (50.5 ms bottleneck dominates)
FPS / frame ms 11.80 / 84.55 ms 11.90 / 83.70 ms Flat (masked by 50.5 ms copy-back + heavier draws)

Credits

  • Assisted by OpenAI Codex and Google Gemini.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539824085 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038). Originally posted by [shreezzz](https://github.com/shreezzz) on 2026-11-28T11:50:21Z. --- ## Summary Large heap allocations from `XMemAllocDefault` (notably a 20.1 MiB / `0x1412200` GPU-written scratch buffer) currently bypass `MEM_WRITE_WATCH`. Because `watch::writes()` returns `None` and the range isn't registered as view memory, `Shadow` refreshes copy the entire buffer whole every frame (`~40.7 MB/frame`) even when the CPU writes nothing to it. This PR routes large `XMemAllocDefault` allocations (`>= 1 MiB` padded size) through write-watched virtual reservations (`VICTORY_WATCH_LARGE_XMEM=0` restores the heap path, default enabled) and also tries `MEM_WRITE_WATCH` on eligible non-placeholder explicit-address reservations in `XMemVirtualAlloc`. ## Changes (`crates/victory-hle/src/modules/xmem.rs`) - Route `XMemAllocDefault` requests `>= 1 MiB` padded size to `VirtualAlloc2` with `MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH`, always passing `MEM_ADDRESS_REQUIREMENTS` from `address_range(0)` (keeping 64-bit allocations out of the low 4 GiB reserved for 32-bit requests and within the 64-bit upper bound, while honoring alignments above 64 KiB including 2 MiB). - Ensure the header fits safely at minimum alignment and stores the exact reservation base so `XMemFreeDefault` releases via `VirtualFree(base, 0, MEM_RELEASE)`. - Try `MEM_WRITE_WATCH` on eligible explicit-address non-placeholder reservations in `XMemVirtualAlloc`, safely falling back to the original flags if Windows refuses. ## Verification - **Unit tests:** `cargo test -p victory-hle --locked modules::xmem` passed (22 passed, 1 benchmark ignored), including regression coverage for `MEM_WRITE_WATCH` and `address_range(0)` bounds at minimum, 64 KiB, and 2 MiB alignments (and verified with `VICTORY_WATCH_LARGE_XMEM=0`). - **Workspace check:** `cargo check --locked --workspace` passed. ### Same-Binary A/B Benchmark (`--release --features diagnostics`) #### Seeded Re-Verification on `63b902f` Tested with the identical binary (`VICTORY_WATCH_LARGE_XMEM=0` vs `=1`) from fresh copies of the same post-intro save and warmed shader cache on RTX 3070 8 GB / 16 GB RAM (`--console series-s`, windowed 1920x1080), 20 settled `<150 ms` reports per arm after 30 s warm-up (medians; Control @ `4,452` draws, Treatment @ `4,529` draws): | Metric | Control (`=0`) | Treatment (`=1`) | Delta | |---|---:|---:|---:| | `copied whole` | `6.95 ms / 42.50 MB` | **`0.10 ms / 0.40 MB`** | **-99.1% volume / -6.85 ms** | | Total `copies` | `27.60 ms / 114.60 MB` | **`21.75 ms / 93.95 MB`** | **-5.85 ms / -20.65 MB** | | FPS / frame ms | `12.70 / 78.80 ms` | **`13.00 / 77.05 ms`** | **+0.30 fps / -1.75 ms** | #### Initial A/B on `a4d05e7` Same-binary A/B on RTX 3070 8 GB / 16 GB RAM (`--console series-s`, windowed 1920x1080), 28 settled reports after 30 s warm-up in the shared `5,000-5,999` draw band (medians; Control n=22 @ `5,404` draws, Treatment n=7 @ `5,921` draws): | Metric | Control (`=0`) | Treatment (`=1`) | Delta | |---|---:|---:|---:| | `copied whole` | `6.50 ms / 41.15 MB` | **`0.10 ms / 0.40 MB`** | **-99% volume / -6.40 ms** | | Total `copies` | `23.60 ms / 106.75 MB` | **`17.00 ms / 79.30 MB`** | **-6.60 ms / -27.45 MB** | | Top unwatched whole copy (`+0x1412200`) | `40.71 MB/frame` | **Eliminated** (max `0.24 MB`) | **Gone** | | `+0x1412200` bus traffic | `21.05 MB up, 21.04 MB back` | **`0.00 MB up, 21.04 MB back`** | **-21.05 MB/frame up** | | `copy-back` / `GPU wait` | `47.25 ms` / `0.00 ms` | `50.50 ms` / `7.20 ms` | Unchanged (`50.5 ms` bottleneck dominates) | | FPS / frame ms | `11.80 / 84.55 ms` | `11.90 / 83.70 ms` | Flat (masked by `50.5 ms` copy-back + heavier draws) | ## Credits - Assisted by OpenAI Codex and Google Gemini.
urielbeaupre commented 2026-11-28 12:25:11 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by urielbeaupre on 2026-11-28T12:25:11Z.


Independent confirmation from an in-game A/B. I tested my own port of the same idea (TaynanGT/Vice-Tay#321: XMemAllocDefault blocks of 64 KiB and up come from MEM_WRITE_WATCH memory). For the 21 MB 0x1412200 buffer it does what this PR does, so I'm not opening a second PR.

RTX 4070 Ti 12 GB, Ryzen 9 7900X, Series S profile, DLSS off, the same save, runs alternated on/off. Measured over seconds 60–110 after input (a cutscene), 10 readings each:

Run write-watched fps CPU preparing copied per frame
2 no 33.1 24.3 ms 72.9 MB
3 yes 35.5 22.6 ms 52.0 MB
4 no 34.2 23.8 ms 72.0 MB
7 yes 37.8 21.0 ms 52.6 MB
8 no 36.2 22.2 ms 70.1 MB

Every run with it copied about 20 MB less per frame and spent 1.2–1.7 ms less CPU preparing each frame. Each run with it beat the run without it next to it, by +1.6 to +2.4 fps. After the scene change, runs vary more than the change does (20–26 fps either way), so I don't claim anything there. I saw no visual problems.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239214332 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7239214332). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T12:25:11Z. --- Independent confirmation from an in-game A/B. I tested my own port of the same idea (TaynanGT/Vice-Tay#321: `XMemAllocDefault` blocks of 64 KiB and up come from `MEM_WRITE_WATCH` memory). For the 21 MB `0x1412200` buffer it does what this PR does, so I'm not opening a second PR. RTX 4070 Ti 12 GB, Ryzen 9 7900X, Series S profile, DLSS off, the same save, runs alternated on/off. Measured over seconds 60–110 after input (a cutscene), 10 readings each: | Run | write-watched | fps | CPU preparing | copied per frame | |---|---|---|---|---| | 2 | no | 33.1 | 24.3 ms | 72.9 MB | | 3 | **yes** | 35.5 | 22.6 ms | 52.0 MB | | 4 | no | 34.2 | 23.8 ms | 72.0 MB | | 7 | **yes** | 37.8 | 21.0 ms | 52.6 MB | | 8 | no | 36.2 | 22.2 ms | 70.1 MB | Every run with it copied about 20 MB less per frame and spent 1.2–1.7 ms less CPU preparing each frame. Each run with it beat the run without it next to it, by +1.6 to +2.4 fps. After the scene change, runs vary more than the change does (20–26 fps either way), so I don't claim anything there. I saw no visual problems. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Exopus-0x65f7ad0 commented 2026-11-28 13:02:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Exopus-0x65f7ad0 on 2026-11-28T13:02:37Z.


Nice find on the +0x1412200 whole copy. One placement question about watched_reservation.

XMemVirtualAlloc keeps 64-bit title memory out of the low 4 GiB on purpose: address_range starts at 1 << 32 and keeps the low 4 GiB for ADDRESS_32BIT requests. watched_reservation passes no address bounds (LowestStartingAddress / HighestEndingAddress unset). Windows places such reservations bottom-up, so early in a run these ≥ 1 MiB blocks can land in the low 4 GiB and use up the room that ALLOC_32BIT / GRAPHICS | ADDRESS_32BIT requests rely on later. The heap path did not hand out those addresses for large blocks before, at least going by the comment just above, so this would be a new pressure on that range.

It also interacts with #1041, which caps 64-bit title memory below 2^37, the GPU's by-address directory. An unbounded reservation does not get that cap.

Reusing the existing bounds would cover both:

let (lowest, highest) = address_range(0); // 64-bit, no field
let mut requirements = MEM_ADDRESS_REQUIREMENTS {
    LowestStartingAddress: lowest as *mut c_void,
    HighestEndingAddress: highest as *mut c_void,
    Alignment: if large_align { layout.align() } else { 0 },
};
// and always pass the parameter (count 1)

On native Windows (RTX 5060 Ti / 16 GB), title addresses in my logs today stayed between 4 GiB and about 75 GiB, so the upper cap is mostly insurance. The low-4-GiB part is the one I'd worry about on 16 GB machines that load many large buffers.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239647686 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7239647686). Originally posted by [Exopus-0x65f7ad0](https://github.com/Exopus-0x65f7ad0) on 2026-11-28T13:02:37Z. --- Nice find on the `+0x1412200` whole copy. One placement question about `watched_reservation`. `XMemVirtualAlloc` keeps 64-bit title memory out of the low 4 GiB on purpose: `address_range` starts at `1 << 32` and keeps the low 4 GiB for `ADDRESS_32BIT` requests. `watched_reservation` passes no address bounds (`LowestStartingAddress` / `HighestEndingAddress` unset). Windows places such reservations bottom-up, so early in a run these ≥ 1 MiB blocks can land **in the low 4 GiB** and use up the room that `ALLOC_32BIT` / `GRAPHICS | ADDRESS_32BIT` requests rely on later. The heap path did not hand out those addresses for large blocks before, at least going by the comment just above, so this would be a new pressure on that range. It also interacts with #1041, which caps 64-bit title memory below 2^37, the GPU's by-address directory. An unbounded reservation does not get that cap. Reusing the existing bounds would cover both: ```rust let (lowest, highest) = address_range(0); // 64-bit, no field let mut requirements = MEM_ADDRESS_REQUIREMENTS { LowestStartingAddress: lowest as *mut c_void, HighestEndingAddress: highest as *mut c_void, Alignment: if large_align { layout.align() } else { 0 }, }; // and always pass the parameter (count 1) ``` On native Windows (RTX 5060 Ti / 16 GB), title addresses in my logs today stayed between 4 GiB and about 75 GiB, so the upper cap is mostly insurance. The low-4-GiB part is the one I'd worry about on 16 GB machines that load many large buffers.
shreezzz commented 2026-11-28 14:16:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by shreezzz on 2026-11-28T14:16:46Z.


@Exopus-0x65f7ad0 Good catch, pushed 7cd552b to pass MEM_ADDRESS_REQUIREMENTS from address_range(0) (LowestStartingAddress, HighestEndingAddress, Alignment: if large_align { layout.align() } else { 0 }, count 1) on every watched_reservation call, keeping large blocks out of the low 4 GiB and within the 64-bit upper bound (including compatibility with #1041). Also extended large_default_allocations_honour_write_watch_switch to assert those bounds across min, 64 KiB, and 2 MiB alignments (22/22 victory-hle xmem tests + VICTORY_WATCH_LARGE_XMEM=0 + cargo check --locked --workspace passing).

Generated by OpenAI Codex and Google Gemini.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7240551212 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7240551212). Originally posted by [shreezzz](https://github.com/shreezzz) on 2026-11-28T14:16:46Z. --- @Exopus-0x65f7ad0 Good catch, pushed `7cd552b` to pass `MEM_ADDRESS_REQUIREMENTS` from `address_range(0)` (`LowestStartingAddress`, `HighestEndingAddress`, `Alignment: if large_align { layout.align() } else { 0 }`, count `1`) on every `watched_reservation` call, keeping large blocks out of the low 4 GiB and within the 64-bit upper bound (including compatibility with #1041). Also extended `large_default_allocations_honour_write_watch_switch` to assert those bounds across min, 64 KiB, and 2 MiB alignments (`22/22` `victory-hle` xmem tests + `VICTORY_WATCH_LARGE_XMEM=0` + `cargo check --locked --workspace` passing). *Generated by OpenAI Codex and Google Gemini.*
urielbeaupre commented 2026-11-28 14:50:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by urielbeaupre on 2026-11-28T14:50:57Z.


A second round with the low-4 GiB placement fix (same idea as 7cd552bd), in a rotation against main's behaviour. Same setup as before: RTX 4070 Ti 12 GB, Ryzen 9 7900X, Series S profile, DLSS off, same save. One build, with the switch alternated in the order A, B, A, B. Cutscene = seconds 60–110 after input; after = 110–165.

write-watched cutscene fps CPU preparing after scene change copied per frame (60–165 s)
A1 no 35.2 23.7 ms 22.9 14.0 ms, 84 MB
A2 no 36.7 21.7 ms 24.4 12.8 ms, 81 MB
B1 yes 37.3 20.8 ms 25.2 11.8 ms, 60 MB
B2 yes 38.6 20.2 ms 27.0 11.5 ms, 59 MB

The averages: +2.0 fps in the cutscene (36.0 → 38.0) and +2.5 after the scene change (23.7 → 26.1). The CPU spends 2.2 ms less preparing each frame and about 1.8 ms less copying, and about 22 MB less goes up per frame. No errors and no visual differences. This confirms the earlier round, and adds the gain after the scene change, which the first round couldn't separate from noise.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7240983245 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7240983245). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T14:50:57Z. --- A second round with the low-4 GiB placement fix (same idea as 7cd552bd), in a rotation against main's behaviour. Same setup as before: RTX 4070 Ti 12 GB, Ryzen 9 7900X, Series S profile, DLSS off, same save. One build, with the switch alternated in the order A, B, A, B. Cutscene = seconds 60–110 after input; after = 110–165. | | write-watched | cutscene fps | CPU preparing | after scene change | copied per frame (60–165 s) | |---|---|---|---|---|---| | A1 | no | 35.2 | 23.7 ms | 22.9 | 14.0 ms, 84 MB | | A2 | no | 36.7 | 21.7 ms | 24.4 | 12.8 ms, 81 MB | | B1 | **yes** | 37.3 | 20.8 ms | 25.2 | 11.8 ms, 60 MB | | B2 | **yes** | 38.6 | 20.2 ms | 27.0 | 11.5 ms, 59 MB | The averages: **+2.0 fps in the cutscene (36.0 → 38.0) and +2.5 after the scene change (23.7 → 26.1)**. The CPU spends 2.2 ms less preparing each frame and about 1.8 ms less copying, and about 22 MB less goes up per frame. No errors and no visual differences. This confirms the earlier round, and adds the gain after the scene change, which the first round couldn't separate from noise. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
POMXARK commented 2026-11-28 16:12:32 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-28T16:12:32Z.


Tested this PR in a 20-minute 1440p DLSS Quality + MFG 4x A/B run on Ryzen 7 5700X (8C/16T) + RTX 5080 (16 GB) + 32 GB RAM (VICTORY_WAIT_RESIDENT=0, VICTORY_RELAY=2, VICTORY_CARD_STEPS=2, VICTORY_THIN=1, VICTORY_JOIN_COPIES=1, VICTORY_JOIN_PARTS=8, VICTORY_LAND_SKIP=1, VICTORY_WATCH_LARGE_XMEM=1 default).

Unit Tests & Stability

  • cargo test --release -p victory-hle --lib -- xmem:: --test-threads=4: 23/23 PASS (0.12 s), including large_default_allocations_honour_write_watch_switch.
  • 20-minute continuous 3D workload: 0 engine/D3D12/xmem errors, 0 DeviceRemoved/DEVICE_HUNG, 0 guest exceptions, 0 bake stalls, 0 XMemVirtualAlloc placement taken unwatched warnings, visually clean output throughout.

20-Minute A/B Results (vs same branch without PR #1038)

Metric Baseline + PR #1038 (WATCH_LARGE_XMEM=1) Delta
ALL 3D FPS (p50 / mean) 14.7 / 14.04 15.0 / 14.23 +2.0% / +1.4%
ALL 3D Prep / copies (p50) 53.2 / 24.2 ms 49.7 / 21.3 ms -3.5 / -2.9 ms
submitting prep total / under (p50) 60.8 / 4.4 ms 57.7 / 3.4 ms -3.1 / -1.0 ms
1s frame_times (med / p95 / p99) 62.0 / 81.5 / 94.8 ms 61.0 / 80.4 / 90.4 ms -1.0 / -1.1 / -4.4 ms
Frames >100 ms (1s buckets) 1,407 1,301 -7.5%
1k–4k draws/frame (p50) 17.90 FPS 18.80 FPS +5.0%
4k–7k draws/frame (p50 / copies) 13.75 FPS / 25.5 ms 15.40 FPS / 21.3 ms +12.0% / -4.2 ms
7k–10k draws/frame (p50 / copies) 10.65 FPS / 39.8 ms 10.50 FPS / 39.5 ms -1.4% / -0.3 ms
>=10k draws/frame (p50 / mean) 12.20 / 11.24 FPS 13.60 / 12.14 FPS +11.5% / +8.0%
Peak Commit / Peak Shared 31,235 / 9,401 MB 29,548 / 8,876 MB -1,687 / -525 MB

Takeaway: Clean, low-risk win on a CPU-bound RTX 5080 setup (wait_fl = 0.1 ms): removing the unwatched large-buffer whole copies cuts submitting prep by -3.1 ms, trims p99 frame times by -4.4 ms, boosts 4k–7k by +12.0% and >=10k by +11.5%, and lowers peak commit by 1.69 GB.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7242056639 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7242056639). Originally posted by [POMXARK](https://github.com/POMXARK) on 2026-11-28T16:12:32Z. --- Tested this PR in a 20-minute 1440p DLSS Quality + MFG 4x A/B run on **Ryzen 7 5700X (8C/16T) + RTX 5080 (16 GB) + 32 GB RAM** (`VICTORY_WAIT_RESIDENT=0`, `VICTORY_RELAY=2`, `VICTORY_CARD_STEPS=2`, `VICTORY_THIN=1`, `VICTORY_JOIN_COPIES=1`, `VICTORY_JOIN_PARTS=8`, `VICTORY_LAND_SKIP=1`, `VICTORY_WATCH_LARGE_XMEM=1` default). ### Unit Tests & Stability - `cargo test --release -p victory-hle --lib -- xmem:: --test-threads=4`: **23/23 PASS** (`0.12 s`), including `large_default_allocations_honour_write_watch_switch`. - 20-minute continuous 3D workload: **0 engine/D3D12/xmem errors**, **0 `DeviceRemoved`/`DEVICE_HUNG`**, **0 guest exceptions**, **0 bake stalls**, **0 `XMemVirtualAlloc placement taken unwatched` warnings**, visually clean output throughout. ### 20-Minute A/B Results (vs same branch without PR #1038) | Metric | Baseline | + PR #1038 (`WATCH_LARGE_XMEM=1`) | Delta | |---|---:|---:|---:| | `ALL 3D` FPS (p50 / mean) | 14.7 / 14.04 | **15.0 / 14.23** | **+2.0% / +1.4%** | | `ALL 3D` Prep / `copies` (p50) | 53.2 / 24.2 ms | **49.7 / 21.3 ms** | **-3.5 / -2.9 ms** | | `submitting prep` total / `under` (p50) | 60.8 / 4.4 ms | **57.7 / 3.4 ms** | **-3.1 / -1.0 ms** | | `1s frame_times` (med / p95 / p99) | 62.0 / 81.5 / 94.8 ms | **61.0 / 80.4 / 90.4 ms** | **-1.0 / -1.1 / -4.4 ms** | | Frames `>100 ms` (1s buckets) | 1,407 | **1,301** | **-7.5%** | | `1k–4k` draws/frame (p50) | 17.90 FPS | **18.80 FPS** | **+5.0%** | | `4k–7k` draws/frame (p50 / `copies`) | 13.75 FPS / 25.5 ms | **15.40 FPS / 21.3 ms** | **+12.0% / -4.2 ms** | | `7k–10k` draws/frame (p50 / `copies`) | 10.65 FPS / 39.8 ms | 10.50 FPS / **39.5 ms** | -1.4% / -0.3 ms | | `>=10k` draws/frame (p50 / mean) | 12.20 / 11.24 FPS | **13.60 / 12.14 FPS** | **+11.5% / +8.0%** | | Peak Commit / Peak Shared | 31,235 / 9,401 MB | **29,548 / 8,876 MB** | **-1,687 / -525 MB** | **Takeaway:** Clean, low-risk win on a CPU-bound RTX 5080 setup (`wait_fl = 0.1 ms`): removing the unwatched large-buffer whole copies cuts `submitting prep` by **-3.1 ms**, trims `p99` frame times by **-4.4 ms**, boosts `4k–7k` by **+12.0%** and `>=10k` by **+11.5%**, and lowers peak commit by **1.69 GB**.
Marsietiss commented 2026-11-28 19:18:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Marsietiss on 2026-11-28T19:18:28Z.


Data point from our tree (RTX 5080, Series S mode, #1038 ported plus the 7cd552bd6 address_range(0) bounds fix): VICTORY_WATCH_LARGE_XMEM=1 still gave flickering ground. Bisect: the flicker was gone with VICTORY_WATCH_LARGE_XMEM=0 at otherwise identical settings (same texture caps, same build line), and stayed gone after a live flip of the texture cap, so in our case it is this switch and not the texture side. Before the bounds fix, our port also allowed blocks of 1 MiB or more above TITLE_TOP_BITS=37; with the bounds fix in, the flicker was still there. We have not found which large allocation is involved. Keeping it at 0 on our side for now; glad to test a variant if you have one in mind.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244446217 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7244446217). Originally posted by [Marsietiss](https://github.com/Marsietiss) on 2026-11-28T19:18:28Z. --- Data point from our tree (RTX 5080, Series S mode, #1038 ported plus the `7cd552bd6` `address_range(0)` bounds fix): `VICTORY_WATCH_LARGE_XMEM=1` still gave flickering ground. Bisect: the flicker was gone with `VICTORY_WATCH_LARGE_XMEM=0` at otherwise identical settings (same texture caps, same build line), and stayed gone after a live flip of the texture cap, so in our case it is this switch and not the texture side. Before the bounds fix, our port also allowed blocks of 1 MiB or more above `TITLE_TOP_BITS=37`; with the bounds fix in, the flicker was still there. We have not found which large allocation is involved. Keeping it at 0 on our side for now; glad to test a variant if you have one in mind.
shreezzz commented 2026-11-28 20:04:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by shreezzz on 2026-11-28T20:04:44Z.


@Marsietiss traced 7832421 + 7cd552b against watch.rs, dstorage.rs, and texture.rs and found why making >= 1 MiB XMemAllocDefault allocations write-watched (=1) can drop updates where =0 (whole-copy) didn't:

  1. VA reuse without JOURNAL reset (watch.rs:1380, 2854): VirtualAlloc2(..., MEM_WRITE_WATCH) hands out zero-filled pages with clean dirty bits, and title_memory_allocated/title_memory_freed don't bump JOURNAL or j.ahead — so surviving LOOSE Shadows / Staging textures on a recycled VA keep stale bytes.
  2. DirectStorage FILE_FLAG_NO_BUFFERING writes (dstorage.rs → watch.rs:2524): title_memory_written(..., false) returns early under VICTORY_PAGE_WRITES=1 without bumping JOURNAL (and can be masked during ask_once).
  3. Textures skipping digest() (texture.rs:1452): Staging::refresh_timed now gets Some from watch::writes(..., false) and trusts JOURNAL + j.ahead instead of hashing self.memory, even though Host::submit only populates ask_once from Shadow spans.

If you're up for a quick 1-minute bisect with VICTORY_WATCH_LARGE_XMEM=1 on your tree:

  • First try VICTORY_REFRESH_CHECK=1 (if it logs a host copy of title memory is stale after its refresh, it'll name the exact Shadow span).
  • If it stays silent while ground still flickers, toggling VICTORY_ASK_ONCE=0, VICTORY_PAGE_PARTS=0, VICTORY_LAND_ECHO=0, or VICTORY_RELAY=0 one at a time will pinpoint whether it's dstorage/Staging during ask_once, 4 KiB VA reuse, or merge_under_writes.

also preparing a watch.rs coherence fix (JOURNAL/j.ahead updates on title_memory_allocated/freed + title_memory_written) to test alongside this!

🤖 Assisted by OpenAI Codex & Google Gemini

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245018730 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7245018730). Originally posted by [shreezzz](https://github.com/shreezzz) on 2026-11-28T20:04:44Z. --- @Marsietiss traced `7832421` + `7cd552b` against `watch.rs`, `dstorage.rs`, and `texture.rs` and found why making `>= 1 MiB` `XMemAllocDefault` allocations write-watched (`=1`) can drop updates where `=0` (whole-copy) didn't: 1. **VA reuse without `JOURNAL` reset (`watch.rs:1380, 2854`):** `VirtualAlloc2(..., MEM_WRITE_WATCH)` hands out zero-filled pages with clean dirty bits, and `title_memory_allocated`/`title_memory_freed` don't bump `JOURNAL` or `j.ahead` — so surviving `LOOSE` `Shadow`s / `Staging` textures on a recycled VA keep stale bytes. 2. **DirectStorage `FILE_FLAG_NO_BUFFERING` writes (`dstorage.rs` → `watch.rs:2524`):** `title_memory_written(..., false)` returns early under `VICTORY_PAGE_WRITES=1` without bumping `JOURNAL` (and can be masked during `ask_once`). 3. **Textures skipping `digest()` (`texture.rs:1452`):** `Staging::refresh_timed` now gets `Some` from `watch::writes(..., false)` and trusts `JOURNAL + j.ahead` instead of hashing `self.memory`, even though `Host::submit` only populates `ask_once` from `Shadow` spans. If you're up for a quick 1-minute bisect with `VICTORY_WATCH_LARGE_XMEM=1` on your tree: - First try **`VICTORY_REFRESH_CHECK=1`** (if it logs `a host copy of title memory is stale after its refresh`, it'll name the exact `Shadow` span). - If it stays silent while ground still flickers, toggling **`VICTORY_ASK_ONCE=0`**, **`VICTORY_PAGE_PARTS=0`**, **`VICTORY_LAND_ECHO=0`**, or **`VICTORY_RELAY=0`** one at a time will pinpoint whether it's `dstorage`/`Staging` during `ask_once`, 4 KiB VA reuse, or `merge_under_writes`. also preparing a `watch.rs` coherence fix (`JOURNAL`/`j.ahead` updates on `title_memory_allocated`/`freed` + `title_memory_written`) to test alongside this! 🤖 Assisted by [OpenAI Codex](https://openai.com/codex) & [Google Gemini](https://gemini.google.com)
Marsietiss commented 2026-11-28 21:05:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Marsietiss on 2026-11-28T21:05:56Z.


@shreezzz thanks for the trace and the recipe. Results on our current tree (Mangrove line, RTX 5080, Series S mode):

  • VICTORY_WATCH_LARGE_XMEM=1 + VICTORY_REFRESH_CHECK=1, 5-spot teleport burst: 0 a host copy of title memory is stale after its refresh lines. In that session no ground flicker was seen.
  • What we still see is intermittent flicker on leaves and power lines, and it shows with WATCH_LARGE_XMEM 0 and 1, with REFRESH_CHECK=1, and with LAZY_LAND=0. So on our tree that one looks like a rendering issue (thin / alpha-tested geometry), not the write-watch coherence you traced; we're checking it against #1407.
  • Caveat: the flicker is intermittent, so single-session "no flicker" calls are weak evidence; we're building a frozen-time frame-diff meter so this can be judged by numbers. We haven't run the ASK_ONCE / PAGE_PARTS / LAND_ECHO / RELAY toggles yet, since the refresh check stayed silent.

Happy to test your watch.rs coherence fix (JOURNAL / j.ahead on allocate/free + title_memory_written) when it's up.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245770410 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1038#issuecomment-7245770410). Originally posted by [Marsietiss](https://github.com/Marsietiss) on 2026-11-28T21:05:56Z. --- @shreezzz thanks for the trace and the recipe. Results on our current tree (Mangrove line, RTX 5080, Series S mode): - `VICTORY_WATCH_LARGE_XMEM=1` + `VICTORY_REFRESH_CHECK=1`, 5-spot teleport burst: **0** `a host copy of title memory is stale after its refresh` lines. In that session no ground flicker was seen. - What we still see is intermittent flicker on **leaves and power lines**, and it shows with `WATCH_LARGE_XMEM` 0 and 1, with `REFRESH_CHECK=1`, and with `LAZY_LAND=0`. So on our tree that one looks like a rendering issue (thin / alpha-tested geometry), not the write-watch coherence you traced; we're checking it against #1407. - Caveat: the flicker is intermittent, so single-session "no flicker" calls are weak evidence; we're building a frozen-time frame-diff meter so this can be judged by numbers. We haven't run the `ASK_ONCE` / `PAGE_PARTS` / `LAND_ECHO` / `RELAY` toggles yet, since the refresh check stayed silent. Happy to test your `watch.rs` coherence fix (JOURNAL / `j.ahead` on allocate/free + `title_memory_written`) when it's up.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!1038
No description provided.