Skip to content

D3D12.X: build a split program's whole form on a worker with the default wait - #2491

Closed
b3IKK wants to merge 2 commits into
xcl-dev:mainfrom
b3IKK:review/2372-default-worker-wait
Closed

b3IKK wants to merge 2 commits into
xcl-dev:mainfrom
b3IKK:review/2372-default-worker-wait

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2372 (9dd8715).

#2372 moves a split program's whole form into pso_async, but Chain::whole calls pso_async::resolve_wait_for(key, budget). With the default wait (XCL_PSO_WAIT_MS unset, budget = None) that function takes the job and builds it on the calling (title) thread — the stall #2372 is about. Only setting XCL_PSO_WAIT_MS sends it to a worker, and then the bind skips dispatches. On the retail 1.0.2.1 title on an RTX 5080 (XCL_DIRECT_DXIL=1, XCL_PSO_WAIT_MS=50, 600 s) that was whole form: 198 asked for, 30 built, **16,701 dispatches skipped** while it was being built, followed by 0xc0000005 at game_scarlett_master.exe+0x5293422.

This adds pso_async::resolve_wait_worker: the whole form is enqueued on the xcl-pso workers and the caller waits for it, never taking the job itself. Chain::whole uses it when the budget is None; with XCL_PSO_WAIT_MS set, the existing budgeted/skip behavior is unchanged.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: resolve_wait_worker (sent to the workers, waited for there).
  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs: Chain::whole uses it for None.
  • whole_tests::a_whole_form_with_no_budget_is_built_on_a_worker_and_not_skipped: the build runs on an xcl-pso thread, returns Whole::Built, and WHOLE_SKIPS does not move.

Measured on the retail title (RTX 5080, retail 1.0.2.1, XCL_DIRECT_DXIL=1, default wait, 600 s):

#2372 + wait 50 ms this branch, default wait
whole forms asked / built 198 / 30 46 / 45
dispatches skipped 16,701 0
last 2 s interval with a present 166 s 92 s
crash 0xc0000005 at 166.5 s none (clean 600 s)

So the skips and the crash are gone, but the title still stops presenting at 92 s: its binds now wait for 45 serialized ~0.7–1.1 MB worker builds. The remaining lever is precompiling those whole forms (or more huge-compile capacity), not skipping them.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 1274 passed, 0 failed, 46 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib -- whole_tests: 2 passed, 0 failed
  • the new test with the None branch put back to resolve_wait_for(key, None): 0 passed, 1 failed — built on None, not on a PSO worker

Regression run

main (426a5a7, clean tree, no local changes):

xcl-smoke v1
commit: 426a5a745db4d5e4b037449ede0b70cb342f5192
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15158 MB

PR (caae07d, clean tree, no local changes):

xcl-smoke v1
commit: caae07d1874fcc2a322a9518982703a4f40c35f8
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15828 MB

(The main block is 426a5a7, an ancestor of the current main, from the same machine and data folder.)

Not tested

  • whether the world presents with a precompiled whole-form set (the 45 worker builds are the remaining wall)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Claude Fable 5.2: implemented the worker path, added the test and confirmed it fails without it, ran the suite and the scripts/smoke.ps1 pair, and ran both retail comparisons on this machine.

