GPU: opt-in batched prewarm for 64 KiB title shadow buffers #178

Manually merged
github merged 1 commit from github-bot/gh-178 into main 2026-11-27 07:26:01 +00:00 AGit
Owner

@⁠KGAT1W on GitHub · 2026-11-27 06:23 UTC · original
KGAT1W:perf/opt-in-title-buffer-prewarm → main · +253 −26 · 3 files · 1 commits · merged 2026-11-27 07:24 UTC

Why

On a Ryzen 7 5700X / RX 7600 (8 GiB), world entry in the opening scene triggers thousands of small title shadow allocations. Move a bounded number of those allocations into the menu/loading period. This targets the transition hitch, not sustained render FPS.

What changes

  • VICTORY_TITLE_PREWARM_COUNT defaults to 0. For example, add -More @{VICTORY_TITLE_PREWARM_COUNT='3328'} to an existing scripts/play.ps1 invocation. The cap is 3584 buffers (224 MiB of payload); 3328 is 208 MiB.
  • After the first successful present a worker creates distinct fresh 64 KiB committed L0 buffers, makes them resident in batches of up to 32, waits for the existing mapping fence, then maps and publishes them. Taking a buffer transfers ownership; released buffers are not recycled. A miss uses the existing allocation path.
  • Speculation is time-bounded, checks DXGI non-local budget and system memory, and drops unused stock on pressure. No change to resolution, texture detail or the default launcher.

Evidence and limits

In the local experimental branch, two control runs with the previous 256-buffer stock had a 2.56 / 2.67 s world-entry interval. Two runs with the 3328-buffer package had 1.16 / 1.22 s; all 3328 buffers were used. The package also changed worker and lock handling, so this is not an isolated A/B of this PR. I have not rebenchmarked this standalone port on current main. An isolated confirmation would compare unset vs 3328 on the same scene/driver and log the transition separately from FPS.

On the upstream-based branch: cargo test --locked --release -p victory-gpu --features diagnostics --lib -- --test-threads=1: 517 passed, 42 ignored. Includes independent mapped buffers after pressure trimming and the budget guard.

The RX 7600 experimental source and build instructions are available for reference. Only the prewarm change is proposed here.

**@⁠KGAT1W** on GitHub · 2026-11-27 06:23 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/178) `KGAT1W:perf/opt-in-title-buffer-prewarm` → `main` · +253 −26 · 3 files · 1 commits · merged 2026-11-27 07:24 UTC ### Why On a Ryzen 7 5700X / RX 7600 (8 GiB), world entry in the opening scene triggers thousands of small title shadow allocations. Move a bounded number of those allocations into the menu/loading period. This targets the transition hitch, not sustained render FPS. ### What changes - `VICTORY_TITLE_PREWARM_COUNT` defaults to 0. For example, add `-More @{VICTORY_TITLE_PREWARM_COUNT='3328'}` to an existing `scripts/play.ps1` invocation. The cap is 3584 buffers (224 MiB of payload); 3328 is 208 MiB. - After the first successful present a worker creates distinct fresh 64 KiB committed L0 buffers, makes them resident in batches of up to 32, waits for the existing mapping fence, then maps and publishes them. Taking a buffer transfers ownership; released buffers are not recycled. A miss uses the existing allocation path. - Speculation is time-bounded, checks DXGI non-local budget and system memory, and drops unused stock on pressure. No change to resolution, texture detail or the default launcher. ### Evidence and limits In the local experimental branch, two control runs with the previous 256-buffer stock had a 2.56 / 2.67 s world-entry interval. Two runs with the 3328-buffer package had 1.16 / 1.22 s; all 3328 buffers were used. The package also changed worker and lock handling, so this is **not an isolated A/B** of this PR. I have not rebenchmarked this standalone port on current main. An isolated confirmation would compare unset vs 3328 on the same scene/driver and log the transition separately from FPS. On the upstream-based branch: `cargo test --locked --release -p victory-gpu --features diagnostics --lib -- --test-threads=1`: **517 passed, 42 ignored**. Includes independent mapped buffers after pressure trimming and the budget guard. The [RX 7600 experimental source and build instructions](https://github.com/KGAT1W/Vice-Tay/tree/experiment/rx7600-next-final) are available for reference. Only the prewarm change is proposed here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 06:25:44 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 06:43 UTC · original

@⁠KGAT1W I enabled CI and ran the two stock tests with your change on current main. Both passed. They cover budget gating and keeping issued buffers after the unused stock is trimmed. The switch stays off by default.

