GPU: a copy that meets an unmapped page retries in 64 KiB kernel calls (2 300-2 500 a world frame); one query per region is 2.3x cheaper #783

Open
opened 2026-11-26 04:13:58 +00:00 by github-bot · 11 comments
Owner

@⁠rocobalt1 on GitHub · 2026-11-24 10:37 UTC · original

A CPU-side cost that #400's table does not separate: copies that meet an unmapped page retry in the kernel 64 KiB at a time, and rediscover the same holes every frame.

Setup: NVIDIA RTX 4060 Ti (driver 32.0.16.1656), Ryzen 9 5900X, 64 GB, Windows 11; Xbox Series 1.0.2.1; diag build (--profile diag --features diagnostics) of an integration tree at 2b1a569 (about 50 PRs on main); VICTORY_NO_WATCHDOG=1; TdrDelay=60 set machine-wide on this box. No game data used.

What the log says

In the world, one frame:

33 129 title copies 16.3 MB; 34 490 refreshes 29 201 MB
moves 29.06 ms; 652.74 MB unmapped; 2 479.5 fallbacks
... copies 120 ms 302 MB

moves (the timed first attempt) is 29 ms; the copies take 120-275 ms. The difference is the fallback path, and its counter is the only one that scales with fallbacks.

The path

copy_mapped reads the range with one ReadProcessMemory. If any page of it is unmapped, it redoes the whole range in 64 KiB pieces (then 4 KiB inside a piece that fails), one ReadProcessMemory per piece, zeros where nothing can be read.

  • A 174 MB shadow with a single hole is 2 784 kernel calls for one copy.
  • 2 300-2 500 fallbacks a frame re-discover the same holes, so the cost grows with the size of the ranges, not with how much is unmapped.
  • The holes are real: VICTORY_COPY_MODE=plain, which copies the range blindly, ends the run inside a minute on this machine.

The change (gist below)

On the fallback, walk the range with VirtualQuery and copy what the region says is committed and readable, zeros for the rest - same bytes in the destination as today, but one query per region instead of one kernel call per 64 KiB piece. The regions of the big pools are megabytes long, so a 174 MB range is a handful of queries. The same change in write_mapped for the copy-back, over writable regions, leaves the rest alone as before.

The comment above copy_mapped notes that VirtualQuery cost about 2 ms per copy in these pools; that was querying before every copy. Here it runs only on the fallback and replaces thousands of calls.

A/B, one binary, same save

VICTORY_COPY_FALLBACK=pieces (diagnostics builds only) keeps the old path, so both arms are the same binary, written save, 120 s after world entry, 10 frames each:

Fallback frame (avg) copies copies MB ms/MB fallbacks
region scan 910 ms 120 ms 302 MB 0.40 2 479
64 KiB pieces 978 ms 275 ms 233 MB 1.18 2 325

The region arm also had more content (2 823 draws/frame against 2 400). The win is bounded by what copies cost in the scene: 15 % of the frame here, and the earlier opening-cutscene frames on this machine showed copies 1 799 ms of a 4 400 ms frame, where this path is most of it.

Not tested: AMD, release builds, main itself (the function and its callers are unchanged since d2a4bae as far as I can tell, but I only built the tree), and the case where the title unmaps a page between the query and the memcpy of its region.

Patch: https://gist.github.com/rocobalt1/1edb3c0dad03f54c05f972b95475b14c

If it is useful, a collaborator is welcome to take it as a PR; I do not have write access here.

Same shape as #776: both costs come from asking the kernel about the same pages again every submission. They are independent (copy bytes vs write-watch askings) and should stack.

AI-assisted: an agent working with the tester, which built the change and ran the A/B.

