Coalesce dirty page parts into copy ranges #2971

Manually merged
github merged 1 commit from github-bot/gh-2971 into gh-pr/2971/base 2026-11-29 22:58:44 +00:00 AGit
Owner

@⁠Brazzo978 on GitHub · 2026-11-29 19:08 UTC · original
Brazzo978:perf/coalesce-written-page-parts → main · +43 −8 · 2 files · 1 commits · merged 2026-11-29 22:54 UTC

What it changes

Build shadow copy ranges from consecutive dirty parts of each 64 KiB page. The previous shadow loop tested all 16 bits and merged adjacent 4 KiB pieces one at a time. This change reports contiguous runs directly, skips unset parts, and uses a fast path for isolated set bits. The other write-watch range builder uses the same iterator. Range clipping and the merge across page boundaries stay in their existing callers.

How it was tested

  • cargo test --locked --profile diag -p victory-gpu --lib parts_tests passed on Windows 10 22H2 with Rust 1.98.1 (MSVC target). The new test reconstructs every 16-bit mask from the emitted ranges and checks that they are ordered and maximal. The existing shadow test covers partial ranges and a run crossing a page boundary.
  • A CPU-only microbenchmark on a Ryzen 7 5800X3D compared the old and new by_parts implementations, compiled with -C opt-level=3. Each sample split 256 pages 1,000 times. The two implementations ran in alternating order for ten samples per process, and five processes were measured. Each pattern was also checked for identical output.
Synthetic mask in every page Before After
One dirty part (0x0040) 3.42 ms 1.11 ms
Contiguous dirty parts (0x1FFE) 6.19 ms 1.13 ms
Alternating dirty parts (0x5555) 7.36 ms 7.48 ms

The table shows the median of the five process medians. These figures describe the CPU-side splitter. Frame times in the title remain unmeasured for this patch.

Checked for overlap

  • Searched open pull requests for the shadow and write-watch range code. #2530 changes when the caller invokes by_parts. #2647 changes submission write-watch work. This patch changes how the splitter visits parts within a page.

Codex helped implement and review the change.

**@⁠Brazzo978** on GitHub · 2026-11-29 19:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2971) `Brazzo978:perf/coalesce-written-page-parts` → `main` · +43 −8 · 2 files · 1 commits · merged 2026-11-29 22:54 UTC ## What it changes Build shadow copy ranges from consecutive dirty parts of each 64 KiB page. The previous shadow loop tested all 16 bits and merged adjacent 4 KiB pieces one at a time. This change reports contiguous runs directly, skips unset parts, and uses a fast path for isolated set bits. The other write-watch range builder uses the same iterator. Range clipping and the merge across page boundaries stay in their existing callers. ## How it was tested - `cargo test --locked --profile diag -p victory-gpu --lib parts_tests` passed on Windows 10 22H2 with Rust 1.98.1 (MSVC target). The new test reconstructs every 16-bit mask from the emitted ranges and checks that they are ordered and maximal. The existing shadow test covers partial ranges and a run crossing a page boundary. - A CPU-only microbenchmark on a Ryzen 7 5800X3D compared the old and new `by_parts` implementations, compiled with `-C opt-level=3`. Each sample split 256 pages 1,000 times. The two implementations ran in alternating order for ten samples per process, and five processes were measured. Each pattern was also checked for identical output. | Synthetic mask in every page | Before | After | | --- | ---: | ---: | | One dirty part (`0x0040`) | 3.42 ms | 1.11 ms | | Contiguous dirty parts (`0x1FFE`) | 6.19 ms | 1.13 ms | | Alternating dirty parts (`0x5555`) | 7.36 ms | 7.48 ms | The table shows the median of the five process medians. These figures describe the CPU-side splitter. Frame times in the title remain unmeasured for this patch. ## Checked for overlap - [x] Searched open pull requests for the shadow and write-watch range code. #2530 changes when the caller invokes `by_parts`. #2647 changes submission write-watch work. This patch changes how the splitter visits parts within a page. Codex helped implement and review the change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:13:35 +00:00
Author
Owner

@⁠icdmkg2 on GitHub · 2026-11-29 20:43 UTC · original

On an RTX 5060 Laptop GPU (8 GB, driver 621.24), Ryzen 7 H 260, Windows 11, this PR loses the device shortly after the game reaches the world. It happened in every run I made with it, and in none without it.