The 1.16–1.22 s result is for the experimental package. The number that would pin down this PR is the world-entry interval on the same RX 7600 setup with the switch unset and set to 3328.

**@⁠TaynanGT** on GitHub · 2026-11-27 06:43 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/178#issuecomment-7211788637) @⁠KGAT1W I enabled CI and ran the two stock tests with your change on current `main`. Both passed. They cover budget gating and keeping issued buffers after the unused stock is trimmed. The switch stays off by default. The 1.16–1.22 s result is for the experimental package. The number that would pin down this PR is the world-entry interval on the same RX 7600 setup with the switch unset and set to 3328.
Author
Owner

@⁠KGAT1W on GitHub · 2026-11-27 07:06 UTC · original

Ran the isolated A/B you requested. On this RX 7600, VICTORY_TITLE_PREWARM_COUNT=3328 reduced the mean world-entry present interval from 4.084 s to 1.978 s (−2.106 s / −51.6%). All four fresh-process runs, in execution order:

Run VICTORY_TITLE_PREWARM_COUNT World-entry interval
1 unset 4.168 s
2 3328 1.852 s
3 3328 2.103 s
4 unset 3.999 s

Build/setup: upstream 6594538 + PR head 5d856ea, release build with diagnostics. Same binary in all four runs (SHA-256 063ba5c4e8577ded5f7a28b532663abc19fd6b616e77997429dc782f37bd917d); the only additional source changes were a local timing/marker probe and a post-window screenshot. No experimental package patches. Ryzen 7 5700X, RX 7600 8 GB, driver 32.0.31041.1004, Windows build 26200. Series S, 1280×720 output, internal scale 0.8, title upscaler 6, windowed, relay 2. Same opening save and copies of the same existing application shader/pipeline/image caches restored before each run; OS/driver caches were not flushed. The control variable was absent from the process environment, not set to 0.

Metric: time between consecutive successful swap-chain Presents, measured with Instant. W = first title frame with ≥500 host draws since the previous one. Took the largest interval ending in [W−12, W], as in the package test; in all four it ended at W−2. No screenshots during that window; a single capture at W+8 confirmed the opening car scene. Both enabled runs logged made=3328 reason="cap" (worker durations 1.112 s and 1.123 s).

This isolates the PR on this machine. It measures the transition hitch, not launch-to-world time or sustained FPS; the earlier 1.16–1.22 s values remain package-only.

**@⁠KGAT1W** on GitHub · 2026-11-27 07:06 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/178#issuecomment-7212152159) Ran the isolated A/B you requested. On this RX 7600, `VICTORY_TITLE_PREWARM_COUNT=3328` reduced the mean world-entry present interval from **4.084 s to 1.978 s** (**−2.106 s / −51.6%**). All four fresh-process runs, in execution order: | Run | `VICTORY_TITLE_PREWARM_COUNT` | World-entry interval | |---:|---|---:| | 1 | unset | 4.168 s | | 2 | 3328 | 1.852 s | | 3 | 3328 | 2.103 s | | 4 | unset | 3.999 s | **Build/setup:** upstream `6594538` + PR head `5d856ea`, release build with diagnostics. Same binary in all four runs (SHA-256 `063ba5c4e8577ded5f7a28b532663abc19fd6b616e77997429dc782f37bd917d`); the only additional source changes were a local timing/marker probe and a post-window screenshot. No experimental package patches. Ryzen 7 5700X, RX 7600 8 GB, driver `32.0.31041.1004`, Windows build `26200`. Series S, 1280×720 output, internal scale 0.8, title upscaler 6, windowed, relay 2. Same opening save and copies of the same existing application shader/pipeline/image caches restored before each run; OS/driver caches were not flushed. The control variable was absent from the process environment, not set to 0. **Metric:** time between consecutive successful swap-chain Presents, measured with `Instant`. W = first title frame with ≥500 host draws since the previous one. Took the largest interval ending in `[W−12, W]`, as in the package test; in **all four** it ended at **W−2**. No screenshots during that window; a single capture at W+8 confirmed the opening car scene. Both enabled runs logged `made=3328 reason="cap"` (worker durations 1.112 s and 1.123 s). This isolates the PR on this machine. It measures the transition hitch, not launch-to-world time or sustained FPS; the earlier 1.16–1.22 s values remain package-only.
github manually merged commit 791648b935 into main 2026-11-27 07:26:01 +00:00
Author
Owner

