Skip to content

D3D12.X: a pipeline that must wait for a compile slot leaves its worker free - #3306

Open
grahamster2 wants to merge 1 commit into
xcl-dev:mainfrom
grahamster2:pr/huge-pso-handoff
Open

grahamster2 wants to merge 1 commit into
xcl-dev:mainfrom
grahamster2:pr/huge-pso-handoff

Conversation

@grahamster2

Copy link
Copy Markdown
Collaborator

On an RTX 3080 in a retail title, pipeline building stood still in game. All xcl-pso workers and helpers were parked at the huge-compile gate, the window said "driver 1 building (21 waiting for a slot)" with 1000+ pipelines queued, and the game ran at 0–2 fps with a black screen (draws without a built pipeline are left out). In the log, 21 huge compiles (667 KB – 1.08 MB of DXIL) each waited 90–213 s at the gate for 4–21 s of driver work.

Root cause: a gated compile on a normal worker (huge: ≥ 256 KB of DXIL, XCL_HUGE_PSO_CONCURRENCY default 1; also the 4 MiB giant lane and AMD's 128–256 KiB compute lane) parks it in big_compile_turn. A helper took the parked worker's place in the queue, but no more helpers than normal workers were started (compile_threads). The helpers took huge builds too and parked behind the same slot. Once every worker and helper stood at the gate, nothing served the queue.

The parked build stays on its thread: its driver call is made of what that thread holds (descriptors and DXIL on its stack, known only after translation and DXC). That thread waits for the slot and builds it, and the result is delivered as before. What changes is the seat in the queue: every parked normal worker or helper now gets a replacement, up to XCL_HUGE_PSO_HANDOFFS (default twice the normal workers, never fewer than them, at most 512). Each helper builds pipelines too and takes memory, so one is started only while 3 GB of commit is free (the floor the huge gate itself waits for); a parked build that found no headroom tries again on each 50 ms look while it waits (the counts are checked first, so commit is only asked while a helper is missing; like before, a helper is started with the gate's lock held). The slot limits and the commit gate are unchanged.

With many unwanted builds waiting at once, a wanted one (a title thread waits for it) must not lose a freed slot to them: while one waits (Slots::wanted_waiting), no unwanted build takes a slot. This only changes anything in a lane where the wanted cap equals the unwanted one (wanted_most == most): the giant lane (1 / 1), or XCL_HUGE_PSO_WANTED_CONCURRENCY / XCL_MEDIUM_PSO_WANTED_CONCURRENCY set equal to their unwanted counterparts. With the defaults of the huge (1 / 2) and AMD medium lanes, a wanted build has slots of its own above the unwanted cap that no unwanted build takes, so there it changes nothing.

No issue.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: handoff_most (XCL_HUGE_PSO_HANDOFFS, default 2× the normal workers); park_for_big_compile / ParkedWorker::top_up / may_add_helper start a helper only under the bound and with 3 GB of commit free (real::big_compile_commit_free); HANDED_OFF counts helpers actually started, shown as "N workers handed off at the compile gate" on the pipeline line.
  • crates/xcl/src/hle/d3d12x/real.rs: big_compile_turn retries a helper while it waits; Slots::wanted_waiting; an unwanted build does not take a slot while a wanted one waits.
  • README.md: XCL_HUGE_PSO_HANDOFFS next to the huge / medium compile knobs.
  • Tests: helpers_parked_at_the_gate_are_replaced_too and an_unwanted_build_leaves_a_free_slot_to_a_waiting_wanted_one fail without the change (checked by putting back the compile_threads bound and dropping the wanted_waiting check); parked_workers_start_no_helper_without_commit_and_none_past_the_bound (no commit headroom: no helper; 2 parked with a bound of 1: one helper, the queue still served); a_helper_starts_only_under_the_bound_and_with_commit_free; the_handoff_bound_is_never_below_the_workers. The wanted-slot test polls against a 10 s deadline instead of sleeping a fixed 120 ms. The queue tests that park workers take the commit as free and get their bound passed, so they depend neither on the machine's commit nor on XCL_HUGE_PSO_HANDOFFS. The job of the existing test graphics_first_use_carries_the_exact_serialized_recipe_identity now builds no pipeline: it releases its stand-in without waiting for the build, and a build-ahead worker finishing that orphan released the fake 0x4332 as a COM object. With an earlier version of the new test that parked every normal worker, the xcl lib test binary aborted that way (misaligned pointer dereference in xcl-pso-ahead-N) in 3 of 6 used_tests:: runs; main had 0 of 5. After both changes: 5 of 5 passed.

In game (development build, not this head)

Two 300 s+ runs of the same retail title on this machine, on a development branch (main plus a page-alias port and other changes, with XCL_HUGE_PSO_CONCURRENCY=2 XCL_HUGE_PSO_WANTED_CONCURRENCY=3, 11 compile threads), with the previous version of this change. They differ only in XCL_HUGE_PSO_HANDOFFS. The counter there still counted parked builds, not started helpers.

  • Default bound (64 at the time): the title did not freeze on the gate, but it ran the machine out of RAM. From xcl.log: a pipeline worker waits for a huge compile slot – a helper serves its queue meanwhile (64 helpers so far) at 166.8 s, and at 295.6 s … 181 with 256 KB of DXIL or more), 87 huge builds handed off, …. Free RAM from the run's monitor:
    [107 s] presents/2s=60 submits/2s=180 last present at 104 s, free=10.1 GB commitLeft=69.3 GB
    [275 s] presents/2s=3 submits/2s=56 last present at 275 s, free=2.3 GB commitLeft=59.6 GB
    [295 s] presents/2s=0 submits/2s=12 last present at 287 s, free=0.9 GB commitLeft=57.9 GB
    elapsed 305 s; killed: free=1.78GB (10th sample under 2) at 305 s; exit ; peak commit 19.3 GB
    
  • XCL_HUGE_PSO_HANDOFFS=8: … (8 helpers so far) at 105.7 s, and at 348.8 s … 206 with 256 KB of DXIL or more), 49 huge builds handed off, …. Free RAM went down to 2.5 GB once and then stayed between 4.1 and 6.4 GB:
    [145 s] presents/2s=0 submits/2s=0 last present at 102 s, free=2.5 GB commitLeft=58.7 GB
    [165 s] presents/2s=0 submits/2s=0 last present at 102 s, free=6.4 GB commitLeft=64 GB
    [339 s] presents/2s=1 submits/2s=1 last present at 339 s, free=4.1 GB commitLeft=61.6 GB
    
  • Hence the lower default (2× the normal workers: 22 on this machine). The 3 GB commit check would not have stopped the helpers in the first run: commit left stayed above 57 GB while physical RAM ran out. It bounds commit, not free RAM; the bound on the helpers is what kept RAM in the second run.

