Skip to content

D3D12.X: pipeline and DXC workers run below normal, raised while a title waits - #3336

Draft
Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:contrib/low-priority-compile-workers
Draft

Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:contrib/low-priority-compile-workers

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Prime

The ordinary pipeline workers (xcl-pso-*) and the DXC workers (xcl-dxc-*) are a thread for every core but one each, at the title's own priority: while a world streams its shaders in, they take cores from the title threads the frame waits for. They stayed at normal priority on purpose, because a title thread can wait for a pipeline and must not wait behind its own threads; only the preload workers had a way out of that (lowest priority, raised to normal while their build is wanted).

Both kinds of worker now start below normal, and the same raise covers them: a normal worker notes itself on the build it runs (Demand::normal_thread), the first waiter raises it to normal and the last one to leave puts it back. A DXC compile runs at normal when its build is wanted as it starts, and one already running is raised (dxc::raise_wanted) when its build becomes wanted. XCL_LOW_PRIORITY_WORKERS=0 keeps every worker at normal priority.

Related: #2423 orders the DXC queue so wanted compiles go first (queue order, not thread priority).

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: pipeline workers start below normal; Demand::normal_thread and the raise while a title thread waits
  • crates/xcl/src/gpu/recomp/dxc.rs: DXC workers below normal, dxc::raise_wanted; test a_running_compile_is_raised_when_a_title_thread_comes_to_want_it
  • README.md: XCL_LOW_PRIORITY_WORKERS

Tested

  • RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0; the suite in debug, the smoke on a release build of the head commit
  • cargo test --workspace --no-fail-fast -- --test-threads=4 with the three uma_driver tests below skipped, on 27c6a4b: 2606 passed, 0 failed, 49 ignored (SKIPPED GPU tests: 28 lines: 21 no wave64 (this card runs wave32), 3 a wave32 per-lane form refused by the translator (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1), 1 no dxc.exe, 1 cannot disable the driver cache (needs Windows Developer Mode))
  • the three skipped tests on their own (cargo test -p xcl --lib -- --test-threads=1 uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window): 3 passed, 0 failed. They are left out of the whole run because on this PC's driver they can end the library test process (exit 0x7c10003, "coherent window could not be restored"), on main too
  • the library harness twice more (cargo test -p xcl --lib -- --test-threads=4, same skips): 2467 passed, 0 failed; 2467 passed, 0 failed
  • the same whole run on main fa20459: 2605 passed, 0 failed, 49 ignored, 28 SKIPPED lines (own-prs-20261129 run, same command)
  • retail title (60 s scripts/smoke.ps1, no input, copied profile and shader cache): blocks below

Regression run

xcl-smoke v1
commit: fa204595a488c60c6c5f905244f0172072c9c2a9
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1334 (PresentX 1334)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15272 MB
xcl-smoke v1
commit: 27c6a4bbc4b66afb589597ce78d96cc7c6295dda
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1509 (PresentX 1509)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15299 MB

Not tested

  • AMD GPUs (this is an NVIDIA wave32 card)
  • the retail title's world: the 60 s runs end on the title's start-up screens
  • Frame times while a retail world builds its pipelines were not measured for this change alone (the 60 s smoke builds few pipelines).

AI use

  • Claude Code wrote the change and its test, wrote this description, and ran the tests and the smoke runs on this PC. The model is not named here: this session cannot tell which model served each turn.

Optional temporary Discord for coordinating contributor work, testing and comparing results.

🤖 Generated with Claude Code

…tle waits

The ordinary pipeline workers (xcl-pso-*) and the DXC workers (xcl-dxc-*) are a thread for
every core but one each, at the title's own priority: while a world streams its shaders in
they take cores from the title threads the frame waits for. They stayed at normal priority on
purpose, because a title thread can wait for a pipeline and must not wait behind its own
threads; only the preload workers had a way out of that (lowest priority, raised to normal while
their build is wanted).

Both kinds of worker now start below normal, and the same raise covers them: a normal worker
notes itself on the build it runs (Demand::normal_thread), the first waiter raises it to normal
and the last one to leave puts it back. A DXC compile runs at normal when its build is wanted
as it starts, and one already running is raised (dxc::raise_wanted) when its build becomes
wanted. XCL_LOW_PRIORITY_WORKERS=0 keeps every worker at normal priority.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaZV7vMq866ni7pGnJC2Ew
@Prime1997 Prime1997 self-assigned this Nov 29, 2026
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@Aniseto