**@⁠rocobalt1** on GitHub · 2026-11-24 10:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/783) A CPU-side cost that #400's table does not separate: **copies that meet an unmapped page retry in the kernel 64 KiB at a time**, and rediscover the same holes every frame. **Setup:** NVIDIA RTX 4060 Ti (driver 32.0.16.1656), Ryzen 9 5900X, 64 GB, Windows 11; Xbox Series 1.0.2.1; diag build (`--profile diag --features diagnostics`) of an integration tree at `2b1a569` (about 50 PRs on `main`); `VICTORY_NO_WATCHDOG=1`; `TdrDelay=60` set machine-wide on this box. No game data used. ## What the log says In the world, one frame: ``` 33 129 title copies 16.3 MB; 34 490 refreshes 29 201 MB moves 29.06 ms; 652.74 MB unmapped; 2 479.5 fallbacks ... copies 120 ms 302 MB ``` `moves` (the timed first attempt) is 29 ms; the copies take 120-275 ms. The difference is the fallback path, and its counter is the only one that scales with `fallbacks`. ## The path `copy_mapped` reads the range with one `ReadProcessMemory`. If **any** page of it is unmapped, it redoes the whole range in 64 KiB pieces (then 4 KiB inside a piece that fails), one `ReadProcessMemory` per piece, zeros where nothing can be read. - A 174 MB shadow with a single hole is 2 784 kernel calls for one copy. - 2 300-2 500 fallbacks a frame re-discover the same holes, so the cost grows with the size of the ranges, not with how much is unmapped. - The holes are real: `VICTORY_COPY_MODE=plain`, which copies the range blindly, ends the run inside a minute on this machine. ## The change (gist below) On the fallback, walk the range with `VirtualQuery` and copy what the region says is committed and readable, zeros for the rest - same bytes in the destination as today, but one query per **region** instead of one kernel call per 64 KiB piece. The regions of the big pools are megabytes long, so a 174 MB range is a handful of queries. The same change in `write_mapped` for the copy-back, over writable regions, leaves the rest alone as before. The comment above `copy_mapped` notes that `VirtualQuery` cost about 2 ms per copy in these pools; that was querying *before every copy*. Here it runs only on the fallback and replaces thousands of calls. ## A/B, one binary, same save `VICTORY_COPY_FALLBACK=pieces` (diagnostics builds only) keeps the old path, so both arms are the same binary, written save, 120 s after world entry, 10 frames each: | Fallback | frame (avg) | copies | copies MB | ms/MB | fallbacks | |---|---:|---:|---:|---:|---:| | region scan | **910 ms** | **120 ms** | 302 MB | **0.40** | 2 479 | | 64 KiB pieces | 978 ms | 275 ms | 233 MB | 1.18 | 2 325 | The region arm also had more content (2 823 draws/frame against 2 400). The win is bounded by what copies cost in the scene: 15 % of the frame here, and the earlier opening-cutscene frames on this machine showed `copies 1 799 ms` of a 4 400 ms frame, where this path is most of it. **Not tested:** AMD, release builds, `main` itself (the function and its callers are unchanged since `d2a4bae` as far as I can tell, but I only built the tree), and the case where the title unmaps a page between the query and the `memcpy` of its region. Patch: https://gist.github.com/rocobalt1/1edb3c0dad03f54c05f972b95475b14c If it is useful, a collaborator is welcome to take it as a PR; I do not have write access here. Same shape as #776: both costs come from asking the kernel about the same pages again every submission. They are independent (copy bytes vs write-watch askings) and should stack. *AI-assisted: an agent working with the tester, which built the change and ran the A/B.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:58 +00:00
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 10:58 UTC · original

Clean main-based implementation ready on a fork (since PR creation is currently collaborators-only): https://github.com/MartinIndra02/VIctory/tree/perf/gpu-copy-mapped-region-fallback (based on main ffe310e).

Two improvements over the gist in the description

  1. Race-safe per-region copy (addresses the unmap-between-query-and-copy caveat): instead of raw memcpy after VirtualQuery, each committed region is copied with a single ReadProcessMemory / WriteProcessMemory call, and only if that call fails (a concurrent unmap/reprotect between VirtualQuery and the copy) does it fall back to the existing 64 KiB → 4 KiB for_pieces loop on that region. Unmapped / PAGE_NOACCESS / PAGE_GUARD regions are still zeroed in one write_bytes(0, n) (or skipped in write_mapped).
  2. Reuse the initial partial copy (done): when the initial ReadProcessMemory / WriteProcessMemory hits the first unmapped page (ERROR_PARTIAL_COPY), Windows already copied lpNumberOfBytesRead (done) bytes before the hole. Starting for_regions at start + done avoids re-copying the committed prefix a second time.

Verification

Windows 11 Pro 26200, Ryzen 7 5800X3D, NVIDIA GeForce RTX 3080 (621.24), Rust 1.98.1 (x86_64-pc-windows-msvc):

  • New unit test host::batch::copy_mapped_and_write_mapped_handle_holes_across_regions: 2 MiB reserved range with two 512 KiB committed regions and two 512 KiB unmapped holes — verifies copy_mapped copies committed regions and zeroes holes, and write_mapped writes committed regions while skipping holes.
  • New release microbenchmark (cargo test --release -p victory-gpu --lib -- --ignored --nocapture copy_mapped_hole_benchmark, 16 runs each):
    • 64 MiB (4 KiB hole at 32 MiB): 136.35 ms → 81.03 ms (1.68×)
    • 64 MiB (32 MiB hole at 16 MiB): 608.11 ms → 49.82 ms (12.21×)
  • cargo test -p victory-gpu --lib -- --test-threads=1: 51 passed, 0 failed, 2 ignored
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics): 0 warnings
  • cargo xtask policy: 154 files ok

No game data used. AI-assisted; all builds, tests, and benchmarks executed on my machine.

