Skip to content

Recompiler: prioritize wanted DXC compiles and reserve worker headroom - #2423

Open
ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:recomp/dxc-priority-queue
Open

ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:recomp/dxc-priority-queue

Conversation

@ChalanaGimhanaX

@ChalanaGimhanaX ChalanaGimhanaX commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1164
Part of #1452
Part of #1833

What is in it
Replaces the single FIFO mpsc::channel in dxc::pool() (crates/xcl/src/gpu/recomp/dxc.rs) with a priority queue (Queue<J>) so DXC compiles that a title thread is actively waiting on (wanted) are never stuck behind queued or long-running background compiles:

  • Priority dequeue (crates/xcl/src/gpu/recomp/dxc.rs): Workers always pop the oldest currently-wanted job ahead of background jobs, even on a single-worker pool (XCL_DXC_THREADS=1).
  • Reserved worker headroom while a title is running: When state::boot().is_some() and total_workers >= 2, background compiles are capped at total_workers - wanted_reserve(total_workers) (reserving (total / 3).clamp(1, 4).min(total - 1) workers for wanted compiles, while wanted compiles may use any free worker). When no title is running (xcl shaders --precompile), reserve is 0 so offline precompilation still uses every worker.
  • Dynamic promotion wakeup (crates/xcl/src/hle/d3d12x/pso_async.rs): When Pending::want() flips demand.wanted from false to true, it drops the demand lock first (preserving strict queue -> demand lock order) and calls dxc::notify_wanted() (a no-op if the DXC pool has not been started yet) so any idle reserved worker immediately picks up an already-queued compile.
  • Panic & partial-spawn safety: An RAII BgSlot guard always decrements bg_active and wakes waiting workers on drop, and QueueState::total_workers tracks the actual spawned worker count (closing cleanly if 0 spawned).

