D3D12.X: cap a small compute dispatch's loop entries at 4096 passes #3667

Open
Prime1997 wants to merge 1 commit from upstream-pr/3667 into main
Prime1997 commented 2026-12-02 05:54:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-12-02T05:54:15Z.


Requested by Prime

A compute dispatch of only a few groups got the largest loop budget there is: recomp::dispatch_loop_budget shares 2^28 passes among a dispatch's threads, so one group of 64 threads got 65 536 passes a loop entry. That share model fits a dispatch that fills the GPU. A small dispatch runs its groups side by side, so a loop that never ends costs the full 65 536 passes of latency whatever the thread count. On an RTX 3060 Ti, in a game title, a split wave64 compute program took 50.4 ms for one 1x1x1 group, twice a frame, every frame. This change caps each lane's loop entry at 4096 passes (four times DISPATCH_LOOP_PASSES_MIN) for compute dispatches with known group counts. Large dispatches already get less than that and are unchanged. No translated code changes, so the shader cache stays valid.

Related: #3652 (open) lowers the split-wave64 exchange and barrier waits of the direct DXIL translator from 2^20 polls (an exit bit for a departed half, then 2^12 and 2^16 polls). That is the other bounded wait that can hold a small dispatch this long. The two do not touch the same code.

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs: loop_passes_max() reads XCL_LOOP_PASSES_MAX. capped_loop_budget() computes the IO_LOOP_BUDGET value, min(share, max x threads per group), with a saturating product so extreme values fall back to the share. loop_budget_for() applies it to a compute pipeline and logs the first 64 programs whose loops get fewer passes. The direct bind path writes it for compute dispatches with known group counts. Unit test small_dispatches_get_at_most_the_max_loop_passes.
  • crates/xcl/src/hle/d3d12x/console_list.rs: translated console command lists take the same capped budget.

Tested

  • RTX 3060 Ti 8 GB, Windows 11, release build: the change has been in our test builds since 1 Dec. Not yet shown: whether that program's 50 ms drops to ~3 ms, or whether its time is a bounded wait or real work.
  • This branch (on main 1c8b5514): cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu passes. The test suite was not run on this exact branch.

Regression run

  • Not run yet: testers welcome.

Not tested

  • The suite and scripts/smoke.ps1 on this branch; AMD.
  • A program whose loop really needs more than 4096 passes an entry in a small dispatch. XCL_LOOP_PASSES_MAX=0 restores the old budget if one shows up.

Switches

  • XCL_LOOP_PASSES_MAX=<n>: default 4096, the most passes one loop entry of a lane gets in a compute dispatch with known group counts. =0 keeps the dispatch's share alone, as before (up to 65 536). Indirect dispatches are not affected.

AI use

  • Claude Code wrote the change and this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5600747675 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-12-02T05:54:15Z. --- <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime**_ A compute dispatch of only a few groups got the largest loop budget there is: `recomp::dispatch_loop_budget` shares 2^28 passes among a dispatch's threads, so one group of 64 threads got 65 536 passes a loop entry. That share model fits a dispatch that fills the GPU. A small dispatch runs its groups side by side, so a loop that never ends costs the full 65 536 passes of latency whatever the thread count. On an RTX 3060 Ti, in a game title, a split wave64 compute program took 50.4 ms for one 1x1x1 group, twice a frame, every frame. This change caps each lane's loop entry at 4096 passes (four times `DISPATCH_LOOP_PASSES_MIN`) for compute dispatches with known group counts. Large dispatches already get less than that and are unchanged. No translated code changes, so the shader cache stays valid. Related: #3652 (open) lowers the split-wave64 exchange and barrier waits of the direct DXIL translator from 2^20 polls (an exit bit for a departed half, then 2^12 and 2^16 polls). That is the other bounded wait that can hold a small dispatch this long. The two do not touch the same code. **What is in it** - `crates/xcl/src/hle/d3d12x/bind.rs`: `loop_passes_max()` reads `XCL_LOOP_PASSES_MAX`. `capped_loop_budget()` computes the `IO_LOOP_BUDGET` value, min(share, max x threads per group), with a saturating product so extreme values fall back to the share. `loop_budget_for()` applies it to a compute pipeline and logs the first 64 programs whose loops get fewer passes. The direct bind path writes it for compute dispatches with known group counts. Unit test `small_dispatches_get_at_most_the_max_loop_passes`. - `crates/xcl/src/hle/d3d12x/console_list.rs`: translated console command lists take the same capped budget. **Tested** - RTX 3060 Ti 8 GB, Windows 11, release build: the change has been in our test builds since 1 Dec. Not yet shown: whether that program's 50 ms drops to ~3 ms, or whether its time is a bounded wait or real work. - This branch (on main 1c8b5514): `cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu` passes. The test suite was not run on this exact branch. **Regression run** - Not run yet: testers welcome. **Not tested** - The suite and `scripts/smoke.ps1` on this branch; AMD. - A program whose loop really needs more than 4096 passes an entry in a small dispatch. `XCL_LOOP_PASSES_MAX=0` restores the old budget if one shows up. **Switches** - `XCL_LOOP_PASSES_MAX=<n>`: default 4096, the most passes one loop entry of a lane gets in a compute dispatch with known group counts. `=0` keeps the dispatch's share alone, as before (up to 65 536). Indirect dispatches are not affected. **AI use** - Claude Code wrote the change and this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-02 09:13:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:13:14Z.


