Lazy landing and lazy fetch: what the GPU writes to memory the CPU never touches stays on the card (VICTORY_LAZY_LAND=1, VICTORY_LAZY_FETCH=1, on top of #1038) #1184

Closed
urielbeaupre wants to merge 11 commits from upstream-pr/1184 into main
urielbeaupre commented 2026-11-28 15:05:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by urielbeaupre on 2026-11-28T15:05:48Z.


Depends on #1038. This branch is #1038's two commits plus the ones here. Lazy landing only works on the write-watched private memory #1038 adds.

The finding

Every frame the GPU writes a 21 MB buffer (0x1412200, from XMemAllocDefault). The layer then does this with it:

  1. Lands it: fetches the card's bytes and merges them into title memory (land::piece → safecopy::merge), about 22 MB a frame.
  2. Echo-checks it: right after, the copy's own refresh reads all of it back from title memory (Shadow::take → take_landed → host::read) to see whether the CPU changed it.

The title never touches it. A fault probe, included here as VICTORY_READER_PROBE_LEN=1412200 (test only, off), makes the buffer's pages inaccessible once a second and records who faults, with the call chain. Over a full 165 s run there were 2 callers, both ours:

caller page touches share
host::read ← Shadow::take (refresh / echo check) ~350,000 66%
land::piece ← Shadow::land_card (landing merge) ~220,000 34%

The title's code made none. The buffer is still needed: skipping its landing outright (VICTORY_LAND_NEVER_LEN=1412200, test only) makes the echo check read stale title memory and send it up over the card's bytes, and the scene goes low-poly. So the GPU → title memory → GPU round trip has a consumer, but that consumer is only the copy itself.

The change: lazy landing (VICTORY_LAZY_LAND=1, off by default)

For a copy that lies whole in private write-watched memory (title_memory_private, marked from #1038's watched_reservation), is at least 1 MiB long and has no other live copy over it:

  • Landing: the card's bytes go into the copy's CPU side only. Those 4 KiB pages are marked ahead and made PAGE_NOACCESS. A page becomes ahead only if the landing covers all of it and title memory still equals the copy's CPU side. That compare runs with the page read-only first, so no title write can slip in.
  • Refresh: the copy skips its ahead pages and is stamped up to date with them (Shadow::landed_ahead). It does not re-read 21 MB a frame.
  • Other readers: textures, descriptors and other trackers are told the pages were written (Notes::ahead → watch::landed_beside). They re-read, fault, and get the GPU's bytes.
  • Demand: a vectored handler, first in the chain, catches any access to an ahead page. It makes the page read-write, copies the copy's CPU side in, one 4 KiB page at a time, then retries the access. host::read, write_mapped and the kernel-write hooks land their range first.
  • Back-off: more than 64 pages landed on demand in a second, or a new copy over the memory, turns lazy off for that copy for good (logged once).
  • Lifetime: freed or unmapped memory drops its ahead state and goes back to read-write. A dropped copy lands its pages first.
  • Locking: one RwLock per copy slot. Landing and refresh take it shared and never touch an ahead page under it. The fault handler takes it exclusively. A thread-local guard keeps a thread from re-entering. ASSIGN is always taken before a slot lock.

The log line, every 5 s:
lazy landing (VICTORY_LAZY_LAND=1): N copies lazy, X MB a frame landed into them alone (not into title memory), Y MB ahead now; per frame F faults on pages ahead, P pages landed on demand; K copies turned off since the start

In the runs below it reads: 1 copy lazy, 19.9 MB a frame, 0 faults, 0 turned off.

Measured

RTX 4070 Ti 12 GB, Ryzen 9 7900X, Series S profile, DLSS off, the same save, warm cache. One build, switches alternated. Cutscene = seconds 60–110 after input; after = 110–165.

Lazy landing on top of the write watch (VICTORY_LAZY_LAND 1/0, both with the write watch):

run lazy cutscene fps CPU preparing after scene change copying (60–165 s)
C1 on 41.5 18.2 ms 25.5 10.8 ms
B1 off 38.0 21.2 ms 24.1 13.3 ms
C2 on 41.4 17.7 ms 27.0 9.9 ms
B2 off 39.3 19.8 ms 24.6 12.4 ms

That's +2.8 fps in the cutscene (+7%) and +1.9 after the scene change (+8%), with 2.6–4.4 ms less CPU preparing a frame. Draw counts match on and off (about 1,400 in the cutscene, 3,400–3,750 after), and nothing looks different on screen.

Against main's behaviour, from an earlier rotation the same afternoon (the write watch off: 36.0 / 23.7 fps, see my second comment on #1038): #1038 alone gives about +2 fps, and with this on top it's about +5.5 fps (+15%) in the cutscene and +2.6 (+11%) after the scene change.

Lazy fetch (VICTORY_LAZY_FETCH=1, needs VICTORY_LAZY_LAND=1, off by default)

With lazy landing, the relay still fetched the lazy copy's flagged pieces every frame: a readback list and a wait, 6–7 ms of "copying back", only to put them in a CPU side nothing reads. With lazy fetch, those pages are not fetched at all.

  • Claim: pages of a lazy copy's flagged pieces are "claimed" by the card (Shadow::claim_card_only). They are marked card-only and NOACCESS, other readers are told they were written, and the copy is noted up to date. A page is refused if it has title bytes the card may not have: dirty, or sent after the fetches merged so far.
  • Never sent up: card_dirty leaves card-only pages out. If something marked one of them to go up, it is fetched first, then sent as the card's own bytes.
  • Demand: any touch goes to one fetch thread with its own copy queue: one CopyBufferRegion, no waits on other queues or fences, all D3D objects made at the first claim. It fetches every card-only page, lands them, and turns the copy off for good. The touching thread holds none of our locks while it waits, and the wait is timed, so the process can still exit. Flights still in the air are not waited for: their own landings merge what differs.
  • The log line adds: MB a frame not fetched, MB the card alone holds, fetches on demand, and why pages were fetched all the same.

Measured against lazy landing alone (same build, VICTORY_LAZY_FETCH 1/0, same setup as above). In game: 20.1 MB a frame not fetched, 0 pages refused, 0 fetches on demand, 0 errors.

run lazy fetch cutscene fps CPU preparing after scene change copying back
F1 on 42.9 18.8 ms 26.5 4.9 ms
L1 off 40.0 20.1 ms 25.1 6.7 ms
F2 on 41.8 19.3 ms 26.1 4.5 ms
L2 off 40.2 19.7 ms 24.7 6.5 ms

That's +2.3 fps in the cutscene and +1.4 after the scene change (both about +6%), with copy-back about 1.9 ms shorter. Draw counts match.

All together, in the cutscene: main about 36 fps → #1038 about 38 → lazy landing about 40 → lazy fetch about 42, roughly +17%. After the scene change: about 23.7 → 26.3 (+11%). These come from rotations in several sessions the same afternoon, so the total is approximate. Each step is measured against the one before it, in the same session.

Tests

  • cargo test -p victory-gpu --release --lib: the 12 new lazy tests pass. They cover the bitset and part arithmetic, eligibility, back-off and turn-off, the claim racing land_range, card-only pages never going up, a demand fetch bringing the card's bytes in, and the full path on real memory:
    • title memory stays stale after a lazy landing;
    • a CPU read, a write and read_into fault and get the GPU's bytes;
    • a refresh skips ahead pages, and the lazy copy copies 0 bytes while another tracker is still told;
    • freed memory keeps no NOACCESS pages;
    • several landing threads run with a concurrent reader.
  • indirect::tests::host_list_budget_starts_empty_at_each_submission and warp_batch_charges_every_execution fail, but they fail the same way on #1038's head without these commits.
  • cargo test -p victory-hle --release --lib: 183 passed.
  • Before opening this, independent reviews covered the locking, the demand path, readers outside the copies, the integration with #1038 and lazy fetch. Each issue they found is fixed in its own commit here.

Known limits

  • Kernel calls the runtime passes straight through (WriteFile, send/sendto from title memory): these would fail on an ahead page instead of faulting. The probe saw none of them on this buffer.
  • Copies that other copies overlap are never lazy. Lazy turns itself off when one appears.
  • Related: #420 aims at the same idea (keep GPU-produced bytes until the CPU asks) for section-backed pages. This covers private write-watched memory only.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5541495831 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T15:05:48Z. --- **Depends on #1038.** This branch is #1038's two commits plus the ones here. Lazy landing only works on the write-watched private memory #1038 adds. ## The finding Every frame the GPU writes a 21 MB buffer (`0x1412200`, from `XMemAllocDefault`). The layer then does this with it: 1. **Lands it:** fetches the card's bytes and merges them into title memory (`land::piece` → `safecopy::merge`), about 22 MB a frame. 2. **Echo-checks it:** right after, the copy's own refresh reads all of it back from title memory (`Shadow::take` → `take_landed` → `host::read`) to see whether the CPU changed it. **The title never touches it.** A fault probe, included here as `VICTORY_READER_PROBE_LEN=1412200` (test only, off), makes the buffer's pages inaccessible once a second and records who faults, with the call chain. Over a full 165 s run there were 2 callers, both ours: | caller | page touches | share | |---|---|---| | `host::read` ← `Shadow::take` (refresh / echo check) | ~350,000 | 66% | | `land::piece` ← `Shadow::land_card` (landing merge) | ~220,000 | 34% | The title's code made none. The buffer is still needed: skipping its landing outright (`VICTORY_LAND_NEVER_LEN=1412200`, test only) makes the echo check read stale title memory and send it up over the card's bytes, and the scene goes low-poly. So the GPU → title memory → GPU round trip has a consumer, but that consumer is only the copy itself. ## The change: lazy landing (`VICTORY_LAZY_LAND=1`, off by default) For a copy that lies whole in private write-watched memory (`title_memory_private`, marked from #1038's `watched_reservation`), is at least 1 MiB long and has no other live copy over it: - **Landing:** the card's bytes go into the copy's CPU side only. Those 4 KiB pages are marked *ahead* and made `PAGE_NOACCESS`. A page becomes ahead only if the landing covers all of it and title memory still equals the copy's CPU side. That compare runs with the page read-only first, so no title write can slip in. - **Refresh:** the copy skips its ahead pages and is stamped up to date with them (`Shadow::landed_ahead`). It does not re-read 21 MB a frame. - **Other readers:** textures, descriptors and other trackers are told the pages were written (`Notes::ahead` → `watch::landed_beside`). They re-read, fault, and get the GPU's bytes. - **Demand:** a vectored handler, first in the chain, catches any access to an ahead page. It makes the page read-write, copies the copy's CPU side in, one 4 KiB page at a time, then retries the access. `host::read`, `write_mapped` and the kernel-write hooks land their range first. - **Back-off:** more than 64 pages landed on demand in a second, or a new copy over the memory, turns lazy off for that copy for good (logged once). - **Lifetime:** freed or unmapped memory drops its ahead state and goes back to read-write. A dropped copy lands its pages first. - **Locking:** one RwLock per copy slot. Landing and refresh take it shared and never touch an ahead page under it. The fault handler takes it exclusively. A thread-local guard keeps a thread from re-entering. `ASSIGN` is always taken before a slot lock. The log line, every 5 s: `lazy landing (VICTORY_LAZY_LAND=1): N copies lazy, X MB a frame landed into them alone (not into title memory), Y MB ahead now; per frame F faults on pages ahead, P pages landed on demand; K copies turned off since the start` In the runs below it reads: 1 copy lazy, 19.9 MB a frame, 0 faults, 0 turned off. ## Measured RTX 4070 Ti 12 GB, Ryzen 9 7900X, Series S profile, DLSS off, the same save, warm cache. One build, switches alternated. Cutscene = seconds 60–110 after input; after = 110–165. **Lazy landing on top of the write watch** (`VICTORY_LAZY_LAND` 1/0, both with the write watch): | run | lazy | cutscene fps | CPU preparing | after scene change | copying (60–165 s) | |---|---|---|---|---|---| | C1 | **on** | 41.5 | 18.2 ms | 25.5 | 10.8 ms | | B1 | off | 38.0 | 21.2 ms | 24.1 | 13.3 ms | | C2 | **on** | 41.4 | 17.7 ms | 27.0 | 9.9 ms | | B2 | off | 39.3 | 19.8 ms | 24.6 | 12.4 ms | That's **+2.8 fps in the cutscene (+7%) and +1.9 after the scene change (+8%)**, with 2.6–4.4 ms less CPU preparing a frame. Draw counts match on and off (about 1,400 in the cutscene, 3,400–3,750 after), and nothing looks different on screen. **Against main's behaviour,** from an earlier rotation the same afternoon (the write watch off: 36.0 / 23.7 fps, see my second comment on #1038): #1038 alone gives about +2 fps, and with this on top it's about **+5.5 fps (+15%) in the cutscene and +2.6 (+11%) after the scene change.** ## Lazy fetch (`VICTORY_LAZY_FETCH=1`, needs `VICTORY_LAZY_LAND=1`, off by default) With lazy landing, the relay still fetched the lazy copy's flagged pieces every frame: a readback list and a wait, 6–7 ms of "copying back", only to put them in a CPU side nothing reads. With lazy fetch, those pages are not fetched at all. - **Claim:** pages of a lazy copy's flagged pieces are "claimed" by the card (`Shadow::claim_card_only`). They are marked card-only and `NOACCESS`, other readers are told they were written, and the copy is noted up to date. A page is refused if it has title bytes the card may not have: dirty, or sent after the fetches merged so far. - **Never sent up:** `card_dirty` leaves card-only pages out. If something marked one of them to go up, it is fetched first, then sent as the card's own bytes. - **Demand:** any touch goes to one fetch thread with its own copy queue: one `CopyBufferRegion`, no waits on other queues or fences, all D3D objects made at the first claim. It fetches every card-only page, lands them, and turns the copy off for good. The touching thread holds none of our locks while it waits, and the wait is timed, so the process can still exit. Flights still in the air are not waited for: their own landings merge what differs. - **The log line adds:** MB a frame not fetched, MB the card alone holds, fetches on demand, and why pages were fetched all the same. **Measured against lazy landing alone** (same build, `VICTORY_LAZY_FETCH` 1/0, same setup as above). In game: 20.1 MB a frame not fetched, 0 pages refused, 0 fetches on demand, 0 errors. | run | lazy fetch | cutscene fps | CPU preparing | after scene change | copying back | |---|---|---|---|---|---| | F1 | **on** | 42.9 | 18.8 ms | 26.5 | 4.9 ms | | L1 | off | 40.0 | 20.1 ms | 25.1 | 6.7 ms | | F2 | **on** | 41.8 | 19.3 ms | 26.1 | 4.5 ms | | L2 | off | 40.2 | 19.7 ms | 24.7 | 6.5 ms | That's **+2.3 fps in the cutscene and +1.4 after the scene change (both about +6%)**, with copy-back about 1.9 ms shorter. Draw counts match. **All together,** in the cutscene: main about 36 fps → #1038 about 38 → lazy landing about 40 → lazy fetch about 42, roughly **+17%**. After the scene change: about 23.7 → 26.3 (+11%). These come from rotations in several sessions the same afternoon, so the total is approximate. Each step is measured against the one before it, in the same session. ## Tests - `cargo test -p victory-gpu --release --lib`: the 12 new lazy tests pass. They cover the bitset and part arithmetic, eligibility, back-off and turn-off, the claim racing `land_range`, card-only pages never going up, a demand fetch bringing the card's bytes in, and the full path on real memory: - title memory stays stale after a lazy landing; - a CPU read, a write and `read_into` fault and get the GPU's bytes; - a refresh skips ahead pages, and the lazy copy copies 0 bytes while another tracker is still told; - freed memory keeps no `NOACCESS` pages; - several landing threads run with a concurrent reader. - `indirect::tests::host_list_budget_starts_empty_at_each_submission` and `warp_batch_charges_every_execution` fail, but they fail the same way on #1038's head without these commits. - `cargo test -p victory-hle --release --lib`: 183 passed. - Before opening this, independent reviews covered the locking, the demand path, readers outside the copies, the integration with #1038 and lazy fetch. Each issue they found is fixed in its own commit here. ## Known limits - **Kernel calls the runtime passes straight through** (`WriteFile`, `send`/`sendto` from title memory): these would fail on an ahead page instead of faulting. The probe saw none of them on this buffer. - **Copies that other copies overlap** are never lazy. Lazy turns itself off when one appears. - **Related:** #420 aims at the same idea (keep GPU-produced bytes until the CPU asks) for section-backed pages. This covers private write-watched memory only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
urielbeaupre commented 2026-11-28 16:22:13 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by urielbeaupre on 2026-11-28T16:22:13Z.


@POMXARK @tippythetaidum @Bj0rnis: you ran careful A/Bs on #1038 and #1014 today. Would you be up for one on this? It stacks on #1038 (this branch includes its two commits), so the comparison is #1038 alone against #1038 plus this. Both switches are off by default:

  • off: no extra switches (#1038's write watch stays on)
  • on: VICTORY_LAZY_LAND=1 and VICTORY_LAZY_FETCH=1

The log line every 5 s shows whether it engaged. When it works it reads something like 1 copies lazy, … 20.1 MB a frame not fetched at all, … 0 fetches on demand … 0 copies turned off. If it says 0 copies lazy, or the "fetched all the same" counters are non-zero, please paste that line: it means your setup takes a path I haven't seen yet.

What I'd most like to know:

  1. fps and copying back / preparing with it on and off, at your usual draw-count buckets;
  2. any visual difference (missing detail or low-poly LODs would point at the buffer being stale);
  3. on Linux/Proton, whether 0 fetches on demand holds.

On my RTX 4070 Ti / 7900X (Series S, DLSS off) it measured +2.8 fps on top of #1038, then lazy fetch added +2.3 in a cutscene, with copy-back about 2 ms shorter. Results on an RTX 5080 at 1440p with DLSS would show whether that holds where the frame is more GPU-heavy.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7242189983 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184#issuecomment-7242189983). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T16:22:13Z. --- @POMXARK @tippythetaidum @Bj0rnis: you ran careful A/Bs on #1038 and #1014 today. Would you be up for one on this? It stacks on #1038 (this branch includes its two commits), so the comparison is #1038 alone against #1038 plus this. Both switches are off by default: - **off:** no extra switches (#1038's write watch stays on) - **on:** `VICTORY_LAZY_LAND=1` and `VICTORY_LAZY_FETCH=1` The log line every 5 s shows whether it engaged. When it works it reads something like `1 copies lazy, … 20.1 MB a frame not fetched at all, … 0 fetches on demand … 0 copies turned off`. If it says `0 copies lazy`, or the "fetched all the same" counters are non-zero, please paste that line: it means your setup takes a path I haven't seen yet. What I'd most like to know: 1. fps and `copying back` / `preparing` with it on and off, at your usual draw-count buckets; 2. any visual difference (missing detail or low-poly LODs would point at the buffer being stale); 3. on Linux/Proton, whether `0 fetches on demand` holds. On my RTX 4070 Ti / 7900X (Series S, DLSS off) it measured +2.8 fps on top of #1038, then lazy fetch added +2.3 in a cutscene, with copy-back about 2 ms shorter. Results on an RTX 5080 at 1440p with DLSS would show whether that holds where the frame is more GPU-heavy. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Marsietiss commented 2026-11-28 19:18:27 +00:00 (Migrated from github.com)

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


Thanks for the lazy landing work. We ported #1184 onto our tree and found one stale-read path; the fix applies cleanly on top of this PR's head (b126a98b0), so here it is as a commit rather than a PR (this PR's head is in a fork, so I could not target it): github.com/Chezzuss/VIctory@5ba8b55fc0 (branch fix/lazy-keep-ahead, 3 files, +108/-4 incl. a test).

What we saw: with VICTORY_LAZY_LAND=1 the title read stretched car geometry; with it off the same scene was fine. Cause on our side: the write watch (watch.rs) calls VirtualProtect on whole 64K blocks (guard, unguard, arm, alias). Where a block covers pages a lazy copy holds ahead (PAGE_NOACCESS), that call reopens them as RW/RO, so the title reads the stale title bytes through the opened page with no fault, and the card's bytes never land.

Fix: lazy::keep_ahead(at, len) re-closes the pages ahead (under the slots' shared lock) after each watch protect, and lazy::guardable(at, old) accepts a PAGE_NOACCESS first page when that page is ahead, so the watch's "not ours, put it back" check does not misfire. A counter in the lazy log line reports pages re-closed per frame. cargo test -p victory-gpu --lib lazy passes, including the new a_protection_over_pages_ahead_does_not_open_them.

Caveat: I only checked that it builds and the lazy tests pass on this head; the in-game confirmation was on our merged tree (which has more write-watch changes than this PR), so please treat it as a lead, not as proof for your base. Happy to adapt it if the watch code differs.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244445948 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184#issuecomment-7244445948). Originally posted by [Marsietiss](https://github.com/Marsietiss) on 2026-11-28T19:18:27Z. --- Thanks for the lazy landing work. We ported #1184 onto our tree and found one stale-read path; the fix applies cleanly on top of this PR's head (b126a98b0), so here it is as a commit rather than a PR (this PR's head is in a fork, so I could not target it): https://github.com/Chezzuss/VIctory/commit/5ba8b55fc09e41889da3271bc7f0f193c539d7eb (branch `fix/lazy-keep-ahead`, 3 files, +108/-4 incl. a test). What we saw: with `VICTORY_LAZY_LAND=1` the title read stretched car geometry; with it off the same scene was fine. Cause on our side: the write watch (`watch.rs`) calls `VirtualProtect` on whole 64K blocks (guard, unguard, arm, alias). Where a block covers pages a lazy copy holds ahead (`PAGE_NOACCESS`), that call reopens them as RW/RO, so the title reads the stale title bytes through the opened page with no fault, and the card's bytes never land. Fix: `lazy::keep_ahead(at, len)` re-closes the pages ahead (under the slots' shared lock) after each watch protect, and `lazy::guardable(at, old)` accepts a `PAGE_NOACCESS` first page when that page is ahead, so the watch's "not ours, put it back" check does not misfire. A counter in the lazy log line reports pages re-closed per frame. `cargo test -p victory-gpu --lib lazy` passes, including the new `a_protection_over_pages_ahead_does_not_open_them`. Caveat: I only checked that it builds and the lazy tests pass on this head; the in-game confirmation was on our merged tree (which has more write-watch changes than this PR), so please treat it as a lead, not as proof for your base. Happy to adapt it if the watch code differs.
urielbeaupre commented 2026-11-28 19:43:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by urielbeaupre on 2026-11-28T19:43:23Z.


@Marsietiss thank you, that's a precise diagnosis. I couldn't fetch the commit: https://github.com/Chezzuss/VIctory returns 404 for both the repository and 5ba8b55 (it's private, or it was taken down). Your description is clear enough to implement from, so I'll do it here and credit you in the commit:

  • lazy::keep_ahead(at, len): after each VirtualProtect the write watch makes over a 64 KiB block (guard, unguard, arm, alias), pages a lazy copy holds ahead are made PAGE_NOACCESS again, under the slots' shared lock;
  • lazy::guardable(at, old): the watch's "not ours, put it back" check accepts a PAGE_NOACCESS first page when that page is ahead;
  • a re-closed-pages counter in the lazy log line, plus a test for a protection change over pages ahead.

I'll also log on this base how often the watch touches blocks with pages ahead at all, to see whether the path is reached here or mainly on trees with more write-watch changes. If it's convenient, a git format-patch of 5ba8b55 pasted here would still be useful to check my version against yours.

On the flickering ground you saw with #1038: noted. If I can reproduce it here, I'll report which allocation it is.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244757056 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184#issuecomment-7244757056). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T19:43:23Z. --- @Marsietiss thank you, that's a precise diagnosis. I couldn't fetch the commit: https://github.com/Chezzuss/VIctory returns 404 for both the repository and 5ba8b55 (it's private, or it was taken down). Your description is clear enough to implement from, so I'll do it here and credit you in the commit: - `lazy::keep_ahead(at, len)`: after each `VirtualProtect` the write watch makes over a 64 KiB block (guard, unguard, arm, alias), pages a lazy copy holds ahead are made `PAGE_NOACCESS` again, under the slots' shared lock; - `lazy::guardable(at, old)`: the watch's "not ours, put it back" check accepts a `PAGE_NOACCESS` first page when that page is ahead; - a re-closed-pages counter in the lazy log line, plus a test for a protection change over pages ahead. I'll also log on this base how often the watch touches blocks with pages ahead at all, to see whether the path is reached here or mainly on trees with more write-watch changes. If it's convenient, a `git format-patch` of 5ba8b55 pasted here would still be useful to check my version against yours. On the flickering ground you saw with #1038: noted. If I can reproduce it here, I'll report which allocation it is. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Marsietiss commented 2026-11-28 19:52:35 +00:00 (Migrated from github.com)

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


Follow-up: the commit link above points into a private repo, sorry. The same fix is now public in our fork Mangrove:

Same caveat as before: builds and lazy tests pass on your head; the in-game check was on our merged tree. Thanks again, @Urielbeaupre.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244869350 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184#issuecomment-7244869350). Originally posted by [Marsietiss](https://github.com/Marsietiss) on 2026-11-28T19:52:35Z. --- Follow-up: the commit link above points into a private repo, sorry. The same fix is now public in our fork **Mangrove**: - on top of this PR's head (b126a98b0): https://github.com/Marsietiss/Mangrove/commit/d9aec2a7877efb6b301c5e9c9f4bff8ab33cd62f (branch `fix/lazy-keep-ahead`), so you can cherry-pick or compare directly. - merged into our main line: `crates/victory-gpu/src/lazy.rs` (`keep_ahead`, `guardable`) in https://github.com/Marsietiss/Mangrove Same caveat as before: builds and lazy tests pass on your head; the in-game check was on our merged tree. Thanks again, @Urielbeaupre.
urielbeaupre commented 2026-11-28 20:33:25 +00:00 (Migrated from github.com)

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


Closing this, because current main no longer has the cost it removes.

I rebased it onto main 32ecacf (with #1038's two commits; no conflicts, 491 tests pass) and added the keep-ahead fix Marsietiss reported. My version keeps the pages ahead NOACCESS throughout the watch's protections instead of reopening and re-closing them, and the lock order can't deadlock. Credit to Marsietiss/Mangrove@d9aec2a. In game on that base, lazy landing never engaged, so I added an always-on diagnostic. With main's launcher defaults (Series S, RTX 4070 Ti) it reads:

2 write-watched XMemAllocDefault blocks (92 MB); copies made 7,793, 0 of them of 1 MiB or more in such a block;
asked at landings 3,121, lazy 0; turned down: 3,120 under 1 MiB, 1 not in a write-watched XMemAllocDefault block

The 21 MB buffer (0x1412200) that went GPU → title memory → echo re-read every frame on 63b902f isn't copied back on current main at all: copy-back is down to ~3.8 MB of new bytes a frame. So there's nothing for this PR to keep on the card, and reviewing it would only cost time.

For the record, in case that buffer comes back (e.g. with the structure builder on):

  • on 63b902f + #1038, lazy landing gave +2.8 fps in the opening cutscene and +1.9 after the scene change, and lazy fetch added +2.3 / +1.4 more (tables above);
  • the reader probe (VICTORY_READER_PROBE_LEN) showed that only the layer touched that buffer, never the title;
  • the rebased branch with the keep-ahead fix and the diagnostic is urielbeaupre/VIctory-NVIDIA perf/lazy-land (I'll push the rebased version there so it isn't lost), if anyone wants to pick it up.

Thanks to everyone who reviewed and tested it, and to Marsietiss for the keep-ahead report.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245372503 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184#issuecomment-7245372503). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T20:33:25Z. --- Closing this, because current main no longer has the cost it removes. I rebased it onto main 32ecacf (with #1038's two commits; no conflicts, 491 tests pass) and added the keep-ahead fix Marsietiss reported. My version keeps the pages ahead `NOACCESS` throughout the watch's protections instead of reopening and re-closing them, and the lock order can't deadlock. Credit to Marsietiss/Mangrove@d9aec2a. In game on that base, lazy landing never engaged, so I added an always-on diagnostic. With main's launcher defaults (Series S, RTX 4070 Ti) it reads: ``` 2 write-watched XMemAllocDefault blocks (92 MB); copies made 7,793, 0 of them of 1 MiB or more in such a block; asked at landings 3,121, lazy 0; turned down: 3,120 under 1 MiB, 1 not in a write-watched XMemAllocDefault block ``` The 21 MB buffer (`0x1412200`) that went GPU → title memory → echo re-read every frame on 63b902f isn't copied back on current main at all: copy-back is down to ~3.8 MB of new bytes a frame. So there's nothing for this PR to keep on the card, and reviewing it would only cost time. For the record, in case that buffer comes back (e.g. with the structure builder on): - on 63b902f + #1038, lazy landing gave +2.8 fps in the opening cutscene and +1.9 after the scene change, and lazy fetch added +2.3 / +1.4 more (tables above); - the reader probe (`VICTORY_READER_PROBE_LEN`) showed that only the layer touched that buffer, never the title; - the rebased branch with the keep-ahead fix and the diagnostic is urielbeaupre/VIctory-NVIDIA `perf/lazy-land` (I'll push the rebased version there so it isn't lost), if anyone wants to pick it up. Thanks to everyone who reviewed and tested it, and to Marsietiss for the keep-ahead report. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
POMXARK commented 2026-11-28 20:37:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-28T20:37:41Z.


@urielbeaupre @Marsietiss — confirming your closing finding independently on an RTX 5080 16 GB (Ryzen 7 5700X, 32 GB RAM, Windows 11, Series X 1440p, DLSS Quality + MFG 4x, release build, 20-minute A/B on top of #1038 + Marsietiss/Mangrove@d9aec2a):

  • Unit tests (--release --lib -- lazy --test-threads=1): 14/14 PASS (1.04s), including a_protection_over_pages_ahead_does_not_open_them.
  • 20-minute run (VICTORY_LAZY_LAND=1, VICTORY_LAZY_FETCH=1, VICTORY_LAND_SKIP=1, VICTORY_WC_NO_BACK=1):
    • 0 errors, 0 visual regressions, 0 lazy landing engagements over the entire 20 minutes — matches your diagnostic exactly because copying back is already down to 0.7 MB/frame on current main settings.
    • Run ALL 3D p50 1k–4k 4k–7k 7k–10k Submitting med Copy-back med
      Baseline (#1038, lazy off) 14.80 FPS 16.05 14.80 11.50 59.3 ms 13.6 ms / 0.7 MB
      #1184 + d9aec2a (lazy on) 14.05 FPS 15.10 13.65 10.20 67.9 ms 10.8 ms / 0.7 MB

Good call closing it for current main defaults — and great to have the rebased perf/lazy-land branch + keep_ahead fix archived if large copy-backs return with RT/structure-builder work!

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245424357 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1184#issuecomment-7245424357). Originally posted by [POMXARK](https://github.com/POMXARK) on 2026-11-28T20:37:41Z. --- @urielbeaupre @Marsietiss — confirming your closing finding independently on an RTX 5080 16 GB (Ryzen 7 5700X, 32 GB RAM, Windows 11, Series X 1440p, DLSS Quality + MFG 4x, release build, 20-minute A/B on top of `#1038` + `Marsietiss/Mangrove@d9aec2a`): - **Unit tests (`--release --lib -- lazy --test-threads=1`):** 14/14 PASS (`1.04s`), including `a_protection_over_pages_ahead_does_not_open_them`. - **20-minute run (`VICTORY_LAZY_LAND=1`, `VICTORY_LAZY_FETCH=1`, `VICTORY_LAND_SKIP=1`, `VICTORY_WC_NO_BACK=1`):** - `0` errors, `0` visual regressions, **0 lazy landing engagements** over the entire 20 minutes — matches your diagnostic exactly because `copying back` is already down to **0.7 MB/frame** on current `main` settings. - | Run | ALL 3D p50 | 1k–4k | 4k–7k | 7k–10k | Submitting med | Copy-back med | |---|---:|---:|---:|---:|---:|---:| | Baseline (`#1038`, lazy off) | 14.80 FPS | 16.05 | 14.80 | 11.50 | 59.3 ms | 13.6 ms / 0.7 MB | | `#1184` + `d9aec2a` (lazy on) | 14.05 FPS | 15.10 | 13.65 | 10.20 | 67.9 ms | 10.8 ms / 0.7 MB | Good call closing it for current `main` defaults — and great to have the rebased `perf/lazy-land` branch + `keep_ahead` fix archived if large copy-backs return with RT/structure-builder work!

Pull request closed

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!1184
No description provided.