dxc::Job already carried wanted: Wanted so wait_for_memory lets title-waited compiles bypass low-commit throttling, but pool() still queued every compile into one FIFO mpsc::channel across all workers. During retail world load, title threads waiting on compute pipelines can queue behind background DXC compiles for 13–25 s (#1164), contributing to 30 s watchdog terminations (#1452).

Tested

  • Hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F (12 threads), 16 GB RAM + 43 GB pagefile, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.8.2502.11 (Windows SDK 10.0.26100.0), release for focused tests and smoke runs.
  • Rebased cleanly onto origin/main 2898511 (which includes #2420 fixing the pre-existing a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier test failure that tripped CI on 68a284a).
  • Focused unit tests at head 63ea17f (cargo test --release -p xcl --lib -- gpu::recomp::dxc::pool_tests gpu::recomp::dxc::cache_tests hle::d3d12x::pso_async::used_tests a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier --test-threads=1): 31 passed, 0 failed, 0 ignored:
    • gpu::recomp::dxc::pool_tests: 6 passed, 0 failed (wanted_reserve_scales_with_worker_count, wanted_job_jumps_ahead_of_queued_background_jobs, wanted_job_runs_immediately_while_background_workers_are_saturated, queued_background_job_promoted_to_wanted_wakes_reserved_worker, offline_mode_uses_all_workers_for_background_jobs, bg_slot_recovers_after_worker_panic).
    • gpu::recomp::dxc::cache_tests: 11 passed, 0 failed.
    • hle::d3d12x::pso_async::used_tests: 13 passed, 0 failed.
    • gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier: 1 passed, 0 failed.
  • Prior full debug workspace run on the identical patch at 4ac4637 (cargo test --workspace --no-fail-fast -- --test-threads=4): 1,295 passed, 1 failed (the pre-existing 68a284a test now fixed on 2898511), 46 ignored (37 SKIPPED lines on wave32 RTX 3060 / no Windows Developer Mode).

Regression run
Paired 60 s retail smoke runs (.\scripts\smoke.ps1 -Game <retail> -Seconds 60, release build, same title and caches):

PR head (63ea17f):

xcl-smoke v1
commit: 63ea17f3cf85fc0b1c4f4ef3973f1e479df7b530
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1486 (PresentX 1486)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13844 MB

main (2898511):

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1481 (PresentX 1481)
presents per 2 s (last 3): 59 60 27
device removals: 0
crashes: 0
peak commit: 13730 MB

Not tested

  • Cold-cache multi-minute world-load runs past the 60 s smoke window (the smoke runs above were warm-cache menu runs verifying no regression; priority ordering, saturation bypass, dynamic promotion, offline full-width use, and panic recovery are verified deterministically in dxc::pool_tests).
  • Full workspace suite rerun after the zero-conflict rebase from 4ac4637 to 63ea17f (only the 31 targeted tests above + paired 60 s smoke runs were rerun on 63ea17f).
  • AMD / Intel GPUs and Linux/Wine hosts.

AI use
Google Antigravity (Gemini 4 Neon) wrote the implementation, unit tests, and this description, rebased cleanly onto origin/main 2898511, and ran the tests and paired smoke runs on this machine; I reviewed and approved before updating.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 4ac4637ad27d0ed3b731a2e8377f5abab0dd4dd3 (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: 1293 passed, 3 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 dxc and pso_async tests passed.

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

xcl-smoke v1
commit: 4ac4637ad27d0ed3b731a2e8377f5abab0dd4dd3
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1614 (PresentX 1614)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13931 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.

@ChalanaGimhanaX
ChalanaGimhanaX force-pushed the recomp/dxc-priority-queue branch from 4ac4637 to 63ea17f Compare November 25, 2026 19:04
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2404, xcl-dev#2405

Integrates VRAM top-mip pressure shedding (xcl-dev#2385), DXC wanted-compile
prioritization & worker headroom (xcl-dev#2423), inline split pipeline foreground
path (xcl-dev#2424), ExecuteIndirect split program dispatch (xcl-dev#2404), and hosted
view heap exhaustion null-pair fallback (xcl-dev#2405).

Assisted-by: Antigravity (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1, 1219/1):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

@ChalanaGimhanaX

Copy link
Copy Markdown
Contributor Author

Thanks for running verification! That failure is from a stale base before #2420 (c828d8c): the assertion "group barriers in the program" at lower_dxil.rs:1155 was replaced by #2420 ("group barriers after entry branch" at line 1156) to fix the pre-existing 50a9fde / #2074 failure on main.

This PR only touches dxc.rs and pso_async.rs, and head 63ea17f is already rebased onto 2898511 (which includes c828d8c), with CI green and a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier passing. Could you re-run against 63ea17f + current main?

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

No concrete correctness or liveness defect found. The queue/promotion ordering, notification discipline, worker reserve, and panic recovery look sound, and current Windows checks are green. Nonblocking validation gap: tests use synthetic Queue workers rather than the actual pool()/state::boot()/Pending::want glue. A focused integration test that promotes an already-queued real DXC job after a title bind would increase confidence; cold-cache multi-minute title validation also remains untested.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2404, xcl-dev#2405

Integrates VRAM top-mip pressure shedding (xcl-dev#2385), DXC wanted-compile
prioritization & worker headroom (xcl-dev#2423), inline split pipeline foreground
path (xcl-dev#2424), ExecuteIndirect split program dispatch (xcl-dev#2404), and hosted
view heap exhaustion null-pair fallback (xcl-dev#2405).

Assisted-by: Antigravity (Gemini 4 Neon)
@thehollowedone

Copy link
Copy Markdown

Independent Windows/RTX 3080 Ti check of #2423 head 63ea17f, following the request for a current-head rerun. Clean detached checkout; no source changes.

Tested — Windows 11 Pro build 26300, RTX 3080 Ti 12 GB / driver 621.35, Ryzen 7 9800X3D, 32 GB RAM, Rust 1.99.1 MSVC, DXC 1.8.2502.11.

  • cargo build --offline --locked --release --workspace passed. cargo test --offline --locked --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1,369 passed, 0 failed, 46 ignored; 25 explicit SKIPPED (21 no wave64, 3 unsupported per-lane forms, 1 no heap windows). All six gpu::recomp::dxc::pool_tests passed, including queued-job promotion and reserved-worker wakeup.
  • With Windows Developer Mode enabled, cargo test --offline --locked -p xcl --lib shaders::tests::pso_measurement_compiles_an_exact_synthetic_record -- --exact --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored, 0 skipped. ShaderCacheControl accepted the cache-off run; the small synthetic compute PSO reported 3,640 B DXIL, 14 ms DXC and 0.005 s driver creation. This is tool qualification, not a measurement of this scheduling change.

Not tested — a cold multi-minute retail world-load pair, the actual pool() → Pending::want() promotion glue under a saturated title workload, or first-playable-frame timing. The existing queue tests use synthetic workers; this suite result does not close that reviewer’s integration-test gap.

AI-assisted: Codex (GPT-6, exact variant unavailable) reviewed the paths, ran these tests, and drafted this report.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent AMD report for 63ea17f3cf85fc0b1c4f4ef3973f1e479df7b530.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, rustc 1.100.0, debug profile, DXC from Windows SDK 10.0.26100.0, XCL_ADAPTER=radeon. Exact PR head (not a local merge onto main); main at the time was 6d12f58a.
  • cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4: 1368 passed, 1 failed, 46 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff); it fails identically on main 6d12f58a on this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.
  • 7 SKIPPED lines: 6 f16_programs_on_the_gpu / f32_programs_on_the_gpu per-lane cases refused for V_MUL_F16, V_PK_MUL_F16 or V_CVT_F16_F32, and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The new gpu::recomp::dxc::pool_tests (6 tests) all passed.

Not tested

  • scripts/smoke.ps1 / a retail title (no regression run), other adapters, NVIDIA. No game data was used.

AI use

Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. No game files, dumps or shader names are included.

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.

7 participants