Review (head a9670ad4, diff read, not a merge-check; checks red):

  • A default cap that can end working loops in many dispatches, not only ones of a few groups. capped_loop_budget (hle/d3d12x/bind.rs ~5128) lowers the per-entry passes whenever 2^28 / (groups x threads) > 4096. That is every compute dispatch under 65 536 threads, and those dispatches drop from up to 65 536 passes to 4 096. Small dispatches are where one lane does serial work: single-group reductions and scans, or a 1x1x1 loop over a list. For example, 64 threads striding a 512K-element buffer need 8 192 passes per entry. When the cap is hit, the direct DXIL path ends the lane's program (gpu/dxil/kernel.rs ~520-523) and HLSL breaks out of the loop, so the output is silently wrong. The description itself says it was not shown that the 50 ms is a runaway loop rather than real work. Making this the default needs that evidence first, or the cap should be opt-in.
  • It may not reach the program it is meant for. The per-entry count exists only when there is no compact plan (gpu/dxil/kernel.rs ~492, plan.is_none()). Split-wave64 compute programs with atomics, and large programs, get the compact form automatically (gpu/dxil/compact.rs ~261-263). There they keep the lane's 65 536 passes, and this change does nothing. If the 50 ms is the split halves' exchange/barrier spin (2^20 polls), it is the subject of #3652 / #3668, not this PR. The PR has no before/after number.
  • The tests do not cover the change. small_dispatches_get_at_most_the_max_loop_passes (bind.rs ~7191) checks only the arithmetic of the new helper. Neither call site that writes IO_LOOP_BUDGET (bind.rs ~5380, console_list.rs ~1059) is tested. No GPU test shows a small dispatch's loop ending at 4 096 passes, or a long legitimate loop surviving.
  • The log and the hot path. loop_budget_for (bind.rs ~5143-5160) runs for every compute dispatch with known group counts. For every dispatch under 65 536 threads it locks PSO_SHADERS and SEEN, and keeps doing so after 64 programs have been named. Programs without a loop also use up the 64 names, although they never read IO_LOOP_BUDGET. As a result, the log does not identify the programs whose loops were actually cut.
  • Combined with #3669. #3669 makes the direct DXIL lane total four times the per-entry cap derived from IO_LOOP_BUDGET. With both PRs merged, a small dispatch's lane goes from 65 536 passes in all to 16 384, and that includes the compact form. Neither description mentions this.
  • README and PR checks. README.md ~395-401 still says 1024 to 65 536 passes per thread, and the new default-on XCL_LOOP_PASSES_MAX is not documented there. PR checks is red because this runtime change has no xcl-smoke blocks (main and head) under Regression run. Tested has only a cargo check with the gnu target and no suite counts, and AI use does not name the model.

Fine: indirect dispatches (no group counts) and XCL_LOOP_PASSES_MAX=0 keep main's share. The thread count used is the console's numthreads (pso_threads_exact), which is what both translators divide by. The saturating products handle extreme values. No translated code changes.

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