**@⁠MartinIndra02** on GitHub · 2026-11-24 10:58 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7129490661) Clean `main`-based implementation ready on a fork (since PR creation is currently collaborators-only): https://github.com/MartinIndra02/VIctory/tree/perf/gpu-copy-mapped-region-fallback (based on `main` `ffe310e`). ### Two improvements over the gist in the description 1. **Race-safe per-region copy (addresses the unmap-between-query-and-copy caveat):** instead of raw `memcpy` after `VirtualQuery`, each committed region is copied with a single `ReadProcessMemory` / `WriteProcessMemory` call, and only if that call fails (a concurrent unmap/reprotect between `VirtualQuery` and the copy) does it fall back to the existing 64 KiB → 4 KiB `for_pieces` loop on that region. Unmapped / `PAGE_NOACCESS` / `PAGE_GUARD` regions are still zeroed in one `write_bytes(0, n)` (or skipped in `write_mapped`). 2. **Reuse the initial partial copy (`done`):** when the initial `ReadProcessMemory` / `WriteProcessMemory` hits the first unmapped page (`ERROR_PARTIAL_COPY`), Windows already copied `lpNumberOfBytesRead` (`done`) bytes before the hole. Starting `for_regions` at `start + done` avoids re-copying the committed prefix a second time. ### Verification Windows 11 Pro 26200, Ryzen 7 5800X3D, NVIDIA GeForce RTX 3080 (`621.24`), Rust 1.98.1 (`x86_64-pc-windows-msvc`): - New unit test `host::batch::copy_mapped_and_write_mapped_handle_holes_across_regions`: 2 MiB reserved range with two 512 KiB committed regions and two 512 KiB unmapped holes — verifies `copy_mapped` copies committed regions and zeroes holes, and `write_mapped` writes committed regions while skipping holes. - New release microbenchmark (`cargo test --release -p victory-gpu --lib -- --ignored --nocapture copy_mapped_hole_benchmark`, 16 runs each): - `64 MiB (4 KiB hole at 32 MiB)`: `136.35 ms` → **`81.03 ms`** (**1.68×**) - `64 MiB (32 MiB hole at 16 MiB)`: `608.11 ms` → **`49.82 ms`** (**12.21×**) - `cargo test -p victory-gpu --lib -- --test-threads=1`: **51 passed, 0 failed, 2 ignored** - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`): **0 warnings** - `cargo xtask policy`: **154 files ok** *No game data used. AI-assisted; all builds, tests, and benchmarks executed on my machine.*
Author
Owner

@⁠rocobalt1 on GitHub · 2026-11-24 11:24 UTC · original

Real-title numbers for the same idea, to put next to your microbenchmark: the naive form I measured (raw memcpy over VirtualQueryd regions, which is the race you fixed) took 275 ms -> 120 ms per world frame in one binary with a switch, 233-302 MB copied, i.e. 1.18 -> 0.40 ms/MB. Same save, 120 s after world entry, 10 frames each arm.

Your two changes both look right to me:

  • per-region ReadProcessMemory instead of memcpy is the version that should ship; the race window in mine is real (the title unmaps pages of these pools while the frame is prepared, which is why the fallback exists at all), and a failed region re-entering the old for_pieces loop keeps today's behaviour exactly.
  • starting at start + done is free: the partial copy already did the prefix, and today's code copies it twice.