Tested

  • NVIDIA GeForce RTX 3080 10 GB, driver 610.88; AMD Ryzen 5 7600X; Windows 11 build 10.0.26200.9974; rustc 1.94.0 (4a4ef493e 2026-03-02); tests in the debug profile, smoke runs on a release build (cargo build --release -p xcl)
  • on 3db78f6f96f102714a2e232552e44cfecf4e8147: cargo build --workspace ok; cargo test --workspace -- --test-threads=4: 2613 passed, 0 failed, 49 ignored
  • 29 SKIPPED lines on this adapter (no wave64 on NVIDIA, no heap windows, no D3D12 debug layer):
    • SKIPPED gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64
    • SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64
    • SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
    • SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
    • SKIPPED hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)
    • SKIPPED the title under the debug layer (dred: false): no d3d12SDKLayers.dll
    • SKIPPED the title under the debug layer (dred: true): no d3d12SDKLayers.dll
    • SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

Regression run

  • scripts/smoke.ps1 -Game <title folder> -Seconds 60 -StartupTimeoutSeconds 900 with XCL_DEVICE_TYPE=lockhart XCL_PREPARE=0 (Series S mode as in the contributor's runs; no startup shader preparation, so pipelines are built in game) (smoke.ps1 sets XCL_NETWORK=0); same retail title, same settings for both runs. Both stay on the title's first screens (about 660 draws per 2 s) for the 60 s.

main:

xcl-smoke v1
commit: fa204595a488c60c6c5f905244f0172072c9c2a9
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1680 (PresentX 1680)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 12321 MB

this PR's head:

xcl-smoke v1
commit: 3db78f6f96f102714a2e232552e44cfecf4e8147
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 12317 MB

Not tested

  • This head in the long in-game runs above: they were on a development branch with an earlier version of this change (no commit check, bound 64 or 8). The default of 22 on this machine was not run in game, so how much RAM it leaves in that scene is not measured.
  • The 60 s smoke run stays on the title's first screens: the gate is not contended there. The last pipeline line of its xcl.log: D3D12.X: lazy pipelines: 60744 made (58002 graphics), 4305 built (4305 before their first use, 3 with 256 KB of DXIL or more), 0 workers handed off at the compile gate, 54864 translated ahead, 56431 in the build-ahead backlog; binds waited 0 ms for pipelines being built (0 waits in 2 s).
  • AMD GPUs (the medium compute lane), other titles.

AI use

  • Claude Code with Claude Opus 5.5: wrote the code and tests, ran the tests and smoke runs, drafted this description. A separate Claude Code agent that did not write the change reviewed the diff adversarially and its findings were fixed before opening.

…er free

On an RTX 3080 pipeline building stood still in game: the window said
"driver 1 building (21 waiting for a slot), ... 1000+ pipelines queued",
0 - 2 fps and a black screen (draws without a built pipeline are left
out). In the log 21 huge compiles (667 KB - 1.08 MB of DXIL) each waited
90 - 213 s at the gate for 4 - 21 s of driver work.

Root cause: a gated compile (huge: >= 256 KB of DXIL,
XCL_HUGE_PSO_CONCURRENCY default 1; also the giant lane and AMD's
medium compute lane) on a normal worker parks it in big_compile_turn.
A helper took the parked worker's place in the queue, but no more
helpers than normal workers were started (compile_threads), and the
helpers took huge builds too and parked behind the same slot. Once
every worker and every helper stood at the gate, nothing served the
queue.

The driver call of a parked build is made of what its thread holds (the
descriptors and DXIL on its stack, known only after translation and DXC),
so the build stays on that thread, which waits for the slot and builds
it; its result is delivered as before (complete, done/cv, cache publish).
What changes is the seat in the queue: every parked normal worker or
helper now gets a replacement, up to XCL_HUGE_PSO_HANDOFFS (default twice
the normal workers, never fewer than them), so normal builds go on. Each
helper builds too and takes memory, so one is started only while 3 GB
of commit is free (the floor the huge gate itself waits for); a parked
build that found no headroom tries again while it waits. On a
development branch a bound of 64 drained the queue in game but ran the
machine out of RAM. The slot
limits and the commit gate are unchanged.

With many unwanted builds waiting at once, a wanted one (a title thread
waits for it) must not lose a freed slot to them: while one waits
(Slots::wanted_waiting) no unwanted build takes a slot. That only
matters in a lane where wanted_most == most (the giant lane, or the
environment set so); elsewhere a wanted build has slots of its own. The
wanted cap and its commit bypass are unchanged.

The pipeline line counts "N workers handed off at the compile gate"
(helpers actually started). README documents XCL_HUGE_PSO_HANDOFFS.

Tests: helpers_parked_at_the_gate_are_replaced_too (2x the workers parked,
a later build still runs; fails before this change),
parked_workers_start_no_helper_without_commit_and_none_past_the_bound,
a_helper_starts_only_under_the_bound_and_with_commit_free,
an_unwanted_build_leaves_a_free_slot_to_a_waiting_wanted_one (fails
before), the_handoff_bound_is_never_below_the_workers. The job of
graphics_first_use_carries_the_exact_serialized_recipe_identity builds
no pipeline now: that test releases its stand-in without waiting, and a
build-ahead worker finishing the orphan released its fake 0x4332 as a
COM object (the test binary aborted when the queue's normal workers
were all parked).

Assisted-by: Claude Code (Claude Opus 5.5)
@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: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 compile-gate handoff tests at 3db78f6f on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib helpers_parked_at_the_gate_are_replaced_too -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib an_unwanted_build_leaves_a_free_slot_to_a_waiting_wanted_one -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib parked_workers_start_no_helper_without_commit_and_none_past_the_bound -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_helper_starts_only_under_the_bound_and_with_commit_free -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_handoff_bound_is_never_below_the_workers -- --test-threads=1: 1 passed, 0 failed, 0 ignored.

What this adds
All five new tests pass: parked workers and helpers get replacements at the huge-compile gate, helpers respect the commit floor and the bound, a wanted build keeps a free slot, and the bound never drops below the worker count. The thread has no comments yet, so this is the first datapoint in it and the first from an RTX 5070 Ti on driver 32.0.16.2140. These are scheduler tests; I did not reproduce the 0-2 fps title freeze from the description.

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 - ran the commands above on this machine and wrote this report; no game data was used.

@bmjask

bmjask commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Current-main audit (2026-11-29): real starvation bug, but not mergeable with this handoff bound.

The queue-progress fix is cache-key safe and the tests exercise the reported all-workers-parked condition. The critical risk is memory amplification: a parked worker spawns a replacement; that replacement can translate another huge job, park, and spawn another, up to twice the normal worker count (potentially hundreds). The 3 GiB headroom check is only a snapshot and reserves nothing, so many helpers can pass it concurrently and then retain large DXIL/descriptors while waiting at the same gate. This can convert a queue stall into commit exhaustion—the failure the gate is meant to prevent.

Prefer a bounded continuation/waiting queue, or at minimum a much smaller reserved handoff budget with explicit per-helper commit reservations and a stress test proving peak commit stays bounded. The required Windows check is also currently red and needs a current-main rerun.

Cache impact: safe; scheduling only. Disposition: revise design, then re-review.

Review assisted by Codex; exact model name was not exposed in this session. No game/sweep was run.

@minimalhipster990

Copy link
Copy Markdown

A retail repro of this starvation on an RTX 4090, with thread stacks. During the stalls system commit had only 0.9–1.9 GB free, below the 3 GB this PR needs to start a helper. With this PR, 2 of 3 runs reached 600 s; the third stalled the same way and then the GPU hung.

Setup

The stall without this PR. It happened in 8 of 11 runs: 1 of 4 plain runs, and 7 of 7 runs with XCL_LOOK_STATS=2. Each time, presents, submits, draws and I/O stopped at 189–495 s and stayed at 0 until 600 s, with no device removal. The only warning is the 1 s pipeline wait below. In the run with dumps every 30 s, 181 of 185 threads had the same stack from 210 s to 570 s:

  • The title's submitting thread was waiting with no budget for a compute pipeline:

    q_execute_command_lists (real.rs:11697) > list_x::record_deferred (list_x.rs:4486)
      > bind::execute_indirect_snapshot (bind.rs:3559) > PipelineResolution::resolve_for_indirect (pso_async.rs:11529)
      > resolve_wait_pending (pso_async.rs:10992) > Wait::until_done (pso_async.rs:11051) > Condvar::wait
    
  • All 15 xcl-pso-N, all 15 xcl-pso-hN (the compile_threads bound) and xcl-pso-whole were in real::huge_compile_turn, 28 of them under finish_two_pass. No thread was in a driver or DXC compile, and the DXC pool and preload workers were idle.

  • In 6 of the 8 stalls the log shows "thread N has waited 1000 ms for a compute pipeline still being built" within a second of the last present. In all 8, "a pipeline worker waits for a huge compile slot – a helper serves its queue meanwhile (16 helpers so far)" comes earlier, at 160–230 s.

  • System commit during the stalls: 0.9–1.9 GB free. That is below the 3 GB headroom (1.5 GB for a late build), so no parked build could start. Nothing in the process asked for more commit, so the page file did not grow either.

As far as I can tell the build the title waited for was still in the queue: a wanted build skips the commit wait, and with no slot taken it would have started. This matches your description. On plain main resolve_for_indirect also waits with no budget unless XCL_PSO_WAIT_MS is set, so this is not from #3318.

With this PR (3 runs)

run world at end workers handed off lowest commit free peak process commit
1 317.9 s stalled at 315.9 s, then the GPU hung at 338.7 s 16 381 MB 44.2 GB
2 319.2 s 600 s, 2.8 presents/s after the world, 2,761 frames 40 298 MB 48.0 GB
3 208.3 s 600 s, a 1 s compute wait at 472.9 s that cleared, 2,841 frames 32 261 MB 48.4 GB
  • Run 1's dump at 330 s had the same picture: the title thread in resolve_for_indirect → until_done, and 14 xcl-pso-N, the one helper left, the 3 xcl-pso-pre-N and xcl-pso-whole in huge_compile_turn. With commit under 3 GB, no new helper could start.
  • Run 1 then ended at 338.7 s with 0x887a0006 (DEVICE_HUNG), DRED state 3, and two nvlddmkm event 153 entries in the System log at that time, with 619 MB of system commit left. I don't know whether the hang comes from this PR. None of my runs without it ended in 0x887a0006: they ran on, stalled, or (with the 512 MB heap) were removed with 0x887a0005.
  • The four plain runs without this PR had a lowest commit free of 260–492 MB and a peak process commit of 45.7–47.4 GB. With this PR the peak was 48.0–48.4 GB in the two runs that reached 600 s. Three runs are too few to call that the helpers' cost (@bmjask's concern), but it is the direction to watch.

