Pipelines: queue a new pipeline at creation, not at first draw (loading-screen stalls ≥70 ms 24 → 0) #622

Open
github-bot wants to merge 2 commits from github-bot/gh-622 into a-publier AGit
Owner

@⁠11run11 on GitHub · 2026-11-27 14:29 UTC · original
11run11:performance/T-0037-eager-pipelines → a-publier · +139 −10 · 2 files · 2 commits · open

A pipeline that no earlier run drew with is only made at its first draw today. A loading screen that creates and then uses many new pipelines per frame waits on its presenting thread for each one in turn. This change queues such a pipeline for the workers when the title creates it, behind requested ones, so it is usually ready by its first draw.

What it is

  • early() only started pipelines that were on the early list (drawn in an earlier run). A cold cache therefore made every pipeline at first use, one after another, on the thread that presents.
  • On a synthetic loading guest that creates and draws 64 new pipelines a frame, this gives 24 of 24 loading frames ≥70 ms, with a worst frame of about 140–150 ms.

The change (crates/victory-gpu/src/pipeline/make.rs only)

  • early(): when a pipeline is not on the early list, it is queued at EARLY priority if fewer than VICTORY_PIPELINE_EAGER pipelines are waiting. The default limit is 256; 0 turns this off and restores the previous behaviour.
  • The limit is checked with QUEUE locked, and WAITING only grows under that lock, so it cannot be overshot (Queue::push_eager).
  • A new counter, EAGER, counts pipelines queued this way. It counts only newly queued entries.
  • When no worker could be started, nothing is queued, and the first draw makes the pipeline itself as before.
  • EAGER_USED counts the speculative pipelines that a draw or dispatch later used. Both counters are in the "host pipelines all made" and "host pipeline library saved" lines.
  • admit() holds start()'s queueing and counting in one function. Behaviour does not change; it exists so the admission can be tested.
  • Tests: speculative_admission_rechecks_capacity_before_queueing; concurrent_speculative_admission_holds_the_limit (8 threads × 200 creations admit exactly the limit); requested_work_goes_before_queued_speculative_work (a requested pipeline is taken before 200 queued speculative ones).

Tested

Windows 11, RX 9070 XT (driver 32.0.32029.2010 family), Rust 1.98.1, cargo build --release -p victory --features diagnostics.

  • cargo test -p victory-gpu --features diagnostics: 452 passed, 0 failed (WARP). This includes the 10 tests in pipeline::make.
  • Synthetic loading guest (original C test title, 5 runs per setting, medians):
adapter setting frames ≥70 ms worst frame frames ≥38 ms frames to finish loading
RX 9070 XT VICTORY_PIPELINE_EAGER=0 (as before) 24 153.9 ms 24 459
RX 9070 XT default (256) 0 53.5 ms 4 274
WARP =0 24 140.6 ms 24 455
WARP default 0 45.9 ms 14 269
  • A small original test title (Night Courier, WARP): all 6 GPU frames match the title's own render. A synthetic x64 guest also binds and returns as expected.
  • I did not test commercial titles.

Measurements: limit values, cache state, program cost, unused pipelines

I measured the guest with --warm (a second run over a cache that a first run filled) and with two extra settings: LOADING_MOVES (programs of 2048 instructions, so each is expensive to compile) and LOADING_UNUSED_PCT (a share of the created pipelines is never drawn). Each value is the median of 3 runs. Loading is the guest's own clock from its first loading frame to its last. CPU is the runtime process's user+kernel time, and peak is its peak private bytes. The scripts and JSON are in the fork's workbench, not in this PR.

workload adapter EAGER loading CPU peak private frames ≥70 ms
64 new pipelines/frame, cold RX 9070 XT 0 / 16 / 32 / 64 / 256 / 512 2684 / 2248 / 1790 / 847 / 854 / 845 ms 1.69 / 1.61 / 1.72 / 1.55 / 1.48 / 1.45 s 327–329 MiB 24 / 24 / 17 / 0 / 0 / 0
same, expensive programs RX 9070 XT 0 / 64 / 256 8964 / 2350 / 2353 ms 4.98 / 4.94 / 4.72 s 385 / 457 / 457 MiB 24 / 24 / 24
same, warm cache WARP 0 / 64 / 256 559 / 406 / 406 ms 0.86 / 0.91 / 0.75 s 359–362 MiB 0
50% never drawn WARP 0 / 64 / 256 1401 / 830 / 865 ms 0.94 / 1.81 / 1.77 s 271 / 358 / 359 MiB 2 / 0 / 0
256 new/frame, 50% never drawn WARP 0 / 64 / 128 / 256 / 512 1380 / 1150 / 1045 / 804 / 829 ms 0.98 / 1.16 / 1.63 / 1.78 / 1.72 s 279 / 302 / 324 / 367 / 366 MiB 6 at every value
expensive, 50% never drawn WARP 0 / 64 / 256 4630 / 2474 / 2481 ms 2.69 / 5.59 / 5.14 s 454 / 901 / 901 MiB 24 / 24 / 24