One caveat on what this buys, from the same machine now that the fix is in a stacked build (tree 2b1a569 + #431 + this): the world still reports copies 1 209 ms / 216 MB (5.6 ms/MB) in the scene where the title rewrites most of its big pools. So the fallback is necessary but not sufficient - in that scene the time is in the volume and in the write-watch askings (#776), not in the hole walk. With the fix the copy line stops being dominated by the pathological case; it does not make copies cheap.

If it helps: RTX 4060 Ti, driver 32.0.16.1656, TdrDelay=60 machine-wide, diag build, VICTORY_SHADER_LOOP_LIMIT=32, VICTORY_NO_WATCHDOG=1. I can run your branch on this machine if you want an in-title number for the race-safe form specifically; it is main-based (ffe310e) while mine is a 50-PR tree, so the scenes will not be identical, but the copy line is comparable.

**@⁠rocobalt1** on GitHub · 2026-11-24 11:24 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7130062374) Real-title numbers for the same idea, to put next to your microbenchmark: the naive form I measured (raw `memcpy` over `VirtualQuery`d regions, which is the race you fixed) took **275 ms -> 120 ms per world frame** in one binary with a switch, 233-302 MB copied, i.e. **1.18 -> 0.40 ms/MB**. Same save, 120 s after world entry, 10 frames each arm. Your two changes both look right to me: - **per-region `ReadProcessMemory` instead of `memcpy`** is the version that should ship; the race window in mine is real (the title unmaps pages of these pools while the frame is prepared, which is why the fallback exists at all), and a failed region re-entering the old `for_pieces` loop keeps today's behaviour exactly. - **starting at `start + done`** is free: the partial copy already did the prefix, and today's code copies it twice. One caveat on what this buys, from the same machine now that the fix is in a stacked build (tree `2b1a569` + #431 + this): the world still reports **copies 1 209 ms / 216 MB (5.6 ms/MB)** in the scene where the title rewrites most of its big pools. So the fallback is necessary but not sufficient - in that scene the time is in the volume and in the write-watch askings (#776), not in the hole walk. With the fix the copy line stops being dominated by the pathological case; it does not make copies cheap. If it helps: RTX 4060 Ti, driver 32.0.16.1656, `TdrDelay=60` machine-wide, diag build, `VICTORY_SHADER_LOOP_LIMIT=32`, `VICTORY_NO_WATCHDOG=1`. I can run your branch on this machine if you want an in-title number for the race-safe form specifically; it is main-based (`ffe310e`) while mine is a 50-PR tree, so the scenes will not be identical, but the copy line is comparable.
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 11:28 UTC · original

@⁠rocobalt1 Thanks for checking the two changes and sharing the real-title numbers (275 ms -> 120 ms / 1.18 -> 0.40 ms/MB)!

Yes — if you don't mind running perf/gpu-copy-mapped-region-fallback (61474f6) on your machine, having an in-title number specifically for the race-safe per-region ReadProcessMemory form would be very helpful to have alongside the microbenchmark.

**@⁠MartinIndra02** on GitHub · 2026-11-24 11:28 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7130150010) @⁠rocobalt1 Thanks for checking the two changes and sharing the real-title numbers (`275 ms -> 120 ms` / `1.18 -> 0.40 ms/MB`)! Yes — if you don't mind running `perf/gpu-copy-mapped-region-fallback` (`61474f6`) on your machine, having an in-title number specifically for the race-safe per-region `ReadProcessMemory` form would be very helpful to have alongside the microbenchmark.
Author
Owner

@⁠Gruzzberry on GitHub · 2026-11-24 11:37 UTC · original

A fork branch with this change, written from the description above (not from the gist): https://github.com/Gruzzberry/VIctory/tree/gpu/copy-fallback-by-region (one commit on main ffe310e).

On the fallback, copy_mapped and write_mapped walk the range with VirtualQuery instead of 64 KiB pieces: a region that is not committed or has no access reads as zeros (or is left alone, for the copy-back), any other is read or written in one call, and only a region the kernel then refuses is cut into 64 KiB and 4 KiB pieces as before. The first whole-range read is unchanged, so the query is still not asked on the common path.

Tests build 8 MiB of address space with committed, reserved-only and no-access stretches and check the bytes that arrive, the zeros, and that the copy-back leaves the holes alone. An ignored timing test copies 8 MiB with a 4 MiB hole: 3.24 ms a copy with the old pieces, 0.48 ms with regions (debug build, RTX 4070 machine). cargo test -p victory-gpu passes 52 tests; with diagnostics 55 pass on the RTX 4070 and on WARP, also with VICTORY_D3D12_DEBUG=1. Workspace tests (344), both clippy runs and the asset policy are clean.

Not run on the title, so the frame-time effect measured above is not confirmed on my side; the case of a page unmapped between the query and the read goes to the old piece path, as the kernel refuses it.

AI use: written with Claude; tests run on an RTX 4070 and WARP.

**@⁠Gruzzberry** on GitHub · 2026-11-24 11:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7130340818) A fork branch with this change, written from the description above (not from the gist): https://github.com/Gruzzberry/VIctory/tree/gpu/copy-fallback-by-region (one commit on `main` `ffe310e`). On the fallback, `copy_mapped` and `write_mapped` walk the range with `VirtualQuery` instead of 64 KiB pieces: a region that is not committed or has no access reads as zeros (or is left alone, for the copy-back), any other is read or written in one call, and only a region the kernel then refuses is cut into 64 KiB and 4 KiB pieces as before. The first whole-range read is unchanged, so the query is still not asked on the common path. Tests build 8 MiB of address space with committed, reserved-only and no-access stretches and check the bytes that arrive, the zeros, and that the copy-back leaves the holes alone. An ignored timing test copies 8 MiB with a 4 MiB hole: 3.24 ms a copy with the old pieces, 0.48 ms with regions (debug build, RTX 4070 machine). `cargo test -p victory-gpu` passes 52 tests; with diagnostics 55 pass on the RTX 4070 and on WARP, also with `VICTORY_D3D12_DEBUG=1`. Workspace tests (344), both clippy runs and the asset policy are clean. Not run on the title, so the frame-time effect measured above is not confirmed on my side; the case of a page unmapped between the query and the read goes to the old piece path, as the kernel refuses it. _AI use: written with Claude; tests run on an RTX 4070 and WARP._
Author
Owner