Not tested: more runs (the stall comes and goes, so 3 runs say little either way), XCL_HUGE_PSO_HANDOFFS other than the default, this PR on main alone, and a larger page file.

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the tests and replays, named the stacks and wrote this report. The person running these tests asked for it.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: 3db78f6
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2895 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: read the whole diff (pso_async.rs +224/-22, real.rs +63/-6, README). By default at most 2x the normal workers run as helpers (main: as many as the workers), only while 3 GB of commit is free, and an unwanted build no longer takes a compile slot while a wanted one waits. Findings: (1) may_add_helper (~4100) now needs 3 GB free to start a helper, where main started one regardless. With less than 3 GB free and every normal worker parked on an unwanted huge build (each also waiting for 3 GB), nothing serves the queue, including a pipeline a bind waits for with no budget, which a helper would build on main. (2) The default limit 2x(cores-1) follows the CPU, not the RAM: on a 32-thread CPU it's 62, about the 64 that ran the author's machine out of RAM, and the default wasn't run in game. (3) It raises the limit rather than removing it: once more huge builds are queued than workers plus handoff_most, every thread parks again. (4) Main's c110ed8 (huge-compile slots scale with free commit) landed after this PR's base, so the "1 / 2" defaults and in-game runs in the description predate it. (5) The wanted-first slot rule (real.rs ~5610) is a separate change. The PR's CI run failed 4 pipeline_library / warm_library tests outside this diff (3 entries instead of 2, then a poisoned lock); #3307 carries this same commit and passed, so it looks intermittent; they all pass in the run above. Fine: no wakeup can be lost (50 ms re-check plus notify_all when a slot frees), the wanted_waiting count is balanced on every exit, helpers retire as before, and the new test fails with main's one-helper-per-worker limit.
performance: 60 s smoke of a retail title, main d0832e6 vs this merge (60b1c015): 1516 -> 1666 frames shown (109 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 17766 MB, 0 device removals, 0 crashes.
verdict: not yet: with less than 3 GB of free commit no helper starts, so a queue whose normal workers are all parked on unwanted huge builds stops serving even a pipeline a bind waits for (finding 1), and the default limit follows the CPU rather than the RAM
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.

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

Review of 3db78f6f: 3 finding(s). 3 are inline.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

pub(super) struct ParkedWorker(bool);
/// Whether one more helper may start: fewer than the parked workers and than `most`, and
/// commit free (asked last).
fn may_add_helper(helpers: usize, parked: usize, most: usize, commit_free: impl Fn() -> bool) -> bool {

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.

Helpers now start only with 3 GB of commit free (may_add_helper && commit_free()), which removes the old guarantee that every parked normal worker gets a replacement. With less than 3 GB of commit left (e.g. 16 GB RAM, small pagefile), every normal worker takes a huge/medium build and parks in big_compile_turn, unwanted builds also wait on commit_free, and top_up refuses a helper on every look. Nothing serves the Foreground/BoundSoon queue, so small pipelines that need no gate or headroom stand still until commit frees up. That's the freeze this PR describes. The PR also notes the commit check didn't prevent the RAM exhaustion it saw, so this check protects little and disables the fix exactly where commit is tight.


/// Commit a helper is started with at least: the floor a huge compile waits for at the gate
/// (`real::big_compile_headroom`).
const HELPER_COMMIT_HEADROOM: u64 = 3 << 30;

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.

HELPER_COMMIT_HEADROOM is documented as the floor a huge compile waits for, but huge_compile_turn uses headroom_for(bytes, late), which halves it to 1.5 GB for late builds. With 1.5-3 GB of commit left, late builds pass the gate and wanted builds bypass commit, yet top_up refuses every helper. Workers parked on slot contention get no replacement, so the queue stalls while the gate itself would let builds proceed. Both should come from the same headroom_for source.

let ahead = !is_wanted && ahead();
let open = slots.ahead || !ahead;
if open && *n < cap && (is_wanted || commit_free()) && !(ahead && slots.urgent.load(Ordering::Acquire) > 0) {
let behind = !is_wanted && slots.wanted_waiting.load(Ordering::Acquire) > 0;

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.

behind is computed before the build removes its own count from wanted_waiting, so a build that was wanted and just became unwanted (the title gave up after XCL_GFX_PSO_WAIT_MS) is blocked by its own stale count. It refuses a free slot, decrements afterwards and sleeps a full LOOK (50 ms), and another build may take the slot. No notify is sent when wanted_waiting drops either, so unwanted builds blocked only by behind sit until their timeout.

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

5 participants