What this shows:

  • Loading time falls by 2.7–3.8× when everything created is drawn, with the same total CPU, because the work only moves onto the workers. Frames ≥70 ms disappear when each pipeline is cheap. With expensive programs, frames stay long, but loading still ends 3.8× sooner.
  • The gain stops growing once the limit covers what a title creates per burst: 64 for 64 per frame, 256 for 256 per frame.
  • The cost is pipelines that are never drawn. They are made anyway, using CPU on the low-priority workers and the memory their host pipelines and the compiler hold. In the worst synthetic case (expensive and half never drawn), CPU and peak private bytes double, while loading time still halves.
  • In no case was requested work slower than with EAGER=0. Requested pipelines go before queued speculative ones (tested), so I did not add a reserved worker for requested work: nothing measured here asks for one.
  • The new log fields queued_at_creation / queued_at_creation_used ("host pipelines all made" and "host pipeline library saved") show how many of a real title's speculative pipelines it actually drew. That is the number that decides whether the default should stay at 256, be lower, or be opt-in.

Limits and risks

  • Pipelines a title creates but never draws are compiled too (see the table above). The limit counts pipelines waiting at once, not the total compiled: a title that keeps creating pipelines it never draws keeps the workers busy with them. Workers run at THREAD_PRIORITY_LOWEST. VICTORY_PIPELINE_EAGER=0 restores the old behaviour, and I am happy to make the switch opt-in, or to lower the default, if you prefer.
  • It does not help pipelines that are created and drawn in the same frame when the workers are already saturated. Those still wait as before.

CI

Belobug's own ci.yml, unmodified, passes on this branch in my fork (Clippy with -D warnings, default and diagnostics tests): https://github.com/11run11/VIctory-Belobug-11run/actions/runs/46030871483 (commit af07fec).