@⁠rocobalt1 on GitHub · 2026-11-24 11:39 UTC · original

In-title A/B of your branch, same machine and same save: main ffe310e vs martin-copy 61474f6, diag builds of each, VICTORY_NO_WATCHDOG=1, VICTORY_SHADER_LOOP_LIMIT=32, VICTORY_D3D12_DRED=1, driven into the world with VICTORY_KEYS, 90 s of settling, then the last 8 frames.

parent ffe310e your branch
frame 1 484 ms 1 196 ms
copies 792 ms / 218 MB 564 ms / 207 MB
moves (the timed first attempt) 8.58 ms 9.51 ms
fallbacks 636 715
unmapped 162.6 MB 181.4 MB
watches 671 ms 610 ms

So in the title the fix is -29 % on copies and -19 % on the frame, not the 12x the microbenchmark shows, and the reason is visible in the same line: the write-watch askings cost 610-671 ms/frame here, more than the copies themselves. The hole walk was never the largest term in this scene; it was the largest term in the cutscene frames where copies reached 1 800 ms of a 4 400 ms frame.

That is not an argument against the change - it is the right shape, it removes a pathological case, and it is the version I would ship (race-safe, and the done prefix reuse is free). It is an argument that the next win is #776: the same askings over nested buffers, 120-180 ms in that report's runs, 610 ms in mine. With both, this frame would be about 1 196 - 570 = ~630 ms; flags not needed to see which one matters more here.

Caveat: one run each, main-based (515 shaders still refuse, world black), so the scene is lighter than the 50-PR tree; the columns are comparable because both arms ran the same save and the same keys.

**@⁠rocobalt1** on GitHub · 2026-11-24 11:39 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7130381349) In-title A/B of your branch, same machine and same save: **`main` `ffe310e` vs `martin-copy` `61474f6`**, diag builds of each, `VICTORY_NO_WATCHDOG=1`, `VICTORY_SHADER_LOOP_LIMIT=32`, `VICTORY_D3D12_DRED=1`, driven into the world with `VICTORY_KEYS`, 90 s of settling, then the last 8 frames. | | parent `ffe310e` | your branch | |---|---:|---:| | frame | 1 484 ms | **1 196 ms** | | copies | 792 ms / 218 MB | **564 ms / 207 MB** | | `moves` (the timed first attempt) | 8.58 ms | 9.51 ms | | fallbacks | 636 | 715 | | unmapped | 162.6 MB | 181.4 MB | | **watches** | **671 ms** | **610 ms** | So in the title the fix is **-29 % on copies and -19 % on the frame**, not the 12x the microbenchmark shows, and the reason is visible in the same line: **the write-watch askings cost 610-671 ms/frame here, more than the copies themselves.** The hole walk was never the largest term in this scene; it was the largest term in the cutscene frames where `copies` reached 1 800 ms of a 4 400 ms frame. That is not an argument against the change - it is the right shape, it removes a pathological case, and it is the version I would ship (race-safe, and the `done` prefix reuse is free). It is an argument that the next win is #776: the same askings over nested buffers, 120-180 ms in that report's runs, **610 ms in mine**. With both, this frame would be about 1 196 - 570 = ~630 ms; flags not needed to see which one matters more here. Caveat: one run each, main-based (515 shaders still refuse, world black), so the scene is lighter than the 50-PR tree; the columns are comparable because both arms ran the same save and the same keys.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 11:43 UTC · original

A/B on the gap your report lists as not tested: AMD, release build, Linux/Wine, with the actual game.

Setup: AMD RX 9060 XT (RDNA4, RADV 26.3.1), Arch Linux, kernel 6.18.x; Wine 11.22 (system), DXVK 3.1.1 dxgi, vkd3d-proton 3.2.0 (Proton Experimental DLLs), WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n"; release MSVC build (cargo xwin); package 1.0.2.1, build unknown (b99f876b…b5c35a79d5decd9f716504239e93). Both runs booted with VICTORY_KEYS and reached the world.

Build World lines fps frame copies ms/MB
main ffe310e 33 0.32 4027 ms 2627 ms / 56.7 MB 61.0
MartinIndra02 61474f6 16 0.78 2548 ms 610 ms / 28.6 MB —

First 13 world lines of each (closest to a like-for-like window):

Build fps frame copies
main 0.41 3144 ms 1881 ms / 72.3 MB
61474f6 0.78 2828 ms 637 ms / 28.6 MB

And the subset with copy_MB > 20 (removes small-copy noise): main 2955 ms / 63.2 MB = 62.6 ms/MB; 61474f6 559 ms / 118.6 MB = 12.9 ms/MB.

On Wine the 64 KiB kernel-call fallback is especially expensive, so the region scan is a large win here: copy time roughly 3x lower and world fps about 2x, even in frames where the branch copied more MB. Caveat: these are two real runs, not the same save/frame window (no controlled save on this machine), so treat it as directional; the scene mix differs.

