Skip to content

D3D12.X: compile compute pipelines eagerly on background workers - #1442

Open
WTactic wants to merge 1 commit into
xcl-dev:mainfrom
WTactic:perf/parallel-compute-pso
Open

WTactic wants to merge 1 commit into
xcl-dev:mainfrom
WTactic:perf/parallel-compute-pso

Conversation

@WTactic

@WTactic WTactic commented Nov 24, 2026 •

Copy link
Copy Markdown

Lazy PSO compilation previously meant compute pipelines were built synchronously on the calling thread during their first bind, leaving worker threads idle while large compute shaders blocked the title.

Submit compute pipelines eagerly so worker threads can build them in parallel across all CPU cores. Also track active driver PSO compiles and surface them in the window title, and make the DXC memory wait timeout and reserve configurable (XCL_MEMORY_WAIT_SECS, XCL_MEMORY_RESERVE_GB, keeping the 60 s default per review feedback).

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: eagerly submit compute pipelines to workers (!compute remaining lazy).
  • crates/xcl/src/hle/d3d12x/pso_async.rs: add atomic counter tracking active driver PSO compilations across worker threads.
  • crates/xcl/src/hle/d3d12x/present.rs: display active/built PSO counts in window title.
  • crates/xcl/src/gpu/recomp/dxc.rs: make memory reserve and wait timeout configurable via environment variables (defaulting to 60 s).

Tested

  • Hardware: NVIDIA GeForce RTX 4090, Intel Core i9-10850K @ 3.60 GHz (10 cores, 20 threads), Windows 11 x64 (26200), rustc 1.97.1, release/debug
  • cargo test -p xcl --lib pso: 26 passed, 0 failed, 1 ignored

Regression run
main (1d027e5):

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: NVIDIA GeForce RTX 4090
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1529 (PresentX 1529)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15898 MB

PR (293584e):

xcl-smoke v1
commit: 293584e0078a9c4b616054ad6a9806bc6a4893a4
gpu: NVIDIA GeForce RTX 4090
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1335 (PresentX 1335)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18612 MB

Not tested

  • AMD RDNA GPU adapter.

AI use

  • Gemini 4 Hydrogen + custom harness: diagnosed compute binding stalls, implemented eager compute worker dispatch, configurable memory wait overrides, and regression tested.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit e9c84b0

Verified clean merge with main (b7aa9f3) on e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7: workspace tests pass (0 failures, 0 skips), 0 crashes / 0 device removals on AMD RDNA4, +4.0 to +5.2 GB higher peak commit (14855 MB on main → 20089 MB cold / 18881 MB second run) and -119 frames on the initial 60 s run while background compute PSO workers run concurrently.

Tested

  • Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none)
  • 60 s retail smoke telemetry (report.json d3d12):
    • Run 1 (below under Regression run): frames shown: 1559 (PresentX 1560) vs 1678 on main, peak commit: 20089 MB (+5234 MB vs main's 14855 MB), translated_pipelines: 446, failed_pipelines: 0, background_pipelines: [446, 0, 57377], dxil_cache: { hits: 461, misses: 232, compilations: 232 }
    • Run 2 (consecutive 60 s run with those 232 shaders cached): exit: 0x0, frames shown: 1674 (PresentX 1674), presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 18881 MB (+4026 MB vs main), translated_pipelines: 475, failed_pipelines: 0, background_pipelines: [475, 0, 57348], dxil_cache: { hits: 693, misses: 29, compilations: 29 }
  • Notes on diff coverage: no unit tests cover the new pso_async::active() counter, the dxc::wait_for_memory timeout change (60 s → 5 s default) / XCL_MEMORY_RESERVE_GB & XCL_MEMORY_WAIT_SECS overrides, or eager compute submission; the two new XCL_MEMORY_* environment variables are also not listed in README.md

Regression run
main (b7aa9f3):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14855 MB

PR (e9c84b0):

xcl-smoke v1
commit: e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1560)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20089 MB

Not tested

  • 16 GB RAM hosts under the shortened 5 s wait_for_memory timeout; XCL_MEMORY_RESERVE_GB / XCL_MEMORY_WAIT_SECS overrides; gameplay past the menus

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon) — ran the workspace test suite and 60 s retail smoke check on AMD RDNA4 and formatted this report.

@LocranKing

Copy link
Copy Markdown

Independent Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, 6C/12T CPU, 32 GB RAM) test report for e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7.

In the 60 s smoke run, xcl.log confirmed multiple background worker threads actively compiling compute PSOs concurrently without crashes or frame drops; peak commit rose by +1511 MB relative to main b7aa9f3 (16241 MB vs 14730 MB, 110.3%, within the 125% ceiling).

Tested

  • Commit: e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7 (clean tree, merge-base 930e8b4)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo build --release --workspace: ok (exit 0)
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored, exit 0
    • SKIPPED (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware

Regression run
main baseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1508)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14730 MB

PR head (e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7):

xcl-smoke v1
commit: e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1511 (PresentX 1511)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16241 MB

Not tested: debug build, custom XCL_MEMORY_WAIT_SECS / XCL_MEMORY_RESERVE_GB overrides, XCL_SAMPLE_* tests on this branch, AMD / wave64 hardware.