**@⁠11run11** on GitHub · 2026-11-27 14:29 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/622) `11run11:performance/T-0037-eager-pipelines` → `a-publier` · +139 −10 · 2 files · 2 commits · open A pipeline that no earlier run drew with is only made at its first draw today. A loading screen that creates and then uses many new pipelines per frame waits on its presenting thread for each one in turn. This change queues such a pipeline for the workers when the title creates it, behind requested ones, so it is usually ready by its first draw. ## What it is - `early()` only started pipelines that were on the early list (drawn in an earlier run). A cold cache therefore made every pipeline at first use, one after another, on the thread that presents. - On a synthetic loading guest that creates and draws 64 new pipelines a frame, this gives 24 of 24 loading frames ≥70 ms, with a worst frame of about 140–150 ms. ## The change (`crates/victory-gpu/src/pipeline/make.rs` only) - `early()`: when a pipeline is not on the early list, it is queued at `EARLY` priority if fewer than `VICTORY_PIPELINE_EAGER` pipelines are waiting. The default limit is 256; `0` turns this off and restores the previous behaviour. - The limit is checked with `QUEUE` locked, and `WAITING` only grows under that lock, so it cannot be overshot (`Queue::push_eager`). - A new counter, `EAGER`, counts pipelines queued this way. It counts only newly queued entries. - When no worker could be started, nothing is queued, and the first draw makes the pipeline itself as before. - `EAGER_USED` counts the speculative pipelines that a draw or dispatch later used. Both counters are in the "host pipelines all made" and "host pipeline library saved" lines. - `admit()` holds `start()`'s queueing and counting in one function. Behaviour does not change; it exists so the admission can be tested. - Tests: `speculative_admission_rechecks_capacity_before_queueing`; `concurrent_speculative_admission_holds_the_limit` (8 threads × 200 creations admit exactly the limit); `requested_work_goes_before_queued_speculative_work` (a requested pipeline is taken before 200 queued speculative ones). ## Tested Windows 11, RX 9070 XT (driver 32.0.32029.2010 family), Rust 1.98.1, `cargo build --release -p victory --features diagnostics`. - `cargo test -p victory-gpu --features diagnostics`: 452 passed, 0 failed (WARP). This includes the 10 tests in `pipeline::make`. - Synthetic loading guest (original C test title, 5 runs per setting, medians): | adapter | setting | frames ≥70 ms | worst frame | frames ≥38 ms | frames to finish loading | |---|---|---|---|---|---| | RX 9070 XT | `VICTORY_PIPELINE_EAGER=0` (as before) | 24 | 153.9 ms | 24 | 459 | | RX 9070 XT | default (256) | 0 | 53.5 ms | 4 | 274 | | WARP | `=0` | 24 | 140.6 ms | 24 | 455 | | WARP | default | 0 | 45.9 ms | 14 | 269 | - A small original test title (Night Courier, WARP): all 6 GPU frames match the title's own render. A synthetic x64 guest also binds and returns as expected. - I did not test commercial titles. ## Measurements: limit values, cache state, program cost, unused pipelines I measured the guest with `--warm` (a second run over a cache that a first run filled) and with two extra settings: `LOADING_MOVES` (programs of 2048 instructions, so each is expensive to compile) and `LOADING_UNUSED_PCT` (a share of the created pipelines is never drawn). Each value is the median of 3 runs. *Loading* is the guest's own clock from its first loading frame to its last. CPU is the runtime process's user+kernel time, and *peak* is its peak private bytes. The scripts and JSON are in the fork's workbench, not in this PR. | workload | adapter | `EAGER` | loading | CPU | peak private | frames ≥70 ms | |---|---|---|---|---|---|---| | 64 new pipelines/frame, cold | RX 9070 XT | 0 / 16 / 32 / 64 / 256 / 512 | 2684 / 2248 / 1790 / 847 / 854 / 845 ms | 1.69 / 1.61 / 1.72 / 1.55 / 1.48 / 1.45 s | 327–329 MiB | 24 / 24 / 17 / 0 / 0 / 0 | | same, expensive programs | RX 9070 XT | 0 / 64 / 256 | 8964 / 2350 / 2353 ms | 4.98 / 4.94 / 4.72 s | 385 / 457 / 457 MiB | 24 / 24 / 24 | | same, warm cache | WARP | 0 / 64 / 256 | 559 / 406 / 406 ms | 0.86 / 0.91 / 0.75 s | 359–362 MiB | 0 | | 50% never drawn | WARP | 0 / 64 / 256 | 1401 / 830 / 865 ms | 0.94 / 1.81 / 1.77 s | 271 / 358 / 359 MiB | 2 / 0 / 0 | | 256 new/frame, 50% never drawn | WARP | 0 / 64 / 128 / 256 / 512 | 1380 / 1150 / 1045 / 804 / 829 ms | 0.98 / 1.16 / 1.63 / 1.78 / 1.72 s | 279 / 302 / 324 / 367 / 366 MiB | 6 at every value | | expensive, 50% never drawn | WARP | 0 / 64 / 256 | 4630 / 2474 / 2481 ms | 2.69 / 5.59 / 5.14 s | 454 / 901 / 901 MiB | 24 / 24 / 24 | What this shows: - Loading time falls by 2.7–3.8× when everything created is drawn, with the same total CPU, because the work only moves onto the workers. Frames ≥70 ms disappear when each pipeline is cheap. With expensive programs, frames stay long, but loading still ends 3.8× sooner. - The gain stops growing once the limit covers what a title creates per burst: 64 for 64 per frame, 256 for 256 per frame. - The cost is pipelines that are never drawn. They are made anyway, using CPU on the low-priority workers and the memory their host pipelines and the compiler hold. In the worst synthetic case (expensive and half never drawn), CPU and peak private bytes double, while loading time still halves. - In no case was requested work slower than with `EAGER=0`. Requested pipelines go before queued speculative ones (tested), so I did not add a reserved worker for requested work: nothing measured here asks for one. - The new log fields `queued_at_creation` / `queued_at_creation_used` ("host pipelines all made" and "host pipeline library saved") show how many of a real title's speculative pipelines it actually drew. That is the number that decides whether the default should stay at 256, be lower, or be opt-in. ## Limits and risks - Pipelines a title creates but never draws are compiled too (see the table above). The limit counts pipelines waiting at once, not the total compiled: a title that keeps creating pipelines it never draws keeps the workers busy with them. Workers run at `THREAD_PRIORITY_LOWEST`. `VICTORY_PIPELINE_EAGER=0` restores the old behaviour, and I am happy to make the switch opt-in, or to lower the default, if you prefer. - It does not help pipelines that are created and drawn in the same frame when the workers are already saturated. Those still wait as before. ## CI Belobug's own `ci.yml`, unmodified, passes on this branch in my fork (Clippy with `-D warnings`, default and diagnostics tests): https://github.com/11run11/VIctory-Belobug-11run/actions/runs/46030871483 (commit af07fec).
Split from snapshot 2026-11-27. Admission is checked under the queue lock;
EAGER counts only newly queued pipelines; without workers nothing is queued
and first use makes the pipeline as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:30:16 +00:00
- EAGER_USED: of the pipelines queued at creation, those a draw or dispatch
  used since; both counters in the 'host pipelines all made' and 'host
  pipeline library saved' lines (queued_at_creation, queued_at_creation_used).
- admit(): the queueing and WAITING count of start() in one function (no
  change in behaviour), so the admission can be tested.
- concurrent_speculative_admission_holds_the_limit: 8 threads x 200 creations
  admit exactly the limit.
- requested_work_goes_before_queued_speculative_work: a requested pipeline is
  taken before 200 queued speculative ones; a speculative one a draw asks for
  is promoted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/622/head:github-bot/gh-622'
git switch 'github-bot/gh-622'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-622'
git switch 'github-bot/gh-622'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-622'
git switch 'github-bot/gh-622'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-622'
git switch 'a-publier'
git merge --squash 'github-bot/gh-622'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-622'
git switch 'a-publier'
git merge 'github-bot/gh-622'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.