Both runs hit the #774 SRWLock freeze ~3 minutes into the world, so there is no longer-session number.

Not tested: Windows/NVIDIA, a same-save controlled A/B, and the race where a page is unmapped between query and copy.

**@⁠DaviTostes** on GitHub · 2026-11-24 11:43 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7130470183) A/B on the gap your report lists as not tested: **AMD, release build, Linux/Wine**, with the actual game. **Setup:** AMD RX 9060 XT (RDNA4, RADV 26.3.1), Arch Linux, kernel 6.18.x; Wine 11.22 (system), DXVK 3.1.1 `dxgi`, vkd3d-proton 3.2.0 (Proton Experimental DLLs), `WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n"`; release MSVC build (`cargo xwin`); package 1.0.2.1, `build unknown (b99f876b…b5c35a79d5decd9f716504239e93)`. Both runs booted with `VICTORY_KEYS` and reached the world. | Build | World lines | fps | frame | copies | ms/MB | |---|---:|---:|---:|---:|---:| | `main` `ffe310e` | 33 | 0.32 | 4027 ms | 2627 ms / 56.7 MB | 61.0 | | MartinIndra02 `61474f6` | 16 | 0.78 | 2548 ms | 610 ms / 28.6 MB | — | First 13 world lines of each (closest to a like-for-like window): | Build | fps | frame | copies | |---|---:|---:|---:| | `main` | 0.41 | 3144 ms | 1881 ms / 72.3 MB | | `61474f6` | 0.78 | 2828 ms | 637 ms / 28.6 MB | And the subset with `copy_MB > 20` (removes small-copy noise): `main` 2955 ms / 63.2 MB = **62.6 ms/MB**; `61474f6` 559 ms / 118.6 MB = **12.9 ms/MB**. On Wine the 64 KiB kernel-call fallback is especially expensive, so the region scan is a large win here: copy time roughly 3x lower and world fps about 2x, even in frames where the branch copied more MB. Caveat: these are two real runs, not the same save/frame window (no controlled save on this machine), so treat it as directional; the scene mix differs. Both runs hit the #774 SRWLock freeze ~3 minutes into the world, so there is no longer-session number. **Not tested:** Windows/NVIDIA, a same-save controlled A/B, and the race where a page is unmapped between query and copy.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 12:15 UTC · original

Tried to open this as a PR, but CreatePullRequest is restricted for non-collaborators right now. So the branch is ready on a fork with the commit unchanged:

A collaborator can open it from there.

Verification I ran on the pushed commit (AMD / Linux / release, actual game):

  • victory-gpu under Wine 11.22, Windows MSVC release: 51 passed, 0 failed, 2 ignored.
  • cargo xtask policy: 154 files ok.
  • A/B with the 1.0.2.1 dump (RX 9060 XT, RADV 26.3.1, Wine 11.22 + DXVK 3.1.1 + vkd3d-proton 3.2.0): main ffe310e vs 61474f6 — copies 2627 ms / 56.7 MB → 610 ms / 28.6 MB per world frame; 0.32 → 0.78 fps; subset copy_MB > 20: 62.6 → 12.9 ms/MB. Not a same-save comparison (directional); both runs freeze at #774 ~3 min in.

Not tested: the unmap-between-query-and-copy race, a controlled same-save A/B, AMD on Windows.

**@⁠DaviTostes** on GitHub · 2026-11-24 12:15 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7131194470) Tried to open this as a PR, but `CreatePullRequest` is restricted for non-collaborators right now. So the branch is ready on a fork with the commit unchanged: - Branch: https://github.com/DaviTostes/VIctory/tree/gpu/copy-mapped-region-fallback - Compare: https://github.com/Marvisak/VIctory/compare/main...DaviTostes:VIctory:gpu/copy-mapped-region-fallback - Commit: `61474f6` (author @⁠MartinIndra02, from @⁠rocobalt1's analysis/gist) A collaborator can open it from there. Verification I ran on the pushed commit (AMD / Linux / release, actual game): - `victory-gpu` under Wine 11.22, Windows MSVC release: **51 passed, 0 failed, 2 ignored**. - `cargo xtask policy`: **154 files ok**. - A/B with the 1.0.2.1 dump (RX 9060 XT, RADV 26.3.1, Wine 11.22 + DXVK 3.1.1 + vkd3d-proton 3.2.0): `main` `ffe310e` vs `61474f6` — copies **2627 ms / 56.7 MB → 610 ms / 28.6 MB** per world frame; **0.32 → 0.78 fps**; subset `copy_MB > 20`: **62.6 → 12.9 ms/MB**. Not a same-save comparison (directional); both runs freeze at #774 ~3 min in. **Not tested:** the unmap-between-query-and-copy race, a controlled same-save A/B, AMD on Windows.
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 14:24 UTC · original