AI use: Antigravity (Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Verified head e9c84b0ea1195e39dbea352aa6f4f723d77c4ec7 on Windows 11 / NVIDIA RTX 5080:

  • cargo build --workspace: OK (0 new compiler warnings)
  • cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored

One small review note: lowering wait_for_memory default timeout from 60 s to 5 s (unwrap_or(5)) could let multiple background DXC workers pile into commit memory on tighter 16 GB systems when compute pipelines are submitted eagerly — keeping the default at 60 s while still honoring XCL_MEMORY_WAIT_SECS might be safer.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

Lazy PSO compilation previously meant compute pipelines were built on the
calling thread during their first bind, leaving worker threads idle while
large compute shaders blocked the title.

Submit compute pipelines eagerly so worker threads can build them in
parallel across all CPU cores. Also track active driver PSO compiles and
surface them in the window title, and make the DXC memory wait timeout
and reserve configurable to prevent long worker stalls when system commit
memory is constrained.
@WTactic
WTactic force-pushed the perf/parallel-compute-pso branch from a1a3572 to 293584e Compare November 24, 2026 22:13
@Raghav314

Copy link
Copy Markdown

Test report for the new head 293584e, together with #1273 (be8d052), on main 689f2db: no regression, and no change at the world-load stop, which on this machine is not a pipeline wait.

Setup: RTX 4090 24 GB (driver 617.14, 32-lane waves), 16 threads, 32 GB RAM, Windows 11, release. Local merge c43951b = main 689f2db + this PR + #1273, no conflicts. Retail title, 180 s each, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PRESS_A_AT=20, network off, warm DXIL cache from earlier runs.

main 689f2db + this PR + #1273
frames shown 1532 1518
last present 70 s 72 s
device removals / crashes 0 / 0 0 / 0
peak commit 33.6 GB 35.2 GB
driver builds after the last present 59 (longest 13.4 s) 59 (longest 32.2 s)

Where both stop: at 70–77 s the title's queues wait on four Wait64BitValueX addresses (0x704180110, …120, …138, …158), each logged wait-before-signal, prod=qNone; a GPU wait timeout with the title's fences pending follows, and submits drop to ~0. After that only pipeline builds continue. So on this card the stop is the #1452 wait (here as a stall, not a device removal), and a faster or earlier pipeline doesn't move it; this PR can't be judged on the world load until that is fixed.

main 689f2db:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 180
exit: 0x0
frames shown: 1532 (PresentX 1532)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33561 MB

main + this PR + #1273 (c43951b, a local merge, so not this PR's head commit):

xcl-smoke v1
commit: c43951b3c868e7fd43d84dab5657c2f877aefc25
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 180
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35249 MB

Not tested: this PR without #1273, the test suite on this merge, a cold DXIL cache, whether the longer driver builds after the stop (32 s vs 13 s) come from more builds running at once, AMD.

AI use: Claude Code (Claude Opus 5.5) ran both builds and runs, read the logs and wrote this report for @Raghav314.

@Rednaxeh

Copy link
Copy Markdown
Contributor

RX 7800 XT (RDNA3), 32 GB RAM: no gain from eager compute builds on this machine. The title creates and binds its big compute programs one at a time, and the background workers cannot build them anyway: the 3 GB commit headroom of #1774 is never free here during world loading, so every worker parks in big_compile_turn and the title's own thread ends up compiling at each bind, as on main.

Head 293584e merged locally onto main 568e7db (clean, 6993fb2), release. Ryzen 7 7800X3D, 32 GB RAM (commit limit 43.6 GB with the system-managed page file), driver 32.0.32029.2010, Windows 11 26300. The newer retail title of #505, offline.

Smoke, defaults (HLSL path), A at ~13 s

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD  Radeon RX 7800 XT
title: 0da1204f
seconds: 60
exit: 0x0
frames shown: 1237 (PresentX 1237)
presents per 2 s (last 3): 0 5 10
device removals: 0
crashes: 0
peak commit: 27133 MB
xcl-smoke v1
commit: 6993fb23be08c10fc513de8107b829502d3fa694
gpu: AMD  Radeon RX 7800 XT
title: 0da1204f
seconds: 60
exit: 0x0
frames shown: 1289 (PresentX 1289)
presents per 2 s (last 3): 7 0 10
device removals: 0
crashes: 0
peak commit: 25457 MB

300 s runs, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HUGE_PSO_CONCURRENCY=3 XCL_PSO_TRACE=1 XCL_ACTIVITY=1, thread dump at 200 s

  • Cold: 1631 frames (main, same switches: 1532); presents stop at 92 s in both. The chain of 20 compute programs of 270–330 KB that the AMD driver builds in 12–13 s each still runs one after the other on one title thread (huge, ungated here): the title creates each one right before it binds it, so submitting it to the workers at creation changes nothing. At 200 s, 18 workers were parked in big_compile_turn (3 holding a slot and sleeping in the commit-headroom loop, 15 waiting for a slot) and one title thread was in amdxc64.dll.
  • Warm (same build): the whole chain comes from the driver-blob cache in 1–5 ms; presents still stop at 82 s: 95cc13288a27a96e (ActivateRays, 3.35 MB of plain direct DXIL) enters the driver on a title thread at 78.8 s and has not returned at 300 s, the process at 54.5 GB of commit. On main the same compile starts at 113 s; with this PR's eager build it starts earlier.
  • With XCL_PSO_WAIT_MS=2000 on top: after 120 s not one driver compile runs for the remaining 180 s. The 3 slot holders sit in big_compile_turn's commit_free loop (28.8 GB committed by the process, under 3 GB of commit free on this machine), nothing is wanted any more since the binds give up after 2 s, 2594 dispatches and 256 draws skipped, black window; commit flat at 28.8 GB.

So the premise holds (the workers are idle while the title compiles), but on a 32 GB machine the gate keeps them idle by design, and only a bind that waits gets a compile started. main logs nothing when the headroom holds a build back; that would be worth a line.

Not tested

  • NVIDIA, machines with more commit headroom (where the eager builds would actually run), the suite.

AI use: Claude Code (Claude Fable 5.1) read the logs and wrote this; the runs were mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants