runtime: prewarm graphics pipelines in recorded order on the compile pool (RT-PIPELINE-PREWARM-ORDER phase 2) #2260

Open
github-bot wants to merge 10 commits from github-bot/gh-2260 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-26 11:00 UTC · original
Tyrannys:claude/pipeline-prewarm-order → main · +3005 −50 · 14 files · 10 commits · open

Claimed in the coordination issue as: RT-PIPELINE-PREWARM-ORDER phase 2 (in-game) (claim); split agreed with MoonEyes on #2220

Depends on: #2233, #2220

This branch has both merged in. Until they land, the diff against main shows their changes too; this pull request's own changes are d864cab47 and 6f2b52e56.

What and why

Our boots reach the first world frame, but the world then draws a frame or so a minute while graphics pipelines build at their first draw. #2220 records which pipelines the title asks for first (LEONIDA_PIPELINE_ORDER_LOG=1). This reads that record at the next boot and builds those pipelines, mostly graphics, ahead of their first draw, in the order the earlier run asked for them, on #2233's compile workers.

  • runtime/src/pipeline_prewarm.h (new, no device): the plan. It reads an order log with #2220's reader (pipeline_order::parse) and takes, from the runs recorded on this GPU (vendor and device id), the one with the most records (the newest on a tie). Graphics and mesh records are kept in recorded order, each (key, variant) once. Compute records are left to the compute warm-up and to MoonEyes' --order-file for gta6rt --precompile-pipelines (the split on #2220).
  • Budget: records are taken in order until their recorded build times add up to LEONIDA_PIPELINE_PREWARM_BUDGET_MS (default 300000; a record with no build time counts 1000 ms), and at most LEONIDA_PIPELINE_PREWARM_MAX_ENTRIES (default 4096).
  • Never ahead of a demanded build: when the title creates a PSO whose description key is in the plan, each recorded variant is queued with queue_build as a warm-up at priority 1 + rank. With #2233's rules that is after every demanded build, one warm-up at a time, and none while a demanded build runs. That is MoonEyes' compile-gate finding in #1608 (07:32): a create in flight holds every submission at the gate, so a warm-up must not start while the title waits for a build. Prewarms go ahead of the compute warm-up's size order and before the cache checkpoint. A variant 0 already built at create is skipped.
  • Ignored with a message: a missing or unreadable file, a file with no readable record, or one recorded on another GPU gives no plan and one [rt] pipeline-prewarm: line. A damaged line is skipped (#2220's checksums), and so are line types a v1 reader does not know: the E lines MoonEyes is adding for the precompiler are dropped before parsing, so they are not counted as damage. On success the line gives the counts (variants, pipelines, recorded build time, how many were over the budget, compute records left out).
  • Switch: LEONIDA_PIPELINE_PREWARM_ORDER=<file>, or 1 for pipeline_order.log beside the session cache. The plan is read when the device starts, before #2220's recorder opens the same file, so both variables can be on in the same run (it then records the prewarmed run as a new session).
  • The order key (order_key, #2220) is now also computed when only the prewarm is on.
  • A console stream kept for its first bind (LEONIDA_PIPELINE_COMPILE=on-demand) whose pipeline is in the plan has its parse queued as its first prewarm job, so it gets the same lead as other PSOs (ecox982745's review: 0 of 8 before the first bind otherwise). A bind that comes first waits for that parse, which it would have done itself.
  • Teardown: a queued prewarm holds no reference, as any queued build: a PSO released first drops it (last_release), and the device's cancel waits for a running one.

Limits:

  • A prewarm already running when the title submits still holds the compile gate, as any warm-up does. The pool keeps that to one at a time and starts none while a demanded build runs, but it does not cut a running one short. LEONIDA_COMPILE_GATE=0 removes the wait.
  • A pipeline is only prewarmed once the title has created its PSO: the log names pipelines by the key of their description, not by SPIR-V, so there is nothing to build before that.
  • A root signature the runtime does not know is hashed by address (see #2220), so such a pipeline's key can change between runs and it is then not found.

Tested

  • New CPU test pipeline_prewarm (no device). The plan cases are:

    • order kept, with repeats and compute records left out;
    • the largest run on this GPU chosen, and another GPU's run not read;
    • budget and entry limit respected;
    • a missing file, garbled text, a damaged line, another GPU's log and an empty file each give no plan (or skip the line) with a message;
    • E lines skipped without counting as damage.

    On the compile workers, with jobs that wait at gates:

    • prewarms queued out of order (as the title creates the PSOs) build in recorded order, after the demanded build that was running;
    • a demanded build submitted while a prewarm runs starts at once on the free worker, and the remaining prewarms wait until it is done.
      It passed 9 runs of 9. Each plan rule was broken by hand in turn (8 mutants: prewarms at priority 0, no budget, no entry limit, E lines kept, the first run instead of the largest, any GPU's run, compute records kept, repeats kept), and the test failed for every one.
  • With #2233 and #2220 merged, these pass: pipeline_prewarm, pipeline_order, replay_pipeline_order_hook, d3d12_compile_pool, d3d12_compile_teardown (pool and one worker), d3d12_big_compute (all 7 settings), d3d12_m4_compute, d3d12_pipeline_workers and d3d12_pipeline_workers_eager: 16 of 16. A boot was running on this machine, so the full suite was not run.

  • Device test prewarm_from_recorded_order in d3d12_pipeline_workers_test (RTX 4070 SUPER): a first device records the order, then console-stream PSOs (slot 86) with an eight-entry plan build those eight before any command is recorded, with the ordinary stream and with on-demand, and nothing without a plan; the image matches and each pipeline is built once. The on-demand case fails without the on-demand fix (0 of 8).

  • python -I tests/test_docs_env_vars.py, tests/test_ctest_registration.py, scripts/check_no_game_data.py on the changed files: pass.

Not tested here: a real boot. Our boot session will measure it on the game (time to the first world frame and frames per minute after it, with and without the prewarm) and post the numbers.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly. (Stacked on #2233 and #2220, both merged in; main merges cleanly.)
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠Tyrannys** on GitHub · 2026-11-26 11:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260) `Tyrannys:claude/pipeline-prewarm-order` → `main` · +3005 −50 · 14 files · 10 commits · open Claimed in the coordination issue as: RT-PIPELINE-PREWARM-ORDER phase 2 (in-game) ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)); split agreed with MoonEyes on #2220 Depends on: #2233, #2220 This branch has both merged in. Until they land, the diff against `main` shows their changes too; this pull request's own changes are d864cab47 and 6f2b52e56. ### What and why Our boots reach the first world frame, but the world then draws a frame or so a minute while graphics pipelines build at their first draw. #2220 records which pipelines the title asks for first (`LEONIDA_PIPELINE_ORDER_LOG=1`). This reads that record at the next boot and builds those pipelines, mostly graphics, ahead of their first draw, in the order the earlier run asked for them, on #2233's compile workers. - `runtime/src/pipeline_prewarm.h` (new, no device): the plan. It reads an order log with #2220's reader (`pipeline_order::parse`) and takes, from the runs recorded on this GPU (vendor and device id), the one with the most records (the newest on a tie). Graphics and mesh records are kept in recorded order, each (key, variant) once. Compute records are left to the compute warm-up and to MoonEyes' `--order-file` for `gta6rt --precompile-pipelines` (the split on #2220). - **Budget:** records are taken in order until their recorded build times add up to `LEONIDA_PIPELINE_PREWARM_BUDGET_MS` (default 300000; a record with no build time counts 1000 ms), and at most `LEONIDA_PIPELINE_PREWARM_MAX_ENTRIES` (default 4096). - **Never ahead of a demanded build:** when the title creates a PSO whose description key is in the plan, each recorded variant is queued with `queue_build` as a warm-up at priority `1 + rank`. With #2233's rules that is after every demanded build, one warm-up at a time, and none while a demanded build runs. That is MoonEyes' compile-gate finding in #1608 (07:32): a create in flight holds every submission at the gate, so a warm-up must not start while the title waits for a build. Prewarms go ahead of the compute warm-up's size order and before the cache checkpoint. A variant 0 already built at create is skipped. - **Ignored with a message:** a missing or unreadable file, a file with no readable record, or one recorded on another GPU gives no plan and one `[rt] pipeline-prewarm:` line. A damaged line is skipped (#2220's checksums), and so are line types a v1 reader does not know: the `E` lines MoonEyes is adding for the precompiler are dropped before parsing, so they are not counted as damage. On success the line gives the counts (variants, pipelines, recorded build time, how many were over the budget, compute records left out). - **Switch:** `LEONIDA_PIPELINE_PREWARM_ORDER=<file>`, or `1` for `pipeline_order.log` beside the session cache. The plan is read when the device starts, before #2220's recorder opens the same file, so both variables can be on in the same run (it then records the prewarmed run as a new session). - The order key (`order_key`, #2220) is now also computed when only the prewarm is on. - A console stream kept for its first bind (`LEONIDA_PIPELINE_COMPILE=on-demand`) whose pipeline is in the plan has its parse queued as its first prewarm job, so it gets the same lead as other PSOs (ecox982745's review: 0 of 8 before the first bind otherwise). A bind that comes first waits for that parse, which it would have done itself. - Teardown: a queued prewarm holds no reference, as any queued build: a PSO released first drops it (`last_release`), and the device's cancel waits for a running one. Limits: - A prewarm already running when the title submits still holds the compile gate, as any warm-up does. The pool keeps that to one at a time and starts none while a demanded build runs, but it does not cut a running one short. `LEONIDA_COMPILE_GATE=0` removes the wait. - A pipeline is only prewarmed once the title has created its PSO: the log names pipelines by the key of their description, not by SPIR-V, so there is nothing to build before that. - A root signature the runtime does not know is hashed by address (see #2220), so such a pipeline's key can change between runs and it is then not found. ### Tested - New CPU test `pipeline_prewarm` (no device). The plan cases are: - order kept, with repeats and compute records left out; - the largest run on this GPU chosen, and another GPU's run not read; - budget and entry limit respected; - a missing file, garbled text, a damaged line, another GPU's log and an empty file each give no plan (or skip the line) with a message; - `E` lines skipped without counting as damage. On the compile workers, with jobs that wait at gates: - prewarms queued out of order (as the title creates the PSOs) build in recorded order, after the demanded build that was running; - a demanded build submitted while a prewarm runs starts at once on the free worker, and the remaining prewarms wait until it is done. It passed 9 runs of 9. Each plan rule was broken by hand in turn (8 mutants: prewarms at priority 0, no budget, no entry limit, `E` lines kept, the first run instead of the largest, any GPU's run, compute records kept, repeats kept), and the test failed for every one. - With #2233 and #2220 merged, these pass: `pipeline_prewarm`, `pipeline_order`, `replay_pipeline_order_hook`, `d3d12_compile_pool`, `d3d12_compile_teardown` (pool and one worker), `d3d12_big_compute` (all 7 settings), `d3d12_m4_compute`, `d3d12_pipeline_workers` and `d3d12_pipeline_workers_eager`: 16 of 16. A boot was running on this machine, so the full suite was not run. - Device test `prewarm_from_recorded_order` in `d3d12_pipeline_workers_test` (RTX 4070 SUPER): a first device records the order, then console-stream PSOs (slot 86) with an eight-entry plan build those eight before any command is recorded, with the ordinary stream and with on-demand, and nothing without a plan; the image matches and each pipeline is built once. The on-demand case fails without the on-demand fix (0 of 8). - `python -I tests/test_docs_env_vars.py`, `tests/test_ctest_registration.py`, `scripts/check_no_game_data.py` on the changed files: pass. Not tested here: a real boot. Our boot session will measure it on the game (time to the first world frame and frames per minute after it, with and without the prewarm) and post the numbers. GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [ ] Based on current `main` and merges cleanly. (Stacked on #2233 and #2220, both merged in; `main` merges cleanly.) - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
pipeline_order.h: a passive recorder of the first request of each pipeline and
variant, with its text file format (checksummed lines, truncated or damaged
lines skipped on read) and a lock-free, allocation-free hot path with a writer
thread of its own. ComputePipeline and GraphicsPipeline get a `requested`
callback, called where a submission is prepared, also for handles that exist
already. Nothing uses either yet; the device wiring is the next commit.

Tests (CPU only): pipeline_order_test (first request only, variants, order,
round trip, truncation at every byte, damaged lines, sessions, full record,
bounded file, unwritable file, 8 threads, no allocation, counts line) and
replay_pipeline_order_hook_test (ready, lazy, skipped, unbound variant).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
RT-PIPELINE-PREWARM-ORDER phase 1. With the variable set to 1 the D3D12 device
appends, per compute, graphics and mesh pipeline and variant that the title
uses for the first time, one line to pipeline_order.log beside
pipeline_cache.session.bin: the description key, the variant, creation and
first-use times since the process started, the build time and whether the
handle was ready. One line of counts at exit. Off by default: nothing reads the
file yet, and a run without the variable carries no hook. It touches no cache
file, the memory gate or the compile queue.

The mesh pipeline's key folds in the MS hash (the graphics key does not cover
it). Documented in runtime/README.md and docs/d3d12_vulkan.md, and the doc test
checks the variable is read and named in both.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
- open(): when the existing log does not end with a newline (a process killed
  mid-line), write one first so the next session line is not glued to the cut
  line and its records are not filed under the previous run.
- Fix the hook comments (vulkan_replay.h, d3d12_vulkan_device.cpp, docs,
  README): the hook never blocks and allocates nothing, but the readiness
  callbacks take a non-blocking try_lock on the first request of a pipeline
  and of a variant.
- Close the order log after the exit pipeline cache write, not before.
- Remove the unused Slot::written and Slot::build_written.
- Tests: cut file then new session, flush stops at an unpublished slot,
  unknown session version rejected. Trailing whitespace fixed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Conflicts: docs/d3d12_vulkan.md (main's shorter async paragraph, then the
order-log paragraph), runtime/CMakeLists.txt (both test blocks kept),
runtime/shims/d3d12_vulkan_device.cpp (both includes; build_compute now
reports ComputeBuild::ms to the recorder).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
With LEONIDA_ASYNC_PIPELINES=1 every demanded build, the compute warm-up and
the cache checkpoint ran on one general worker (plus a graphics-only one), so
one long driver compile held every pipeline a submission asked for behind it,
and their draws and dispatches were skipped meanwhile.

PipelineCompiler now runs LEONIDA_COMPILE_THREADS workers (half the logical
processors, 2 to 8). A worker takes the most urgent job it may:
- demanded builds first, in the order they came, then warm-ups by size, then
  the checkpoint, which waits until no worker compiles;
- large builds (compute over 128 KiB, graphics of 1 MiB or more) and warm-ups
  together take at most threads-1 workers, so one stays free for a small
  demanded build; at most LEONIDA_COMPILE_HEAVY_MAX large builds at once
  (default threads-1, 1 with LEONIDA_SERIAL_BIG_COMPILES=1), compute and
  graphics alike, each still within the memory gate;
- warm-ups run one at a time, and none starts while a demanded build runs:
  each holds the compile gate for its whole create, and a submission waits
  for every create in flight;
- one build of a PSO at a time, so after_running and the teardown rules hold.

LEONIDA_COMPILE_THREADS=1 keeps the layout before the pool. The design is
MoonEyes' (#2077), ported onto #2098's scheduler.

Tests: d3d12_compile_pool (CPU, jobs held at gates: settings, a long build
does not hold up a small demanded one, heavy count, free worker, warm-ups one
at a time and after demanded builds, order, one job per PSO, release/cancel/
stop_for_exit with jobs in flight), and d3d12_compile_teardown also with one
worker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The startup cache checkpoint starts only when no compile worker is busy, but a
demanded build can start on another worker while the checkpoint queries the
cache size. has_compile_waiter() only looked at the queue, so the check after
the size query went on to read the cache blob while that build ran.
has_compile_waiter() now also answers true while a demanded build runs.

New gated test in d3d12_compile_pool_test: the checkpoint waits at a gate
standing in for the size query, a demanded build starts on the second worker,
and the second look must see it. It fails without the fix.

Reported by lixonik in review of #2233.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
LEONIDA_PIPELINE_PREWARM_ORDER=<file> (or 1 for pipeline_order.log beside the
session cache) reads the order log #2220 records. Of the runs recorded on this
GPU, the one with the most records is used. When the title creates a PSO whose
description key is in it, each recorded graphics or mesh variant is queued on
the compile workers (#2233) as a warm-up at priority 1 + rank: after every
demanded build, one warm-up at a time, none while a demanded build runs.

Records are taken in order up to LEONIDA_PIPELINE_PREWARM_BUDGET_MS of recorded
build time (default 300000) and LEONIDA_PIPELINE_PREWARM_MAX_ENTRIES (4096).
Compute records are left to the compute warm-up and the offline precompiler.
A missing, garbled or other-GPU log is ignored with one message; damaged lines
and the E lines a v1 reader does not know are skipped.

New CPU test pipeline_prewarm: order kept, budget and entry limit, run
choice, a missing or garbled log, E lines, and on the compile workers the
recorded order and a demanded build overtaking the prewarms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:24:44 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 11:06 UTC · original · reviewed

Built the exact head with MSVC on Windows 11. pipeline_prewarm, d3d12_compile_pool, pipeline_order and replay_pipeline_order_hook all passed, including recorded-rank ordering and a priority-0 build overtaking queued prewarms. Reviewed the new phase-2 commit separately from its dependencies. These are CPU checks. The first-frame effect in a title boot was outside this run.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 11:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260#pullrequestreview-6073044175) · **reviewed** Built the exact head with MSVC on Windows 11. `pipeline_prewarm`, `d3d12_compile_pool`, `pipeline_order` and `replay_pipeline_order_hook` all passed, including recorded-rank ordering and a priority-0 build overtaking queued prewarms. Reviewed the new phase-2 commit separately from its dependencies. These are CPU checks. The first-frame effect in a title boot was outside this run. AI-assisted.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 11:20 UTC · original

On an RTX 4090, the recorded plan built the selected graphics variants before the first bind with the ordinary console stream. With LEONIDA_PIPELINE_COMPILE=on-demand, the same plan loaded, but zero of eight built between PSO creation and the first bind. All eight built during command-list recording. This limits how much lead time the prewarm can gain when a title creates PSOs well before it uses them.

I tested d864cab47e3d on Windows 11, NVIDIA 616.64, with Khronos validation. I adapted only d3d12_pipeline_workers_test, using its authored shaders and its counters around the real Vulkan driver. The fixture created the 48 graphics PSOs through console device slot 86 (16 have an unbound render target) and 16 compute PSOs through the regular device API. A recording run produced 64 entries. Both console modes recorded the same keys and variants in the same order.

These two fresh processes used the same recorded file, an eight-entry cap, lazy graphics compilation, and synchronous demand. After creating the PSOs, the fixture waited up to eight seconds for the selected builds before recording any commands.

Console stream Graphics builds before first bind By end of command-list recording By end of submission
Ordinary 8 8 48
On demand 0 8 48

Both paths passed the pixel and compute-buffer readback checks. Neither prewarmed a compute pipeline. Without a plan, both had zero graphics builds through recording. In a separate control through CreateGraphicsPipelineState, a 48-entry plan built all 48 before submission with no additional graphics builds needed by the draw.

The timing matches the code. The pending console path stores the key and returns after set_pending_stream. Its call to prewarm_queue comes via create_graphics when the stream is first resolved. If prewarming at PSO creation is intended in this mode too, the pending-stream path needs explicit handling. Otherwise it would help to document that prewarming starts at first bind in this mode. This was a synthetic device test. In-game frame times remain open. Pending-stream creation · Graphics prewarm call

**@⁠ecox982745** on GitHub · 2026-11-26 11:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260#issuecomment-7190605506) On an RTX 4090, the recorded plan built the selected graphics variants before the first bind with the ordinary console stream. With `LEONIDA_PIPELINE_COMPILE=on-demand`, the same plan loaded, but **zero of eight** built between PSO creation and the first bind. All eight built during command-list recording. This limits how much lead time the prewarm can gain when a title creates PSOs well before it uses them. I tested `d864cab47e3d` on Windows 11, NVIDIA 616.64, with Khronos validation. I adapted only `d3d12_pipeline_workers_test`, using its authored shaders and its counters around the real Vulkan driver. The fixture created the 48 graphics PSOs through console device slot 86 (16 have an unbound render target) and 16 compute PSOs through the regular device API. A recording run produced 64 entries. Both console modes recorded the same keys and variants in the same order. These two fresh processes used **the same recorded file**, an eight-entry cap, lazy graphics compilation, and synchronous demand. After creating the PSOs, the fixture waited up to eight seconds for the selected builds before recording any commands. | Console stream | Graphics builds before first bind | By end of command-list recording | By end of submission | | --- | ---: | ---: | ---: | | Ordinary | 8 | 8 | 48 | | On demand | 0 | 8 | 48 | Both paths passed the pixel and compute-buffer readback checks. Neither prewarmed a compute pipeline. Without a plan, both had zero graphics builds through recording. In a separate control through `CreateGraphicsPipelineState`, a 48-entry plan built all 48 before submission with no additional graphics builds needed by the draw. The timing matches the code. The pending console path stores the key and returns after `set_pending_stream`. Its call to `prewarm_queue` comes via `create_graphics` when the stream is first resolved. If prewarming at PSO creation is intended in this mode too, the pending-stream path needs explicit handling. Otherwise it would help to document that prewarming starts at first bind in this mode. This was a synthetic device test. In-game frame times remain open. [Pending-stream creation](https://github.com/ubiquitarianism/leonida/blob/d864cab47e3d0e5a6f9dabab4c71a8feae106a72/runtime/shims/d3d12_vulkan_device.cpp#L14624-L14628) · [Graphics prewarm call](https://github.com/ubiquitarianism/leonida/blob/d864cab47e3d0e5a6f9dabab4c71a8feae106a72/runtime/shims/d3d12_vulkan_device.cpp#L11619)
With LEONIDA_PIPELINE_COMPILE=on-demand a console stream (device slot 86) is
only parsed when it is first bound, and create_graphics queued the prewarm
from there, so a planned pipeline got no lead at all. ecox982745 measured 0
of 8 planned builds before the first bind in that mode, 8 of 8 otherwise.

When the plan has the stream's pipeline, the parse is now queued as its first
prewarm job (at the rank of its first recorded variant, on a compile worker);
create_graphics then queues the variants as for any other PSO. A bind that
comes first waits for the parse through resolve_type's call_once, as it would
have parsed it itself.

d3d12_pipeline_workers_test gets a device case: a first device records the
order, then console-stream PSOs with an eight-entry plan must build those
eight before any command is recorded, with the ordinary stream and with
on-demand, and nothing without a plan. Without the fix the on-demand case
fails with 0 of 8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-26 12:00 UTC · original

@⁠ecox982745 thanks a lot for this, the table and the fixture made it straightforward. Fixed in 6f2b52e56.

What changed: when a console stream kept for its first bind (LEONIDA_PIPELINE_COMPILE=on-demand) has its pipeline in the plan, prepare_console_stream now queues the stream's parse as its first prewarm job: on a compile worker, at the rank of its first recorded variant, below every demanded build like the other prewarms. create_graphics then queues the recorded variants with their ranks, as for any other PSO. A stream that is not in the plan stays pending until its first bind, as before. A bind that comes before the parse waits for it through resolve_type's call_once, which is the parse it would have done itself. Like any queued build it holds no reference, so a PSO released first drops it. Documented in docs/d3d12_vulkan.md and the README row.

Test: a new case in d3d12_pipeline_workers_test, prewarm_from_recorded_order, built on your setup. The 48 graphics PSOs go through console device slot 86 (on a device proxy), the 16 compute ones through the regular API. A first device records the order with LEONIDA_PIPELINE_ORDER_LOG=1. Then three fresh devices run: the plan with an eight-entry cap and the ordinary stream, the plan with on-demand, and on-demand without a plan. Each creates the PSOs, waits up to 8 s, then checks the number of graphics creates before any command is recorded: 8, 8 and 0. Each then submits, checks the readback against the reference image, and checks that all 48 graphics pipelines were built once.

Without the fix the on-demand case fails exactly as you measured (prewarm (on-demand): 0 graphics builds before the first bind, 8 expected), while the ordinary stream gets 8. With it, d3d12_pipeline_workers passes (3 of 3 repeats), as do d3d12_pipeline_workers_eager, pipeline_prewarm, d3d12_compile_pool, d3d12_compile_teardown* and d3d12_big_compute* (13 of 13). RTX 4070 SUPER, NVIDIA 621.01, Windows 11. As before, in-game frame times are still open.

AI-assisted (Claude Code)

**@⁠Tyrannys** on GitHub · 2026-11-26 12:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260#issuecomment-7191442399) @⁠ecox982745 thanks a lot for this, the table and the fixture made it straightforward. Fixed in 6f2b52e56. **What changed:** when a console stream kept for its first bind (`LEONIDA_PIPELINE_COMPILE=on-demand`) has its pipeline in the plan, `prepare_console_stream` now queues the stream's parse as its first prewarm job: on a compile worker, at the rank of its first recorded variant, below every demanded build like the other prewarms. `create_graphics` then queues the recorded variants with their ranks, as for any other PSO. A stream that is not in the plan stays pending until its first bind, as before. A bind that comes before the parse waits for it through `resolve_type`'s `call_once`, which is the parse it would have done itself. Like any queued build it holds no reference, so a PSO released first drops it. Documented in `docs/d3d12_vulkan.md` and the README row. **Test:** a new case in `d3d12_pipeline_workers_test`, `prewarm_from_recorded_order`, built on your setup. The 48 graphics PSOs go through console device slot 86 (on a device proxy), the 16 compute ones through the regular API. A first device records the order with `LEONIDA_PIPELINE_ORDER_LOG=1`. Then three fresh devices run: the plan with an eight-entry cap and the ordinary stream, the plan with on-demand, and on-demand without a plan. Each creates the PSOs, waits up to 8 s, then checks the number of graphics creates before any command is recorded: 8, 8 and 0. Each then submits, checks the readback against the reference image, and checks that all 48 graphics pipelines were built once. Without the fix the on-demand case fails exactly as you measured (`prewarm (on-demand): 0 graphics builds before the first bind, 8 expected`), while the ordinary stream gets 8. With it, `d3d12_pipeline_workers` passes (3 of 3 repeats), as do `d3d12_pipeline_workers_eager`, `pipeline_prewarm`, `d3d12_compile_pool`, `d3d12_compile_teardown*` and `d3d12_big_compute*` (13 of 13). RTX 4070 SUPER, NVIDIA 621.01, Windows 11. As before, in-game frame times are still open. AI-assisted (Claude Code)
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 12:17 UTC · original

Confirmed on an RTX 4090 (Windows 11, NVIDIA 616.64). At 6f2b52e56 the on-demand console stream built all eight selected graphics variants before the first bind. Its parent d864cab47 built zero before the first bind and all eight during command recording. Both used the same synthetic plan, probe and three compile workers.

I replayed the order file recorded on the parent in six fresh processes on the new head. The counts below are completed Vulkan graphics pipeline creates before recording any commands.

Console stream No plan Eight-entry cap 48-entry cap
Ordinary 0 8 48
On demand 0 8 48

Every run finished with exactly 48 graphics and 16 compute creates, correct pixel and buffer readbacks, and no Vulkan validation errors. The 48-entry case also covers all 16 variants with an unbound render target. The committed pipeline_prewarm, d3d12_pipeline_workers and d3d12_pipeline_workers_eager tests passed separately on the unmodified head. This closes the timing gap from my earlier review for this fixture. In-game frame times still need a separate measurement.

**@⁠ecox982745** on GitHub · 2026-11-26 12:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260#issuecomment-7191804934) Confirmed on an RTX 4090 (Windows 11, NVIDIA 616.64). At `6f2b52e56` the on-demand console stream built all eight selected graphics variants **before the first bind**. Its parent `d864cab47` built zero before the first bind and all eight during command recording. Both used the same synthetic plan, probe and three compile workers. I replayed the order file recorded on the parent in six fresh processes on the new head. The counts below are completed Vulkan graphics pipeline creates before recording any commands. | Console stream | No plan | Eight-entry cap | 48-entry cap | | --- | ---: | ---: | ---: | | Ordinary | 0 | 8 | 48 | | On demand | 0 | 8 | 48 | Every run finished with exactly 48 graphics and 16 compute creates, correct pixel and buffer readbacks, and no Vulkan validation errors. The 48-entry case also covers all 16 variants with an unbound render target. The committed `pipeline_prewarm`, `d3d12_pipeline_workers` and `d3d12_pipeline_workers_eager` tests passed separately on the unmodified head. This closes the timing gap from my earlier review for this fixture. In-game frame times still need a separate measurement.
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 03:05 UTC · original

Test on profile M (RTX 4070 Laptop 8 GB, NVIDIA 621.40), with #2260 merged on main d1dff7949, together with #2220 and #2233 through this branch, plus #2412. The merge needed two trivial resolutions:

  • runtime/src/vulkan_replay.h: keep both the local timed field and the requested callback;
  • runtime/CMakeLists.txt: keep both test targets.

Three runs in a row, same recipe:

  1. Record with LEONIDA_PIPELINE_ORDER_LOG=1: 1,340 lines, 525 graphics pipelines, 237 s of recorded build time.
  2. Prewarm with LEONIDA_PIPELINE_PREWARM_ORDER=1: 525 graphics variant(s) of 525 pipeline(s) to prewarm. The run got furthest of the three: the loading screen faded out at 363 s, it was still submitting at 586 s, and there was no device loss.
  3. Control, no prewarm, warmest cache: froze at 309 s, then device lost at 327 s.

Caveats: MEASURED (n=1 each). The record and control runs also hit the write-back freeze that #2418 fixes, so the comparison is confounded. That said, nothing went wrong with the prewarm itself: no errors, the plan was read, and it ran on the compile workers. A later run with prewarm and #2418 reached the world phase (more than 63k indirect draws). AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠OreoFR** on GitHub · 2026-11-27 03:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260#issuecomment-7208690936) Test on profile M (RTX 4070 Laptop 8 GB, NVIDIA 621.40), with #2260 merged on `main` d1dff7949, together with #2220 and #2233 through this branch, plus #2412. The merge needed two trivial resolutions: - `runtime/src/vulkan_replay.h`: keep both the local `timed` field and the `requested` callback; - `runtime/CMakeLists.txt`: keep both test targets. Three runs in a row, same recipe: 1. Record with `LEONIDA_PIPELINE_ORDER_LOG=1`: 1,340 lines, 525 graphics pipelines, 237 s of recorded build time. 2. Prewarm with `LEONIDA_PIPELINE_PREWARM_ORDER=1`: `525 graphics variant(s) of 525 pipeline(s) to prewarm`. The run got furthest of the three: the loading screen faded out at 363 s, it was still submitting at 586 s, and there was no device loss. 3. Control, no prewarm, warmest cache: froze at 309 s, then device lost at 327 s. Caveats: `MEASURED (n=1 each)`. The record and control runs also hit the write-back freeze that #2418 fixes, so the comparison is confounded. That said, nothing went wrong with the prewarm itself: no errors, the plan was read, and it ran on the compile workers. A later run with prewarm and #2418 reached the world phase (more than 63k indirect draws). AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 03:59 UTC · original

@⁠Tyrannys in case it saves you time with the needs rebase label: #2260 merged onto current main (d1dff7949) is at OreoFR/leonida branch pr2260-on-main (176ec068f). The only conflict was runtime/CMakeLists.txt, and the fix keeps both test targets (heavy_pipeline_cache_test from main, pipeline_order_test from #2220). The same tree, plus other open PRs, built and ran in my retail tests above. Feel free to take it or redo it your way. AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠OreoFR** on GitHub · 2026-11-27 03:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2260#issuecomment-7209430473) @⁠Tyrannys in case it saves you time with the `needs rebase` label: #2260 merged onto current `main` (d1dff7949) is at OreoFR/leonida branch `pr2260-on-main` (176ec068f). The only conflict was `runtime/CMakeLists.txt`, and the fix keeps both test targets (`heavy_pipeline_cache_test` from main, `pipeline_order_test` from #2220). The same tree, plus other open PRs, built and ran in my retail tests above. Feel free to take it or redo it your way. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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