Additional in-title A/B on top of the full r4tedx/integration/testers stack (mpDom/pr/present-1440p-fallback d6897fa, Windows 11, RTX 3080 621.24, diag build, VICTORY_PRESENT_1440P=1, VICTORY_SHADER_LOOP_LIMIT=32, VICTORY_NO_WATCHDOG=1, VICTORY_D3D12_DRED=1):

  • Baseline (d6897fa): world settled at 0.2 – 0.4 fps (2,733 – 4,100 ms/frame), of which preparing was 2,009 – 3,107 ms/frame (0 device removals).
  • With perf/gpu-copy-mapped-region-fallback (61474f6 ported) + #798: world ran at 0.7 – 0.9 fps (1,065 – 1,398 ms/frame), with preparing down to 631 – 837 ms/frame (0 device removals, 0 refused pipelines).

Aggregate timings only; no game data posted. AI-assisted; builds and runs executed on my machine.

**@⁠MartinIndra02** on GitHub · 2026-11-24 14:24 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7134323522) Additional in-title A/B on top of the full `r4tedx/integration/testers` stack (`mpDom/pr/present-1440p-fallback` `d6897fa`, Windows 11, **RTX 3080 `621.24`**, diag build, `VICTORY_PRESENT_1440P=1`, `VICTORY_SHADER_LOOP_LIMIT=32`, `VICTORY_NO_WATCHDOG=1`, `VICTORY_D3D12_DRED=1`): - **Baseline (`d6897fa`):** world settled at **`0.2 – 0.4 fps` (`2,733 – 4,100 ms/frame`)**, of which `preparing` was **`2,009 – 3,107 ms/frame`** (`0` device removals). - **With `perf/gpu-copy-mapped-region-fallback` (`61474f6` ported) + `#798`:** world ran at **`0.7 – 0.9 fps` (`1,065 – 1,398 ms/frame`)**, with `preparing` down to **`631 – 837 ms/frame`** (`0` device removals, `0` refused pipelines). *Aggregate timings only; no game data posted. AI-assisted; builds and runs executed on my machine.*
Author
Owner

@⁠jtrudeau1530 on GitHub · 2026-11-24 16:10 UTC · original

Measured on RX 7900 XT / RADV Mesa 26.2.3, Wine 11.18, vkd3d-proton 3.2.0 (cae8353), native Microsoft d3dcompiler_47. Compared official ffe310e with exact MartinIndra02 commit 61474f6b35, its sole parent ffe310e. No other source changes, same diagnostics flags.

The new hole-copy regression executed and passed under Wine. In the bounded title run, late copy windows were 187-698 ms instead of roughly 2-4 seconds on the baseline, with approximately 0.7-1.1 fps rather than 0.2-0.4. This is directional evidence, not a matched replay benchmark; work and pipeline warmup differed.

The world remained dark with translation refusals. At about 108 seconds the candidate hit the same TCP read GPUVM signature described in #714 (0x401031, permission fault, followed by device removed 0x887A0005). The earlier baseline observation ended by closing the window, so this does not establish whether the copy change caused a new regression or simply reached an existing faulty submission sooner. Holding any stability claim and reviewing the two public fault fixes in #844 before further title runs.

**@⁠jtrudeau1530** on GitHub · 2026-11-24 16:10 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7137234157) Measured on RX 7900 XT / RADV Mesa 26.2.3, Wine 11.18, vkd3d-proton 3.2.0 (cae8353), native Microsoft d3dcompiler_47. Compared official ffe310e with exact MartinIndra02 commit 61474f6b350ec3b2b8cdf3760eece2b9c9f957cc, its sole parent ffe310e. No other source changes, same diagnostics flags. The new hole-copy regression executed and passed under Wine. In the bounded title run, late copy windows were 187-698 ms instead of roughly 2-4 seconds on the baseline, with approximately 0.7-1.1 fps rather than 0.2-0.4. This is directional evidence, not a matched replay benchmark; work and pipeline warmup differed. The world remained dark with translation refusals. At about 108 seconds the candidate hit the same TCP read GPUVM signature described in #714 (0x401031, permission fault, followed by device removed 0x887A0005). The earlier baseline observation ended by closing the window, so this does not establish whether the copy change caused a new regression or simply reached an existing faulty submission sooner. Holding any stability claim and reviewing the two public fault fixes in #844 before further title runs.
Author
Owner

@⁠0xcheems on GitHub · 2026-11-24 16:20 UTC · original

A/B of 61474f6 on a Strix Halo iGPU under Proton, in case another AMD/Linux data point helps.

AI use: the runs were driven and the logs summarised with Claude Code (Claude Fable 5.2) on my machine. Own copy of 1.0.2.1.