<!-- greyfinch-sync:ivall/xcl:comment:7340558366 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7340558366). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:13:14Z. --- Review (head a9670ad4, diff read, not a merge-check; checks red): - **A default cap that can end working loops in many dispatches, not only ones of a few groups.** `capped_loop_budget` (`hle/d3d12x/bind.rs` ~5128) lowers the per-entry passes whenever 2^28 / (groups x threads) > 4096. That is every compute dispatch under 65 536 threads, and those dispatches drop from up to 65 536 passes to 4 096. Small dispatches are where one lane does serial work: single-group reductions and scans, or a 1x1x1 loop over a list. For example, 64 threads striding a 512K-element buffer need 8 192 passes per entry. When the cap is hit, the direct DXIL path ends the lane's program (`gpu/dxil/kernel.rs` ~520-523) and HLSL breaks out of the loop, so the output is silently wrong. The description itself says it was not shown that the 50 ms is a runaway loop rather than real work. Making this the default needs that evidence first, or the cap should be opt-in. - **It may not reach the program it is meant for.** The per-entry count exists only when there is no compact plan (`gpu/dxil/kernel.rs` ~492, `plan.is_none()`). Split-wave64 compute programs with atomics, and large programs, get the compact form automatically (`gpu/dxil/compact.rs` ~261-263). There they keep the lane's 65 536 passes, and this change does nothing. If the 50 ms is the split halves' exchange/barrier spin (2^20 polls), it is the subject of #3652 / #3668, not this PR. The PR has no before/after number. - **The tests do not cover the change.** `small_dispatches_get_at_most_the_max_loop_passes` (bind.rs ~7191) checks only the arithmetic of the new helper. Neither call site that writes `IO_LOOP_BUDGET` (bind.rs ~5380, `console_list.rs` ~1059) is tested. No GPU test shows a small dispatch's loop ending at 4 096 passes, or a long legitimate loop surviving. - **The log and the hot path.** `loop_budget_for` (bind.rs ~5143-5160) runs for every compute dispatch with known group counts. For every dispatch under 65 536 threads it locks `PSO_SHADERS` and `SEEN`, and keeps doing so after 64 programs have been named. Programs without a loop also use up the 64 names, although they never read `IO_LOOP_BUDGET`. As a result, the log does not identify the programs whose loops were actually cut. - **Combined with #3669.** #3669 makes the direct DXIL lane total four times the per-entry cap derived from `IO_LOOP_BUDGET`. With both PRs merged, a small dispatch's lane goes from 65 536 passes in all to 16 384, and that includes the compact form. Neither description mentions this. - **README and PR checks.** `README.md` ~395-401 still says 1024 to 65 536 passes per thread, and the new default-on `XCL_LOOP_PASSES_MAX` is not documented there. `PR checks` is red because this runtime change has no `xcl-smoke` blocks (main and head) under **Regression run**. **Tested** has only a `cargo check` with the gnu target and no suite counts, and **AI use** does not name the model. Fine: indirect dispatches (no group counts) and `XCL_LOOP_PASSES_MAX=0` keep main's share. The thread count used is the console's `numthreads` (`pso_threads_exact`), which is what both translators divide by. The saturating products handle extreme values. No translated code changes. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-02 09:37:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:37:06Z.