Kalmarv and others added 2 commits November 25, 2026 10:25
A split compute program keeps its whole form for what the pieces cannot
run: an ExecuteIndirect, and a dispatch with no allocator to keep its
scratch, in a bundle, or whose scratch allocation fails. That form was built in
`Chain::whole` on the calling thread, the title's, the first time it was
needed, ungated (a title thread's huge compile skips the huge-build
slots) and outside `XCL_PSO_WAIT_MS`. A retail title's ExecuteIndirect
of split programs then held its thread for one 20-35 s whole build after
another, with no present (reported on xcl-dev#2080).

The whole form is now a lazy pipeline in `pso_async`, behind the chain's
address as a stand-in's: it is sent to the PSO workers on first need,
where the huge-build slots and the driver blob cache apply as before (the
build itself, `compute_container` with the chain's root signature and its
`.chain.pso` blob, is unchanged). Its callers wait for it as a bind waits
for an unsplit pipeline: with `XCL_PSO_WAIT_MS` up to the budget, then the
dispatch is skipped and counted until a worker has built it; without a
budget, until it is built, built on the calling thread if no worker has
started it, as before. `XCL_PSO_IMAGE_SKIP` spares it as it would spare the
unsplit program. `forget` releases it, or marks it orphaned while it is
being built. The `compute split:` log line counts the whole forms asked
for and built and the dispatches skipped while one was being built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head caae07d1874fcc2a322a9518982703a4f40c35f8 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1272 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed: hle::d3d12x::real::dispatch_chain::whole_tests::a_whole_form_still_being_built_is_not_waited_for_past_the_budget and a_whole_form_with_no_budget_is_built_on_a_worker_and_not_skipped.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: caae07d1874fcc2a322a9518982703a4f40c35f8
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1616 (PresentX 1616)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13923 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Tried the targeted in-run prebuild on top of #2491: record the whole forms a run asks for in used-wholes.txt (by the program's console record) and submit them at creation on the next run. Retail 1.0.2.1, RTX 5080, XCL_DIRECT_DXIL=1, default wait, 600 s:

run A (records) run B (prebuilds at creation)
whole forms asked / built 77 / 76 92 / 93
dispatches skipped 0 0
last present 92 s 92 s

So the prebuild does build the whole forms earlier (93 built, no skips), but presentation does not move. The arithmetic says why: 77 whole forms of 0.7–1.1 MB at 20–35 s each is ~38 minutes of driver work at the 2–4 huge-compile slots, far more than the ~92 s load window; and creation order is not the ask order, so the first bind still waits for a form that is late in the queue. An in-run prebuild cannot clear this wall — the whole forms have to be built before the run (offline) or the per-form compile time has to come down.

AI use: OpenCode, Claude Fable 5.2 implemented the prebuild, ran both retail passes and wrote this.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

A third pass on the warm whole-form cache shows the frontier is still moving. used-wholes.txt went 77 → 94 → 113 across the three runs (+17, +19). In pass C: whole form: 113 asked for, 112 built, 0 dispatches skipped, presentation 94 s.

The creation-time prebuild works for the forms an earlier run asked for (112 built, 0 skips), but each run reaches ~20 new whole forms, and the first one asked at ~92 s is not in the earlier record, so the bind waits for it and presentation stops there. A targeted offline precompile of the known 113 would have the same problem on the next run: it would prebuild the 113 and the title would ask ~20 more.

Two real options remain: a full offline prebuild of all split programs' whole forms (266 programs × 20–35 s ≈ 2.5 h at 4 workers) so no run asks a cold one, or the allocator-less/bundle scratch path so a Dispatch with no title allocator runs the chain pieces instead of the whole form at all. The in-run ordering/capacity/prebuild levers are exhausted.

AI use: OpenCode, Claude Fable 5.2 ran the third pass on this machine and wrote this.

@KDenKC

KDenKC commented Nov 25, 2026 •

Copy link
Copy Markdown

Correction (later the same night): this was wrong, and you were right that the whole forms need an offline prebuild. The run above had 0 cold compute only because its cache already held whole forms from earlier runs. On a cache without them, the stall after world start is the cold whole forms (built back to back on a title thread by Chain::whole, ungated, and as queued worker builds), and #2551's offline prebuild (--precompile --used-only) cut that stall from 391 s to 62 s on this card: #2088 (comment)

@b3IKK one data point against "the whole forms need an offline prebuild", at least on an RTX 5090. With #2404 (5ca9c23, on main 2898511) the title doesn't build whole forms at all: ExecuteIndirect: 382 chained (0 of them whole, 0 slabs lost), 0 whole, and 0 cold compute builds after one precompile. The frames still stop at the same point (114–125 s, three runs). Thread dumps at 140/170/220 s show one title thread inside nvgpucomp64.dll building graphics pipelines one after another (2–4 s each, one every ~7 s), with the xcl-pso* workers idle. That's the same as @rafelis1997's 5070 Ti measurement on #2088. Details: #2088 (comment)

On a third run with the same cache, the title got through those builds and started the world's work at ~520 s, then lost the device (0x887a0005) 3 s later. That looks like #2403's shader-heap limit, but I have no DRED data for it yet.

So on this card, prebuilding the whole forms offline would remove work that #2404 already avoids, and the 92/120 s wall would stay. I haven't run #2491 itself, and your 5080 may differ.

AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs and wrote this.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@SlopTart

SlopTart commented Nov 25, 2026 •

Copy link
Copy Markdown

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of the two whole-form budget tests (a_whole_form_still_being_built_is_not_waited_for_past_the_budget, a_whole_form_with_no_budget_is_built_on_a_worker_and_not_skipped): 2 passed.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-merit correction for the default path: whole-form builds run on xcl-pso workers while the title waits, and focused worker/ownership/no-skip coverage looks sound. The stack remains blocked because this deliberately preserves #2372 XCL_PSO_WAIT_MS behavior: its own RTX 5080 run with 50 ms records 16,701 skipped whole-form dispatches then crashes. The new default does not make that budgeted split whole-form/ExecuteIndirect skipping safe. Remove/disable it for this form or add safe defer/replay before merge.

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #2404, following #2372's closure.

#2491's worker-on-default-wait was the no-skip half of #2372: with no XCL_PSO_WAIT_MS, Chain::whole took the build on the title's thread, so the bind waited for each whole form. #2404 removes that path for chained ExecuteIndirects: the whole form is built at the program's first chained ExecuteIndirect on an xcl-pso-chain-whole thread that waits for the huge-build turn, and it is never built on the title's thread there. Kalmarv's measurements on the remaining fallbacks (another command signature, a bundle, a list without an allocator, a Dispatch without scratch) show no whole-form-sized build over 2 s off the workers in the warm runs, so the default-wait worker adds nothing for them.

The Dispatch/bundle fallbacks that this PR would still cover are removed instead by #2519, now re-stacked directly on #2404 (50af98e): those dispatches run the already-built pieces with an XCL-owned scratch, so no whole form is built at all.

Evidence kept here: the test failed without the change (built on None, not on a PSO worker), suite 1274/0/46, smoke 1627, and the retail comparison (46 asked/45 built, 0 skipped, no crash, presentation 92 s). Thanks to everyone who tested it.

AI use: OpenCode, Claude Fable 5.2 read #2372's closure, checked #2404's head, and wrote this.

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