Builds: main at 55d06914 with launcher defaults, plus VICTORY_LEVELS_ON_DEMAND=0 and VICTORY_COMMIT_FLOOR_MB=1024 (see #1411). Release build, Series S, DLSS performance, the prologue's cell, a script driving it.

build runs device lost
main + #3109 + #3104 + #3103 + #2971 3 3 of 3, 6–8 s into the world
main + #2971 alone 1 yes, about 46 s into the world
main + #3109 alone / #3104 alone / #3103 alone 1 each none
main + #2549 + #2783 + #2647 + #2665 + #2795 (another set I'm running) many none

The log at the loss, the same in each run:

ERROR victory_gpu::host: when the host device went: the submitting thread was between submissions (nothing of ours was running on the card), of 0 lists, for 2201.2 ms; pipeline library: no call running ...
ERROR victory_gpu::host: relay: the device was lost before fence value 40316 was reached ...; device removed: The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application. (0x887A0006)

So it's DXGI_ERROR_DEVICE_REMOVED (invalid command), not a hang or a timeout. A guess, not checked: coalescing dirty parts across a boundary a copy must not cross (a page-mapping or placed-resource edge) could produce a copy range the device rejects. I haven't run VICTORY_D3D12_DEBUG=1 yet. I can if that would help pin the command.

**@⁠icdmkg2** on GitHub · 2026-11-29 20:43 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2971#issuecomment-7262302395) On an RTX 5060 Laptop GPU (8 GB, driver 621.24), Ryzen 7 H 260, Windows 11, this PR loses the device shortly after the game reaches the world. It happened in every run I made with it, and in none without it. **Builds:** `main` at `55d06914` with launcher defaults, plus `VICTORY_LEVELS_ON_DEMAND=0` and `VICTORY_COMMIT_FLOOR_MB=1024` (see #1411). Release build, Series S, DLSS performance, the prologue's cell, a script driving it. | build | runs | device lost | |---|---|---| | `main` + #3109 + #3104 + #3103 + **#2971** | 3 | **3 of 3**, 6–8 s into the world | | `main` + **#2971** alone | 1 | **yes**, about 46 s into the world | | `main` + #3109 alone / #3104 alone / #3103 alone | 1 each | none | | `main` + #2549 + #2783 + #2647 + #2665 + #2795 (another set I'm running) | many | none | The log at the loss, the same in each run: ``` ERROR victory_gpu::host: when the host device went: the submitting thread was between submissions (nothing of ours was running on the card), of 0 lists, for 2201.2 ms; pipeline library: no call running ... ERROR victory_gpu::host: relay: the device was lost before fence value 40316 was reached ...; device removed: The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application. (0x887A0006) ``` So it's `DXGI_ERROR_DEVICE_REMOVED` (invalid command), not a hang or a timeout. A guess, not checked: coalescing dirty parts across a boundary a copy must not cross (a page-mapping or placed-resource edge) could produce a copy range the device rejects. I haven't run `VICTORY_D3D12_DEBUG=1` yet. I can if that would help pin the command.
github-bot changed target branch from main to gh-pr/2971/base 2026-11-29 22:57:56 +00:00
github manually merged commit 9780f5c465 into gh-pr/2971/base 2026-11-29 22:57:58 +00:00
Author
Owner

@⁠icdmkg2 on GitHub · 2026-11-30 07:16 UTC · original

Follow-up to my earlier report: the crash is still there on main at 41adb551, which includes this PR as merged.

Laptop, 8 GB NVIDIA, Series S profile, DLSS Performance. I ran 5 back-to-back runs (1 warm-up + 4 measured). Run 3 died after about 26 s in the world:

host GPU failure: relay: the device was lost before fence value 38929 was reached ...
device removed: The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application. (0x887A0006)

The other 4 runs were fine: median 17.1–18.9 fps. The same harness on 55d06914 + #2549/#2783/#2647/#2665/#2795, without this PR, has not hit 0x887A0006 in this scene. Earlier I bisected this crash to 9780f5c4 alone.

I can run a diagnostics build with VICTORY_D3D12_DEBUG=1 and post the named command if that helps.

**@⁠icdmkg2** on GitHub · 2026-11-30 07:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2971#issuecomment-7271556884) Follow-up to my earlier report: the crash is still there on `main` at 41adb551, which includes this PR as merged. Laptop, 8 GB NVIDIA, Series S profile, DLSS Performance. I ran 5 back-to-back runs (1 warm-up + 4 measured). Run 3 died after about 26 s in the world: ``` host GPU failure: relay: the device was lost before fence value 38929 was reached ... device removed: The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application. (0x887A0006) ``` The other 4 runs were fine: median 17.1–18.9 fps. The same harness on 55d06914 + #2549/#2783/#2647/#2665/#2795, without this PR, has not hit 0x887A0006 in this scene. Earlier I bisected this crash to 9780f5c4 alone. I can run a diagnostics build with `VICTORY_D3D12_DEBUG=1` and post the named command if that helps.
Author
Owner

@⁠icdmkg2 on GitHub · 2026-11-30 07:42 UTC · original

Correction to my two comments above: this PR is not the cause. part_runs gives exactly the runs the old loops built, and both callers already merged touching ranges, so the output is the same. The same 0x887A0006 shows up in my logs from builds that never had this change, about 1 run in 15. My bisect caught a random crash. Sorry for the false alarm. I'm tracking the real crash in #3796.

**@⁠icdmkg2** on GitHub · 2026-11-30 07:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2971#issuecomment-7272039016) Correction to my two comments above: this PR is not the cause. `part_runs` gives exactly the runs the old loops built, and both callers already merged touching ranges, so the output is the same. The same 0x887A0006 shows up in my logs from builds that never had this change, about 1 run in 15. My bisect caught a random crash. Sorry for the false alarm. I'm tracking the real crash in #3796.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

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