Aniseto commented Nov 29, 2026

Copy link
Copy Markdown

Ran the DXC worker priority test at 27c6a4bb on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_running_compile_is_raised_when_a_title_thread_comes_to_want_it -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 2498 filtered out      (exit 0)

The new test passes: a DXC compile already running is raised when a title thread comes to want its build. The PR is a draft and has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti. It is a CPU-side priority test, not a frame-time measurement.

Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@saintwolf

Copy link
Copy Markdown
Contributor

Reviewed and tested at 27c6a4bb.

Code review findings

  1. DXC workers are never lowered back on Build::unwant (crates/xcl/src/gpu/recomp/dxc.rs): raise_wanted() raises matching workers to THREAD_PRIORITY_NORMAL and immediately removes them from RUNNING, and Build::unwant only lowers the PSO worker. If a title thread waits briefly (XCL_GFX_PSO_WAIT_MS timeout) and moves on, the DXC worker remains at NORMAL for the rest of a multi-second compile.
  2. Lock nesting and priority syscalls under build.demand (crates/xcl/src/hle/d3d12x/pso_async.rs): Build::want calls dxc::raise_wanted() while holding build.demand.lock(), which acquires dxc::RUNNING and runs OpenThread/SetThreadPriority/CloseHandle under both locks. It doesn't deadlock today only because Wanted closures only read an AtomicBool, but calling dxc::raise_wanted() after dropping build.demand removes both the lock-ordering hazard and syscall latency under demand.
  3. Minor / test coverage: xcl-pso-whole (real/dispatch_chain.rs) is not lowered by lower_this_worker(), and there is no unit test covering pso_async's note_worker / Build::want / Build::unwant priority transitions (only dxc::RunningCompile is tested).

Tested locally

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0.
  • cargo test -p xcl --lib gpu::recomp::dxc::queue_tests:: -- --test-threads=1: 3 passed, 0 failed.

AI use

  • Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.

@KOLESNiii KOLESNiii 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.

Static review of 27c6a4bb for the stack in the #3041 comparison.

I independently reached the same worker-priority finding as saintwolf. raise_wanted drops the DXC compile from its tracking list when it boosts the worker. If the last title waiter times out, unwant lowers the pipeline worker only. The compiler can stay at normal priority until the job ends. DXC tracking ?? Waiter removal

Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.

@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.

Critical review of current head 27c6a4bb. Unresolved priority-lifetime issue: raise_wanted removes a running DXC compile from RUNNING when it boosts the worker. Build::unwant lowers the PSO worker, but cannot find and lower that DXC worker after a timed-out title wait. A long compile can therefore remain at normal priority and compete with frame work even after demand ends. Keep the running compile tracked until completion and tie its priority to current waiter count; test a waiter timing out while compilation continues. This was also identified in the existing review thread. No local Windows run.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 27c6a4b, diff read, not a merge-check; draft, so not built or run):

  • Piece helpers are never raised. build_pieces (pso_async.rs ~4324) hands pieces to other normal workers as queue jobs that only set BUILDING; they're never noted on the build's Demand, so while a title waits for the parent, the helpers compiling its pieces stay below normal. When dispatch_chain::build runs on a title thread (compile not deferred, real.rs ~6162), the title thread itself waits on below-normal helpers, where on main they ran at normal.
  • Holders of the one-wide giant-compile lane in big_compile_turn aren't raised either.
  • note_worker, Demand::normal_thread and the reset in RunningBuild::drop have no test; only the DXC raise is tested.
  • Nothing measures load time or frame time while a world builds pipelines; two smoke runs of main on the same PC gave 1334 and 1453 frames, so 1509 doesn't show an effect.
  • CI is red: the lib tests died with 0xc0000005 (D3DSCache, create_device_sets_dred_first); worth a rerun. AI use should name the model.

Fine: the raise and reset happen under the demand / RUNNING locks (no raise after the build ends, no reused thread ids), the Wanted closures only read an atomic (no lock-order problem), THREAD_SET_LIMITED_INFORMATION is enough for SetThreadPriority, and XCL_LOW_PRIORITY_WORKERS=0 restores normal priority.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Test report (not a merge-check: draft)
base: b2b1f10
head: 27c6a4b
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at #3336 (comment), and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main (0 failed); the findings in my review stand
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants