GPU: reduce submit-thread work tracking pending refreshes #2665

Manually merged
github merged 1 commit from github-bot/gh-2665 into main 2026-11-30 14:14:19 +00:00 AGit
Owner

@⁠yumaste on GitHub · 2026-11-29 15:44 UTC · original
yumaste:nvidia/perf-submit-overlap → main · +68 −22 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC

## Changes

  • Check the existing atomic pending-write flag before inserting a refresh into the address map in the direct flight check. Keep the union of refresh ranges per host copy and their first-seen order.
  • Merge sorted flight ranges in place after sorting the combined input. This removes the second allocation during each call, including when the flight line is locked.

The direct scan is used when write-watch is queried per range and when the submitter checks again after a flight lands. The submit lock prevents a new declaration during the scan. If the last writer retires during that scan, the existing stale check finds no pending ranges under the shadow lock.

Measurement

Optimized synthetic A/B on a Core Ultra 9 275HX, with 20,000 refreshes to 4,500 copies across 20 lists. Both scan implementations ran in the same process, in alternating order. Each row reports the median of 12 batches of 150 scans. Output ranges and host-copy identity matched before timing.

Copies with pending writes Main This PR
0% 136 µs 22 µs
1% 141 µs 28 µs
5% 121 µs 33 µs
25% 144 µs 71 µs
100% 261 µs 250 µs

Range merging took 2.67 to 2.48 µs for 256 existing ranges and 64 incoming ranges. These timings describe CPU work in synthetic benchmarks. In-game frame time is still unmeasured.

Validation

  • cargo test --locked -p victory-gpu --lib -- --test-threads=1 with RTX 5080 selected. 917 passed, 57 ignored.
  • Ran the ignored end-to-end GPU test a_copy_behind_a_flight_reads_what_the_flight_wrote with relay and card steps enabled. Both the default write-watch mode and VICTORY_ASK_ONCE=0 passed.
  • Staged asset policy and git diff --check passed.
  • Strict Clippy fails on the same two unused imports and immutable loop condition in victory-shader on the unmodified base 829188e9 and on this branch.
**@⁠yumaste** on GitHub · 2026-11-29 15:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2665) `yumaste:nvidia/perf-submit-overlap` → `main` · +68 −22 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC ## Changes - Check the existing atomic pending-write flag before inserting a refresh into the address map in the direct flight check. Keep the union of refresh ranges per host copy and their first-seen order. - Merge sorted flight ranges in place after sorting the combined input. This removes the second allocation during each call, including when the flight line is locked. The direct scan is used when write-watch is queried per range and when the submitter checks again after a flight lands. The submit lock prevents a new declaration during the scan. If the last writer retires during that scan, the existing stale check finds no pending ranges under the shadow lock. ## Measurement Optimized synthetic A/B on a Core Ultra 9 275HX, with 20,000 refreshes to 4,500 copies across 20 lists. Both scan implementations ran in the same process, in alternating order. Each row reports the median of 12 batches of 150 scans. Output ranges and host-copy identity matched before timing. | Copies with pending writes | Main | This PR | | ---: | ---: | ---: | | 0% | 136 µs | 22 µs | | 1% | 141 µs | 28 µs | | 5% | 121 µs | 33 µs | | 25% | 144 µs | 71 µs | | 100% | 261 µs | 250 µs | Range merging took 2.67 to 2.48 µs for 256 existing ranges and 64 incoming ranges. These timings describe CPU work in synthetic benchmarks. In-game frame time is still unmeasured. ## Validation - cargo test --locked -p victory-gpu --lib -- --test-threads=1 with RTX 5080 selected. 917 passed, 57 ignored. - Ran the ignored end-to-end GPU test a_copy_behind_a_flight_reads_what_the_flight_wrote with relay and card steps enabled. Both the default write-watch mode and VICTORY_ASK_ONCE=0 passed. - Staged asset policy and git diff --check passed. - Strict Clippy fails on the same two unused imports and immutable loop condition in victory-shader on the unmodified base 829188e9 and on this branch.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 15:47:11 +00:00
Author
Owner

@⁠BitWuehler on GitHub · 2026-11-29 16:41 UTC · original