Test report (not a merge-check: PR description red)
base: 1c8b551475
head: a9670ad427
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 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 by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7340558366 and its findings stand. Most serious: a default 4096-pass cap on every dispatch under 65,536 threads can silently cut legitimate loops.
performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (a9670ad4): 1652 -> 1687 frames shown (102 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 17407 MB, 0 device removals, 0 crashes.
assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: a default 4096-pass cap on every dispatch under 65,536 threads can silently cut legitimate loops
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.

<!-- greyfinch-sync:ivall/xcl:comment:7341211988 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7341211988). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:37:06Z. --- Test report (not a merge-check: `PR description` red) base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: a9670ad4274310134037f92571023c40f12cae49 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 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 by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7340558366 and its findings stand. Most serious: a default 4096-pass cap on every dispatch under 65,536 threads can silently cut legitimate loops. performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (a9670ad4): 1652 -> 1687 frames shown (102 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 17407 MB, 0 device removals, 0 crashes. assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: a default 4096-pass cap on every dispatch under 65,536 threads can silently cut legitimate loops 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.
tiagonleal commented 2026-12-02 15:22:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T15:22:05Z.


On the open question in the description (a bounded wait or real work): on our RTX 5070 Ti the 1x1x1 split program is CS_DefragHeap_ProcessFreeRequests, and it is neither. Its outer loop count is s_ff1_i32_b32 of a constant-buffer dword, so a 0 there gives 0xFFFFFFFF passes, and the loop runs until XCL's pass budget ends it (45 ms per dispatch here).

The 0 comes from the title's GPU heaps being outside the coherent window: with the Series S window at 512 MB, its three heaps (1162 + 1277 + 258 MB) do not fit, become plain memory, and translated shaders read zeros from them (throny's follow-up on #3568). With XCL_COHERENT_MB=3408 the heaps fit and the program drops out of the XCL_GPU_TIMES top 60 (under 2.45 ms per frame). Numbers are in my comment on #3568.

So the cap here shortens that case, and the program needs only a few passes once its data is reachable. With real data its block walk is a data-dependent loop, so it may be worth checking that 4096 passes still cover it.
AI use: Claude Code (Claude Opus 5.5, with a Claude Fable 5.2 analysis of the shader and logs).

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7350203346 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7350203346). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-12-02T15:22:05Z. --- On the open question in the description (a bounded wait or real work): on our RTX 5070 Ti the 1x1x1 split program is `CS_DefragHeap_ProcessFreeRequests`, and it is neither. Its outer loop count is `s_ff1_i32_b32` of a constant-buffer dword, so a 0 there gives 0xFFFFFFFF passes, and the loop runs until XCL's pass budget ends it (45 ms per dispatch here). The 0 comes from the title's GPU heaps being outside the coherent window: with the Series S window at 512 MB, its three heaps (1162 + 1277 + 258 MB) do not fit, become plain memory, and translated shaders read zeros from them (throny's follow-up on #3568). With `XCL_COHERENT_MB=3408` the heaps fit and the program drops out of the `XCL_GPU_TIMES` top 60 (under 2.45 ms per frame). Numbers are in my comment on #3568. So the cap here shortens that case, and the program needs only a few passes once its data is reachable. With real data its block walk is a data-dependent loop, so it may be worth checking that 4096 passes still cover it. AI use: Claude Code (Claude Opus 5.5, with a Claude Fable 5.2 analysis of the shader and logs). - Tiago
bmjask commented 2026-12-02 20:36:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T20:36:24Z.

Code review location: crates/xcl/src/hle/d3d12x/bind.rs; line 5093

@@ -5088,6 +5088,82 @@ pub(super) fn dispatch_loop_budget_wanted() -> bool {
     *ON.get_or_init(|| std::env::var("XCL_DISPATCH_LOOP_BUDGET").map_or(true, |v| v.trim() != "0"))
 }
 
+/// Default of `XCL_LOOP_PASSES_MAX`: four times `recomp::DISPATCH_LOOP_PASSES_MIN`, the passes a
+/// loop entry of the largest dispatches already gets.
+const LOOP_PASSES_MAX_DEFAULT: u32 = 4096;

High: The new default of 4096 silently cuts short real loops in every small direct compute dispatch, which used to get up to 65 536 passes per loop entry, while the same program keeps 65 536 when dispatched indirectly. A 1x1x1 dispatch of a [64,1,1] or [1,1,1] program with a legitimate serial loop (a single-group scan or compaction over more than 4096 items, a long list walk, a spin on a flag another group sets) now leaves the loop after 4096 passes and runs to the end with partial results: wrong or corrupt output with only one info line per program. The PR says the 50 ms may instead come from the exchange waits #3652 bounds, so the cap may not even fix the motivating case. Keeping the default at the old budget and limiting the cap to the split-wave64 form (or to the identified program) would avoid changing correct programs.

<!-- greyfinch-sync:ivall/xcl:review-comment:4775671119 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#discussion_r4775671119). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T20:36:24Z. **Code review location:** `crates/xcl/src/hle/d3d12x/bind.rs`; line 5093 ~~~~diff @@ -5088,6 +5088,82 @@ pub(super) fn dispatch_loop_budget_wanted() -> bool { *ON.get_or_init(|| std::env::var("XCL_DISPATCH_LOOP_BUDGET").map_or(true, |v| v.trim() != "0")) } +/// Default of `XCL_LOOP_PASSES_MAX`: four times `recomp::DISPATCH_LOOP_PASSES_MIN`, the passes a +/// loop entry of the largest dispatches already gets. +const LOOP_PASSES_MAX_DEFAULT: u32 = 4096; ~~~~ --- **High**: The new default of 4096 silently cuts short real loops in every small direct compute dispatch, which used to get up to 65 536 passes per loop entry, while the same program keeps 65 536 when dispatched indirectly. A 1x1x1 dispatch of a [64,1,1] or [1,1,1] program with a legitimate serial loop (a single-group scan or compaction over more than 4096 items, a long list walk, a spin on a flag another group sets) now leaves the loop after 4096 passes and runs to the end with partial results: wrong or corrupt output with only one info line per program. The PR says the 50 ms may instead come from the exchange waits #3652 bounds, so the cap may not even fix the motivating case. Keeping the default at the old budget and limiting the cap to the split-wave64 form (or to the identified program) would avoid changing correct programs.
bmjask commented 2026-12-02 20:36:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T20:36:24Z.

Review: COMMENTED


Review of a9670ad4: 1 finding(s) (1 high), most severe first.

  1. High crates/xcl/src/hle/d3d12x/bind.rs:5093: The new default of 4096 silently cuts short real loops in every small direct compute dispatch, which used to get up to 65 536 passes per loop entry, while the same program keeps 65 536 when dispatched indirectly. (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.

<!-- greyfinch-sync:ivall/xcl:review:6158525074 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#pullrequestreview-6158525074). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T20:36:24Z. **Review:** COMMENTED --- Review of `a9670ad4`: 1 finding(s) (1 high), most severe first. 1. **High** `crates/xcl/src/hle/d3d12x/bind.rs:5093`: The new default of 4096 silently cuts short real loops in every small direct compute dispatch, which used to get up to 65 536 passes per loop entry, while the same program keeps 65 536 when dispatched indirectly. (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._
lucsoft commented 2026-12-03 14:11:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T14:11:28Z.


merge-check
base: a815de932c
head: a9670ad427
merge: clean
build: ok (cargo build --release -p xcl, cargo test --workspace --release --no-run)
tests: lib 2836 passed, 17 failed, 36 ignored, 2 died (base: 2835 passed, 17 failed, 18 ignored, 2 died; +1 is the new small_dispatches_get_at_most_the_max_loop_passes); integration 151 passed, 5 failed, 20 ignored (base the same); the same 19 lib and 5 integration failures on base and merge, none new; run under Wine with 2 threads, one module per process
review: whole diff read (bind.rs, console_list.rs); agrees with Foniass's review above. (1) A loop entry of a small compute dispatch now gets at most 4096 passes instead of up to 65 536; a loop that legitimately needs more (one group walking a long list) is now cut and gives a wrong result, not a stall. Large dispatches already got less (~1165), so long legit loops look rare, and the log names the first 64 programs whose loops are cut (this run: 64 named, so the list was full). (2) loop_budget_for takes a global Mutex on every dispatch whose budget is cut, also after the 64 names are logged; minor, not measurable here. (3) The unit test covers the arithmetic only, not the dispatch path. No visual comparison was done.
performance: no change measurable at this resolution: in the world 0.63 presents/s (merge) vs 0.72 (base), within the run-to-run spread of this scene; no translated code changes (shader caches stay warm)
title run: retail title, RX 7800 XT (RADV, Wine), main a815de93 + this PR: 386 s in the world, no crash, no device removal, 0 page faults, 0.63 presents/s (base a815de93: 412 s, no crash, no device removal, 0.72 presents/s)
note: the same three caps (#3667, #3668, #3669) were in all of our runs on a zip-based tree all day (Prime1997's portable build); after almost every run a wave stayed busy on the GPU after the title exited (100 % busy, no process; cleared by a reset), with them on. This PR does not fix that, and nothing here says it causes it.
verdict: not yet: confirms Foniass's two high findings (the 4096 default cap can cut loops that legitimately need more passes, with a wrong result instead of a stall; no test of the dispatch paths that write IO_LOOP_BUDGET, bind.rs ~5380 and console_list.rs ~1059); on the AMD side the merge is otherwise clean: suites with no new failures and a 386 s title run with no crash or device removal
hardware / tool and model: RX 7800 XT (RADV, Mesa 26.3.1, vkd3d-proton 3.1, Wine 11.21 Staging, Linux 7.3) / Claude Code (Claude Opus 5.5)

xcl-smoke blocks for the description (CONTRIBUTING: head + main, same title and time):

main a815de93:

xcl-smoke v1
commit: a815de932c4dc8da3b383ca44f4b094aa406fec9
gpu: AMD Radeon RX 7800 XT (RADV NAVI32)
title: f651e787
seconds: 600
exit: 0x0
frames shown: 2614 (PresentX 2614)
presents per 2 s (last 3): 2 2 1
device removals: 0
crashes: 0
peak commit: 0 MB

PR head a9670ad4 (bare head, on its old base main 1c8b5514):

xcl-smoke v1
commit: a9670ad4274310134037f92571023c40f12cae49
gpu: AMD Radeon RX 7800 XT (RADV NAVI32)
title: f651e787
seconds: 600
exit: 0x5
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 1 1 1
device removals: 1
crashes: 1
peak commit: 0 MB

The device removal is ~12 s into the world (138 s after start): a TCP page fault, then a gfx ring timeout. The head's base 1c8b5514 predates #3553, which fixed TCP faults at world entry here; the trial merge into a815de93 (with #3553) ran 600 s clean. A rebase onto current main would give a head block on a good base (and reset claims/checks on a9670ad4).

<!-- greyfinch-sync:ivall/xcl:comment:7381037334 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7381037334). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-03T14:11:28Z. --- merge-check base: a815de932c4dc8da3b383ca44f4b094aa406fec9 head: a9670ad4274310134037f92571023c40f12cae49 merge: clean build: ok (cargo build --release -p xcl, cargo test --workspace --release --no-run) tests: lib 2836 passed, 17 failed, 36 ignored, 2 died (base: 2835 passed, 17 failed, 18 ignored, 2 died; +1 is the new small_dispatches_get_at_most_the_max_loop_passes); integration 151 passed, 5 failed, 20 ignored (base the same); the same 19 lib and 5 integration failures on base and merge, none new; run under Wine with 2 threads, one module per process review: whole diff read (bind.rs, console_list.rs); agrees with Foniass's review above. (1) A loop entry of a small compute dispatch now gets at most 4096 passes instead of up to 65 536; a loop that legitimately needs more (one group walking a long list) is now cut and gives a wrong result, not a stall. Large dispatches already got less (~1165), so long legit loops look rare, and the log names the first 64 programs whose loops are cut (this run: 64 named, so the list was full). (2) loop_budget_for takes a global Mutex on every dispatch whose budget is cut, also after the 64 names are logged; minor, not measurable here. (3) The unit test covers the arithmetic only, not the dispatch path. No visual comparison was done. performance: no change measurable at this resolution: in the world 0.63 presents/s (merge) vs 0.72 (base), within the run-to-run spread of this scene; no translated code changes (shader caches stay warm) title run: retail title, RX 7800 XT (RADV, Wine), main a815de93 + this PR: 386 s in the world, no crash, no device removal, 0 page faults, 0.63 presents/s (base a815de93: 412 s, no crash, no device removal, 0.72 presents/s) note: the same three caps (#3667, #3668, #3669) were in all of our runs on a zip-based tree all day (Prime1997's portable build); after almost every run a wave stayed busy on the GPU after the title exited (100 % busy, no process; cleared by a reset), with them on. This PR does not fix that, and nothing here says it causes it. verdict: not yet: confirms Foniass's two high findings (the 4096 default cap can cut loops that legitimately need more passes, with a wrong result instead of a stall; no test of the dispatch paths that write IO_LOOP_BUDGET, bind.rs ~5380 and console_list.rs ~1059); on the AMD side the merge is otherwise clean: suites with no new failures and a 386 s title run with no crash or device removal hardware / tool and model: RX 7800 XT (RADV, Mesa 26.3.1, vkd3d-proton 3.1, Wine 11.21 Staging, Linux 7.3) / Claude Code (Claude Opus 5.5) xcl-smoke blocks for the description (CONTRIBUTING: head + main, same title and time): main a815de93: ``` xcl-smoke v1 commit: a815de932c4dc8da3b383ca44f4b094aa406fec9 gpu: AMD Radeon RX 7800 XT (RADV NAVI32) title: f651e787 seconds: 600 exit: 0x0 frames shown: 2614 (PresentX 2614) presents per 2 s (last 3): 2 2 1 device removals: 0 crashes: 0 peak commit: 0 MB ``` PR head a9670ad4 (bare head, on its old base main 1c8b5514): ``` xcl-smoke v1 commit: a9670ad4274310134037f92571023c40f12cae49 gpu: AMD Radeon RX 7800 XT (RADV NAVI32) title: f651e787 seconds: 600 exit: 0x5 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 1 1 1 device removals: 1 crashes: 1 peak commit: 0 MB ``` The device removal is ~12 s into the world (138 s after start): a TCP page fault, then a gfx ring timeout. The head's base 1c8b5514 predates #3553, which fixed TCP faults at world entry here; the trial merge into a815de93 (with #3553) ran 600 s clean. A rebase onto current main would give a head block on a good base (and reset claims/checks on a9670ad4).
Foniass commented 2026-12-03 14:18:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T14:18:52Z.


merge-check
base: 16c2fd082a
head: a9670ad427
merge: clean
build: ok
tests: 3013 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 2 high, 5 medium (below)
performance: 60 s smoke run: 1683 → 1655 frames (98 % of main), peak commit 18505 → 19048 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 242 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: 2 blocking findings (critical or high, below); also PR description is red
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: By default this caps each loop entry of a compute dispatch with known group counts at 4096 passes; small dispatches used to get up to 65 536. The head has not changed since my earlier review, so all of its findings are still open. A later comment on the PR shows the 50 ms program was a loop with a count of 0xFFFFFFFF, because it read zeros from heaps outside the coherent window (#3568). What blocks it: the default cap can silently cut real loops.

High

  1. Default cap of 4096 can silently cut real loops. Still open from my earlier review. capped_loop_budget (hle/d3d12x/bind.rs ~5128) lowers every compute dispatch under 65 536 threads from up to 65 536 passes an entry to 4096. When the passes run out, the direct DXIL path ends the lane's program (gpu/dxil/kernel.rs ~516-523) and HLSL breaks out of the loop, so the output is silently wrong. For example, 64 threads striding a 512K-element buffer need 8192 passes. The same program dispatched indirectly keeps 65 536. Make the cap opt-in, or show that it cuts no loop that would have finished.
  2. The change has no test of what it does. Still open. small_dispatches_get_at_most_the_max_loop_passes (bind.rs ~7191) checks only the helper's arithmetic. Neither call site that writes IO_LOOP_BUDGET (bind.rs ~5380, console_list.rs ~1059) is tested. No GPU test shows a small dispatch's loop ending at 4096 passes, or a long legitimate loop surviving.

Medium

  1. The cited case is a data problem, not the loop budget. A later comment on the PR names the program: CS_DefragHeap_ProcessFreeRequests. Its loop count is s_ff1 of a constant-buffer dword that reads 0 because the title's heaps do not fit the 512 MB coherent window. With XCL_COHERENT_MB=3408 it drops under 2.45 ms per frame. So the cause belongs to #3568. With real data the program's block walk is a data-dependent loop that could need more than 4096 passes. The description should say this and justify keeping the cap on by default.
  2. May not reach the program it is meant for. Still open. The per-entry count exists only when there is no compact plan (gpu/dxil/kernel.rs ~492, plan.is_none()). Split-wave64 compute programs with atomics, and large programs, get the compact form automatically (gpu/dxil/compact.rs ~261) and keep the lane's 65 536 passes. The PR has no before/after number.
  3. Interaction with #3669 not described. Still open, and #3669 is still open. With both merged, a small dispatch's lane goes from 65 536 passes in all to 16 384, compact form included. Neither description mentions it.
  4. Log and per-dispatch cost. Still open. loop_budget_for (bind.rs ~5143-5160) locks PSO_SHADERS and SEEN on every dispatch under 65 536 threads, and keeps doing so after 64 programs are named. Programs without a loop also use up the 64 names, so the log does not identify the programs whose loops were actually cut.
  5. README and description gaps. Still open. README ~395-401 still says 1024 to 65 536 passes per thread, and the default-on XCL_LOOP_PASSES_MAX is not documented there. Tested has only cargo check for the gnu target, with no suite counts and no xcl-smoke blocks. AI use does not name the model.
Checked and fine
  • Indirect dispatches and XCL_LOOP_PASSES_MAX=0 keep main's share
  • The thread count is the console's numthreads (pso_threads_exact), which both translators divide by, and the saturating products handle extreme values
  • No translated code changes, so the shader cache stays valid
How this was tested
  • Merged onto main 16c2fd08, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 16c2fd08 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7381238997 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7381238997). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T14:18:52Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: a9670ad4274310134037f92571023c40f12cae49 merge: clean build: ok tests: 3013 passed, 0 failed, 56 ignored; 28 skipped, the same as on main review: 2 high, 5 medium (below) performance: 60 s smoke run: 1683 → 1655 frames (98 % of main), peak commit 18505 → 19048 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 242 s there, 0 device removals, 0 crashes, 2.8 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: 2 blocking findings (critical or high, below); also `PR description` is red hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** By default this caps each loop entry of a compute dispatch with known group counts at 4096 passes; small dispatches used to get up to 65 536. The head has not changed since my earlier review, so all of its findings are still open. A later comment on the PR shows the 50 ms program was a loop with a count of 0xFFFFFFFF, because it read zeros from heaps outside the coherent window (#3568). What blocks it: the default cap can silently cut real loops. #### High 1. **Default cap of 4096 can silently cut real loops.** Still open from my earlier review. capped_loop_budget (hle/d3d12x/bind.rs ~5128) lowers every compute dispatch under 65 536 threads from up to 65 536 passes an entry to 4096. When the passes run out, the direct DXIL path ends the lane's program (gpu/dxil/kernel.rs ~516-523) and HLSL breaks out of the loop, so the output is silently wrong. For example, 64 threads striding a 512K-element buffer need 8192 passes. The same program dispatched indirectly keeps 65 536. Make the cap opt-in, or show that it cuts no loop that would have finished. 2. **The change has no test of what it does.** Still open. small_dispatches_get_at_most_the_max_loop_passes (bind.rs ~7191) checks only the helper's arithmetic. Neither call site that writes IO_LOOP_BUDGET (bind.rs ~5380, console_list.rs ~1059) is tested. No GPU test shows a small dispatch's loop ending at 4096 passes, or a long legitimate loop surviving. #### Medium 3. **The cited case is a data problem, not the loop budget.** A later comment on the PR names the program: CS_DefragHeap_ProcessFreeRequests. Its loop count is s_ff1 of a constant-buffer dword that reads 0 because the title's heaps do not fit the 512 MB coherent window. With XCL_COHERENT_MB=3408 it drops under 2.45 ms per frame. So the cause belongs to #3568. With real data the program's block walk is a data-dependent loop that could need more than 4096 passes. The description should say this and justify keeping the cap on by default. 4. **May not reach the program it is meant for.** Still open. The per-entry count exists only when there is no compact plan (gpu/dxil/kernel.rs ~492, plan.is_none()). Split-wave64 compute programs with atomics, and large programs, get the compact form automatically (gpu/dxil/compact.rs ~261) and keep the lane's 65 536 passes. The PR has no before/after number. 5. **Interaction with #3669 not described.** Still open, and #3669 is still open. With both merged, a small dispatch's lane goes from 65 536 passes in all to 16 384, compact form included. Neither description mentions it. 6. **Log and per-dispatch cost.** Still open. loop_budget_for (bind.rs ~5143-5160) locks PSO_SHADERS and SEEN on every dispatch under 65 536 threads, and keeps doing so after 64 programs are named. Programs without a loop also use up the 64 names, so the log does not identify the programs whose loops were actually cut. 7. **README and description gaps.** Still open. README ~395-401 still says 1024 to 65 536 passes per thread, and the default-on XCL_LOOP_PASSES_MAX is not documented there. Tested has only cargo check for the gnu target, with no suite counts and no xcl-smoke blocks. AI use does not name the model. <details><summary>Checked and fine</summary> - Indirect dispatches and XCL_LOOP_PASSES_MAX=0 keep main's share - The thread count is the console's numthreads (pso_threads_exact), which both translators divide by, and the saturating products handle extreme values - No translated code changes, so the shader cache stays valid </details> <details><summary>How this was tested</summary> - Merged onto main `16c2fd08`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `16c2fd08` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Gevroska commented 2026-12-03 15:48:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-03T15:48:34Z.


I tested the 4,096-pass boundary on my RTX 3080 at a9670ad4. I used one group of 64 lanes running a finite loop and checked both the iteration count and the final value from each lane.

With the proposed default, a loop that needed 4,097 passes stopped at 4,096. All 64 lanes returned the wrong final value in all three trials. The parent (1c8b5514), the opt-out, and an explicit cap of 4,097 all completed the same loop correctly. The default also gave the correct values for loops that needed exactly 4,095 or 4,096 passes.

The fixture passed the budget calculated by each revision directly to the shader guard. This gives a concrete correctness case to weigh when choosing the default. Whether the original slow dispatch needs to complete that work is still a separate question.

AI disclosure: OpenAI Codex GPT-6.2 Sol ran the comparison. An independent Codex reviewer checked the readbacks. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7383768673 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3667#issuecomment-7383768673). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-12-03T15:48:34Z. --- I tested the 4,096-pass boundary on my RTX 3080 at `a9670ad4`. I used one group of 64 lanes running a finite loop and checked both the iteration count and the final value from each lane. With the proposed default, a loop that needed 4,097 passes stopped at 4,096. **All 64 lanes returned the wrong final value in all three trials.** The parent (`1c8b5514`), the opt-out, and an explicit cap of 4,097 all completed the same loop correctly. The default also gave the correct values for loops that needed exactly 4,095 or 4,096 passes. The fixture passed the budget calculated by each revision directly to the shader guard. This gives a concrete correctness case to weigh when choosing the default. Whether the original slow dispatch needs to complete that work is still a separate question. AI disclosure: OpenAI Codex GPT-6.2 Sol ran the comparison. An independent Codex reviewer checked the readbacks. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3667:upstream-pr/3667'
git switch 'upstream-pr/3667'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3667'
git switch 'upstream-pr/3667'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3667'
git switch 'upstream-pr/3667'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3667'
git switch 'main'
git merge --squash 'upstream-pr/3667'
git switch 'main'
git merge --ff-only 'upstream-pr/3667'
git switch 'main'
git merge 'upstream-pr/3667'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3667
No description provided.