@⁠NotADonky43 on GitHub · 2026-11-27 07:41 UTC · original

Independent RTX 5070 Ti / Series X allocation attribution

I tested merged 791648b9 with aggregate counters at the registered-title-buffer allocation path (same diagnostic executable, Series X settings, 25,692 offline shader entries and same loaded 1,625-key D3D12 library on both sides). Only VICTORY_TITLE_PREWARM_COUNT changed, 0 to 3328. The worker published all 3328 buffers in 697 ms, well before the world-entry burst.

Through the first logged >1,000-draws/frame interval Off 3328
Synchronous 64 KiB title-buffer allocations 3,252 35
Prewarmed buffers taken 0 3,230
Synchronous 64 KiB allocation wall time, summed across callers 1,748 ms 34 ms
Other-size direct allocations 217 218
Other-size direct allocation time, summed across callers 204 ms 336 ms

This confirms the intended mechanism on this GPU and profile. These timings include the existing residency/map wait and do not add up to a wall-clock world-entry saving. The first heavy telemetry interval appeared at 55.8/56.3 seconds; I did not measure the same per-present stall as the RX 7600 report or do a visual comparison. Peak private/shared memory was about 23.64/5.66 GiB off and 23.77/5.58 GiB on, so no meaningful peak-memory reduction. Both tests closed cleanly under the same 240-second watchdog, with no logged device loss or buffer allocation failure.

**@⁠NotADonky43** on GitHub · 2026-11-27 07:41 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/178#issuecomment-7212720498) <!-- independent-5070ti-791648b-title-stock --> ### Independent RTX 5070 Ti / Series X allocation attribution I tested merged `791648b9` with aggregate counters at the registered-title-buffer allocation path (same diagnostic executable, Series X settings, 25,692 offline shader entries and same loaded 1,625-key D3D12 library on both sides). Only `VICTORY_TITLE_PREWARM_COUNT` changed, 0 to 3328. The worker published all 3328 buffers in 697 ms, well before the world-entry burst. | Through the first logged >1,000-draws/frame interval | Off | 3328 | |---|---:|---:| | Synchronous 64 KiB title-buffer allocations | 3,252 | 35 | | Prewarmed buffers taken | 0 | 3,230 | | Synchronous 64 KiB allocation wall time, summed across callers | 1,748 ms | 34 ms | | Other-size direct allocations | 217 | 218 | | Other-size direct allocation time, summed across callers | 204 ms | 336 ms | This confirms the intended mechanism on this GPU and profile. These timings include the existing residency/map wait and do not add up to a wall-clock world-entry saving. The first heavy telemetry interval appeared at 55.8/56.3 seconds; I did not measure the same per-present stall as the RX 7600 report or do a visual comparison. Peak private/shared memory was about 23.64/5.66 GiB off and 23.77/5.58 GiB on, so no meaningful peak-memory reduction. Both tests closed cleanly under the same 240-second watchdog, with no logged device loss or buffer allocation failure.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 07:41 UTC · original

@⁠KGAT1W Thanks for controlling the cache and alternating the settings. The four runs put the mean entry hitch at 4.084 s unset and 1.978 s at 3328 on your RX 7600. That was the comparison I needed. The tested revision is on main with the setting still opt-in.

**@⁠TaynanGT** on GitHub · 2026-11-27 07:41 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/178#issuecomment-7212722915) @⁠KGAT1W Thanks for controlling the cache and alternating the settings. The four runs put the mean entry hitch at 4.084 s unset and 1.978 s at 3328 on your RX 7600. That was the comparison I needed. The tested revision is on `main` with the setting still opt-in.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 08:01 UTC · original

@⁠NotADonky43 Thanks for measuring the allocation path on Series X. With 3328 configured, the pool served 3,230 requests and synchronous 64 KiB allocations fell from 3,252 to 35. The summed allocation time fell from 1,748 ms to 34 ms. That confirms the pool is taking work out of the transition on the RTX 5070 Ti.

**@⁠TaynanGT** on GitHub · 2026-11-27 08:01 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/178#issuecomment-7213061480) @⁠NotADonky43 Thanks for measuring the allocation path on Series X. With 3328 configured, the pool served 3,230 requests and synchronous 64 KiB allocations fell from 3,252 to 35. The summed allocation time fell from 1,748 ms to 34 ms. That confirms the pool is taking work out of the transition on the RTX 5070 Ti.
This discussion has been locked. Commenting is limited to contributors.
No description provided.