Confirmed clean merge and in-game stability on Linux (CachyOS) / GE-Proton 11-14 (vkd3d-proton master) / Ryzen 7 9800X3D / RTX 5080 16 GB (base 829188e9 + #2647 + #2656, Series X profile, 1440p, DLSS Quality):

  • Zero regressions or crashes over a full opening playtest (avg ~5,586 draws/frame, max 43.8 fps, worst-case frame hitches down sharply together with #2656).

(Test summary compiled with AI assistance.)

**@⁠BitWuehler** on GitHub · 2026-11-29 16:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2665#issuecomment-7259104166) Confirmed clean merge and in-game stability on **Linux (CachyOS) / GE-Proton 11-14 (`vkd3d-proton master`) / Ryzen 7 9800X3D / RTX 5080 16 GB** (base `829188e9` + #2647 + #2656, Series X profile, 1440p, DLSS Quality): - Zero regressions or crashes over a full opening playtest (avg ~5,586 draws/frame, max 43.8 fps, worst-case frame hitches down sharply together with #2656). *(Test summary compiled with AI assistance.)*
Author
Owner

@⁠tillo88 on GitHub · 2026-11-29 18:05 UTC · original

In-game measurement, since the description says frame time is still unmeasured.

Same route each run: load a save at the start of the game, prison cutscene, then the first boat section to the first package (about 5 min, the same inputs). Numbers are means of the 5-second lines over the run.

base 829188e9, run 1 base, run 2 this PR
fps 31.3 29.7 29.9
submitting thread, ms in its submissions 29.1 34.3 31.2
refreshes, ms a frame 8.7 9.5 8.9
refreshes a frame (of them known to copy nothing) 6,826 (5,761) 6,976 (5,903) 6,849 (5,783)

The PR lands between the two base runs, so on this route the difference is below the run-to-run noise (about 5%). No crashes or visual problems in its run. That fits the synthetic numbers: about 0.1 ms saved a scan against frames of ~33 ms.

For what it's worth, VICTORY_FLUSH_SIFT=1 + VICTORY_FRONT_SIFT=1 measured the same way gave 30.3 fps / 8.4 ms (also noise: here flushes average ~170 refreshes, under the 256 that turns them on), and VICTORY_NEW_BATCH=1 was worse: 29.1 fps / 11.0 ms refreshes.

Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X 1440p, DLSS Quality, frame generation off, ray tracing builder off.

**@⁠tillo88** on GitHub · 2026-11-29 18:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2665#issuecomment-7260203273) In-game measurement, since the description says frame time is still unmeasured. Same route each run: load a save at the start of the game, prison cutscene, then the first boat section to the first package (about 5 min, the same inputs). Numbers are means of the 5-second lines over the run. | | base 829188e9, run 1 | base, run 2 | this PR | |---|---|---|---| | fps | 31.3 | 29.7 | 29.9 | | submitting thread, ms in its submissions | 29.1 | 34.3 | 31.2 | | refreshes, ms a frame | 8.7 | 9.5 | 8.9 | | refreshes a frame (of them known to copy nothing) | 6,826 (5,761) | 6,976 (5,903) | 6,849 (5,783) | The PR lands between the two base runs, so on this route the difference is below the run-to-run noise (about 5%). No crashes or visual problems in its run. That fits the synthetic numbers: about 0.1 ms saved a scan against frames of ~33 ms. For what it's worth, VICTORY_FLUSH_SIFT=1 + VICTORY_FRONT_SIFT=1 measured the same way gave 30.3 fps / 8.4 ms (also noise: here flushes average ~170 refreshes, under the 256 that turns them on), and VICTORY_NEW_BATCH=1 was worse: 29.1 fps / 11.0 ms refreshes. Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X 1440p, DLSS Quality, frame generation off, ray tracing builder off.
Author
Owner

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

An in-game data point from an 8 GB laptop. It covers this PR together with four others, so it can't attribute the gain to this one alone.

Setup: RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24. main at 55d06914, release build, Series S, DLSS performance, VICTORY_LEVELS_ON_DEMAND=0 and VICTORY_COMMIT_FLOOR_MB=1024 in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs.

Combo: main + #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested.

median frame time frames >50 ms per 5 s submitting thread, ms per frame
main 60.7 / 56.7 ms 15.2 / 15.4 52 / 60
combo 49.3 / 48.6 ms 7.6 / 5.8 47 / 44

That's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build, VICTORY_CAPTURE_WORLD) matched main's brightness (mean luma 66.4 against 66.2), with no black holes.

One thing for the diagnostics build: with these merged together, --features diagnostics no longer compiles. A local timing in submit shadows host::timing() at three call sites, and copystat::log_heap_elsewhere uses an mb helper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.

**@⁠icdmkg2** on GitHub · 2026-11-29 18:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2665#issuecomment-7260398896) An in-game data point from an 8 GB laptop. It covers this PR **together with four others**, so it can't attribute the gain to this one alone. **Setup:** RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24. `main` at `55d06914`, release build, Series S, DLSS performance, `VICTORY_LEVELS_ON_DEMAND=0` and `VICTORY_COMMIT_FLOOR_MB=1024` in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs. **Combo:** `main` + #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested. | | median frame time | frames >50 ms per 5 s | submitting thread, ms per frame | |---|---|---|---| | `main` | 60.7 / 56.7 ms | 15.2 / 15.4 | 52 / 60 | | **combo** | **49.3 / 48.6 ms** | **7.6 / 5.8** | **47 / 44** | That's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build, `VICTORY_CAPTURE_WORLD`) matched `main`'s brightness (mean luma 66.4 against 66.2), with no black holes. One thing for the diagnostics build: with these merged together, `--features diagnostics` no longer compiles. A local `timing` in `submit` shadows `host::timing()` at three call sites, and `copystat::log_heap_elsewhere` uses an `mb` helper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.
Author
Owner

@⁠Yuanzer on GitHub · 2026-11-29 18:47 UTC · original · edited 2026-11-29 19:16 UTC

Correction after a same-source control run (AI-assisted local test):

My first pair used an older prebuilt main binary, and it was not comparable to a fresh #2665 build. I rebuilt clean main 829188e9 in a new worktree with the same toolchain, target directory style, release profile, and host-log filter. The corrected pair is:

run FPS median frame median P90 submit thread avg list steps avg
fresh main 829188e9 19 53.2 ms 56.7 ms 35.04 ms 19.89 ms
fresh #2665 51db545d 20 50.3 ms 54.6 ms 33.25 ms 18.55 ms

Both runs used Series S 720p, DLSS Quality preset M, frame generation off, fixed world clock 12:00, and the same saved F1 settings. The PR shows a modest improvement here: +1 FPS, about 2.9 ms shorter median frames, and about 1.8 ms less submit-thread work. The size is within the range of run noise, so I would call it neutral-to-positive rather than a proven universal gain.

I withdraw the earlier regression claim. The earlier 21 FPS comparison was against a stale/pre-existing binary whose build context was not the same as the fresh PR build. I also tried a local variant that cached writes_pending per copy; it did not improve this scene, so I am leaving the submitted implementation alone.

Runs and readings are from the reporter's machine; analysis and wording are AI-assisted.

**@⁠Yuanzer** on GitHub · 2026-11-29 18:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2665#issuecomment-7260759516) · edited 2026-11-29 19:16 UTC Correction after a same-source control run (AI-assisted local test): My first pair used an older prebuilt main binary, and it was not comparable to a fresh #2665 build. I rebuilt clean main 829188e9 in a new worktree with the same toolchain, target directory style, release profile, and host-log filter. The corrected pair is: | run | FPS median | frame median | P90 | submit thread avg | list steps avg | |---|---:|---:|---:|---:|---:| | fresh main 829188e9 | 19 | 53.2 ms | 56.7 ms | 35.04 ms | 19.89 ms | | fresh #2665 51db545d | 20 | 50.3 ms | 54.6 ms | 33.25 ms | 18.55 ms | Both runs used Series S 720p, DLSS Quality preset M, frame generation off, fixed world clock 12:00, and the same saved F1 settings. The PR shows a modest improvement here: +1 FPS, about 2.9 ms shorter median frames, and about 1.8 ms less submit-thread work. The size is within the range of run noise, so I would call it neutral-to-positive rather than a proven universal gain. I withdraw the earlier regression claim. The earlier 21 FPS comparison was against a stale/pre-existing binary whose build context was not the same as the fresh PR build. I also tried a local variant that cached writes_pending per copy; it did not improve this scene, so I am leaving the submitted implementation alone. *Runs and readings are from the reporter's machine; analysis and wording are AI-assisted.*
Author
Owner

@⁠icdmkg2 on GitHub · 2026-11-29 19:21 UTC · original

A second data point, for comparison with @⁠Yuanzer's. Different CPU: RTX 5060 Laptop 8 GB with a Ryzen 7 H 260 (8 cores, no E-cores), Series S, DLSS performance, release.

Same base set (main 55d06914 + #2549 + #2783 + #2647 + #2795), with and without this PR, two alternating pairs:

fps median frame time median submitting thread
with #2665 18.7 / 18.6 47.6 / 50.4 ms 44.9 / 48.1 ms
without 18.9 / 16.9 48.7 / 49.1 ms 45.3 / 46.0 ms

Neutral here: no gain and no loss within the noise, so I don't see the 6 ms regression measured on the i7-14700KF. That's consistent with the per-refresh writes_pending() hypothesis costing more on a hybrid CPU, but it doesn't confirm it.

**@⁠icdmkg2** on GitHub · 2026-11-29 19:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2665#issuecomment-7261216562) A second data point, for comparison with @⁠Yuanzer's. Different CPU: RTX 5060 Laptop 8 GB with a **Ryzen 7 H 260** (8 cores, no E-cores), Series S, DLSS performance, release. Same base set (`main` `55d06914` + #2549 + #2783 + #2647 + #2795), with and without this PR, two alternating pairs: | | fps median | frame time median | submitting thread | |---|---|---|---| | with #2665 | 18.7 / 18.6 | 47.6 / 50.4 ms | 44.9 / 48.1 ms | | without | 18.9 / 16.9 | 48.7 / 49.1 ms | 45.3 / 46.0 ms | Neutral here: no gain and no loss within the noise, so I don't see the 6 ms regression measured on the i7-14700KF. That's consistent with the per-refresh `writes_pending()` hypothesis costing more on a hybrid CPU, but it doesn't confirm it.
github manually merged commit 7dd053efe4 into main 2026-11-30 14:14:19 +00:00
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!2665
No description provided.