Setup: Ryzen AI MAX+ 395, Radeon 8060S (RDNA 3.5, unified memory, 32 GB, 20 GB GPU limit); NixOS, kernel 7.1.5, Mesa 26.1.5 RADV; Proton Experimental experimental-11.0-20261112, vkd3d-proton 3.2.0. Diag builds cross-built with cargo-xwin, Series X profile, VICTORY_NO_WATCHDOG=1, driven into the world with VICTORY_KEYS, 10-minute runs. Base for both arms: ffe310e + #493 + #454 + #190.

Median over the world lines of the per-frame summary (63 to 65 lines per run):

base + 61474f6, run 1 + 61474f6, run 2
frame 2 800 ms 1 783 ms 1 833 ms
copies 2 119 ms / 129 MB 869 ms / 137 MB 1 097 ms / 141 MB
on the GPU 42 ms 44 ms 43 ms
copying back 161 ms 165 ms 157 ms

So about -35 % on the frame and roughly half the copy time here, between the Windows NVIDIA and the RX 9060 XT results above. The arms are separate runs, not the same frames.

One thing to flag, without a cause: run 1 with the commit ended at 8 min 58 s with ring gfx_0.0.0 timeout (thread vkd3d_queue), device removed 0x887A0005 after a submission of 24 lists, and no GPUVM page-fault line. Run 2, the same executable, ran the full 10 minutes, as did the base run. System memory was nearly exhausted at that point (about 1 GB available), so I would not pin it on this change.

**@⁠0xcheems** on GitHub · 2026-11-24 16:20 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7137506207) A/B of `61474f6` on a Strix Halo iGPU under Proton, in case another AMD/Linux data point helps. *AI use: the runs were driven and the logs summarised with Claude Code (Claude Fable 5.2) on my machine. Own copy of 1.0.2.1.* **Setup:** Ryzen AI MAX+ 395, Radeon 8060S (RDNA 3.5, unified memory, 32 GB, 20 GB GPU limit); NixOS, kernel 7.1.5, Mesa 26.1.5 RADV; Proton Experimental `experimental-11.0-20261112`, vkd3d-proton 3.2.0. Diag builds cross-built with cargo-xwin, Series X profile, `VICTORY_NO_WATCHDOG=1`, driven into the world with `VICTORY_KEYS`, 10-minute runs. Base for both arms: `ffe310e` + #493 + #454 + #190. Median over the world lines of the per-frame summary (63 to 65 lines per run): | | base | + `61474f6`, run 1 | + `61474f6`, run 2 | |---|---:|---:|---:| | frame | 2 800 ms | 1 783 ms | 1 833 ms | | copies | 2 119 ms / 129 MB | 869 ms / 137 MB | 1 097 ms / 141 MB | | on the GPU | 42 ms | 44 ms | 43 ms | | copying back | 161 ms | 165 ms | 157 ms | So about -35 % on the frame and roughly half the copy time here, between the Windows NVIDIA and the RX 9060 XT results above. The arms are separate runs, not the same frames. One thing to flag, without a cause: run 1 with the commit ended at 8 min 58 s with `ring gfx_0.0.0 timeout` (thread `vkd3d_queue`), device removed `0x887A0005` after a submission of 24 lists, and no GPUVM page-fault line. Run 2, the same executable, ran the full 10 minutes, as did the base run. System memory was nearly exhausted at that point (about 1 GB available), so I would not pin it on this change.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:52 UTC · original

Automated triage for the maintainers. Confirmed on main: when the first whole-range read fails, copy_mapped in crates/victory-gpu/src/host.rs retries the whole range in 64 KiB pieces, then 4 KiB, with one kernel call per piece (for_pieces), and write_mapped does the same for the copy-back. The cost grows with the size of the range, not with how much of it is unmapped.

Open PR #943 carries the region-walk fallback (the race-safe per-region form from the comments, also starting after the bytes already copied). The in-title A/B runs here (Windows NVIDIA, and AMD under Wine) all show shorter copy times. One Wine run hit the #714 page fault, and nothing so far ties that to this change.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/783#issuecomment-7152320034) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T16:20:25Z at=2026-11-25T03:52:27Z --> Automated triage for the maintainers. Confirmed on `main`: when the first whole-range read fails, `copy_mapped` in `crates/victory-gpu/src/host.rs` retries the whole range in 64 KiB pieces, then 4 KiB, with one kernel call per piece (`for_pieces`), and `write_mapped` does the same for the copy-back. The cost grows with the size of the range, not with how much of it is unmapped. Open PR #943 carries the region-walk fallback (the race-safe per-region form from the comments, also starting after the bytes already copied). The in-title A/B runs here (Windows NVIDIA, and AMD under Wine) all show shorter copy times. One Wine run hit the #714 page fault, and nothing so far ties that to this change. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#783
No description provided.