Recompiler: fix the race for the last wanted DXC slot #1364

Open
github-bot wants to merge 1 commit from github-bot/gh-1364 into main AGit
Owner

@⁠Gevroska on GitHub · 2026-11-24 15:16 UTC · original
Gevroska:xcl-local/dxc-wanted-slot-race → main · +46 −2 · 1 files · 1 commits · open

What is in it

With five DXC compiles running, two workers could both see the sixth slot available and start a wanted compile. The reservation now uses an atomic compare-and-exchange so only one worker takes that slot. The six-slot rule applies to wanted compiles admitted under memory pressure. Workers can still enter when commit headroom is sufficient or after the one-minute timeout.

The out-of-memory regression reported in #534 remains open. Whether a lower concurrency limit helps that workload needs a separate comparison.

Tested

RTX 3080, driver 616.92, Ryzen 7 5700X, Windows 11 25H2, Rust MSVC 1.100.0. scripts/test.ps1 --nocapture: 752 passed, 0 failed, 41 ignored; four runtime skips (wave64 and debug layers). The contention regression failed before and passed after the fix.

An independent contributor ran the workspace suite on this head with an RTX 5070 Ti and an RDNA2 iGPU. Each run reported 752 passed, 0 failed and 41 ignored. Hardware and test details

Regression run

Matched offline release startup runs, separate cold DXIL caches, shared driver cache.

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3080
title: retail-title
seconds: 90
exit: 0x0
frames shown: 2448 (PresentX 2448)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14693 MB
xcl-smoke v1
commit: 0da4c3589012e886c47c7681314e9b2fbfdf93d6
gpu: NVIDIA GeForce RTX 3080
title: retail-title
seconds: 90
exit: 0x0
frames shown: 2474 (PresentX 2474)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14576 MB

Not tested

Retail contention, the one-minute timeout in isolation, and the effect on the reported out-of-memory failure or gameplay.

AI use

Codex GPT-6.2 Sol authored and tested the change. GPT-6.1 Terra medium checked overlap and reproduced the baseline failure. GPT-6.2 Sol high independently reviewed the patch and evidence.
I reviewed the change manually.

**@⁠Gevroska** on GitHub · 2026-11-24 15:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364) `Gevroska:xcl-local/dxc-wanted-slot-race` → `main` · +46 −2 · 1 files · 1 commits · open **What is in it** With five DXC compiles running, two workers could both see the sixth slot available and start a wanted compile. The reservation now uses an atomic compare-and-exchange so only one worker takes that slot. The six-slot rule applies to wanted compiles admitted under memory pressure. Workers can still enter when commit headroom is sufficient or after the one-minute timeout. The out-of-memory regression reported in #534 remains open. Whether a lower concurrency limit helps that workload needs a separate comparison. **Tested** RTX 3080, driver 616.92, Ryzen 7 5700X, Windows 11 25H2, Rust MSVC 1.100.0. scripts/test.ps1 --nocapture: 752 passed, 0 failed, 41 ignored; four runtime skips (wave64 and debug layers). The contention regression failed before and passed after the fix. An independent contributor ran the workspace suite on this head with an RTX 5070 Ti and an RDNA2 iGPU. Each run reported 752 passed, 0 failed and 41 ignored. [Hardware and test details](https://github.com/ivall/xcl/pull/1364#issuecomment-7135995104) **Regression run** Matched offline release startup runs, separate cold DXIL caches, shared driver cache. ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: NVIDIA GeForce RTX 3080 title: retail-title seconds: 90 exit: 0x0 frames shown: 2448 (PresentX 2448) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14693 MB ``` ``` xcl-smoke v1 commit: 0da4c3589012e886c47c7681314e9b2fbfdf93d6 gpu: NVIDIA GeForce RTX 3080 title: retail-title seconds: 90 exit: 0x0 frames shown: 2474 (PresentX 2474) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14576 MB ``` **Not tested** Retail contention, the one-minute timeout in isolation, and the effect on the reported out-of-memory failure or gameplay. **AI use** Codex GPT-6.2 Sol authored and tested the change. GPT-6.1 Terra medium checked overlap and reproduced the baseline failure. GPT-6.2 Sol high independently reviewed the patch and evidence. I reviewed the change manually.
Two wanted compiles could both see the last slot before either incremented the active count. Reserve against the observed count and retry with the updated count after a competing reservation. Leave ordinary admission and the commit and time exceptions as before.

A synchronized two-contender test admits both with the old check and increment, then admits one with the fix. Its freed slot is available to the next compile.

Assisted-by: Codex (GPT-6.2 Sol)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:02 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-24 15:20 UTC · original

Review: this correctly closes the count race — the old code could admit more than WANTED_AT_ONCE wanted compiles because the fast path (WORKING.load < WANTED_AT_ONCE && wanted()) and the plenty || 60 s branch each fetch_add independently, and the CAS(0,1) fallback could stack on top; the try_reserve_wanted_slot CAS loop makes six a real ceiling, and the barrier test pins exactly the double-check race. But it does not close the reported regression on its own axis: the wanted branch still admits up to six compiles of 0.1–0.7 GB when memory is not plenty — six by design is what the 30.9 GB reporter OOMed on (memory allocation of 5,636,096 bytes failed at ~92 s, and again warm at 43.65 GB private; his table is in #534 from 13:49Z). The cheap completion, using the value this loop already computes one line above: pass plenty into try_reserve_wanted_slot and cap the wanted branch at 2 when it is false — one parameter, one constant, testable with your existing barrier harness by flipping the wanted()/plenty pair. @⁠remembering7896 has been offering exactly this A/B in #534 and would have a headroom-gated constant to test against. Suggest title/description say "race" rather than "low commit", so nobody closes the OOM from the changelog.

**@⁠pickles976** on GitHub · 2026-11-24 15:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7135863219) Review: this correctly closes the **count race** — the old code could admit more than `WANTED_AT_ONCE` wanted compiles because the fast path (`WORKING.load < WANTED_AT_ONCE && wanted()`) and the `plenty || 60 s` branch each `fetch_add` independently, and the CAS(0,1) fallback could stack on top; the `try_reserve_wanted_slot` CAS loop makes six a real ceiling, and the barrier test pins exactly the double-check race. **But it does not close the reported regression on its own axis:** the wanted branch still admits up to six compiles of 0.1–0.7 GB when memory is *not* plenty — six by design is what the 30.9 GB reporter OOMed on (`memory allocation of 5,636,096 bytes failed` at ~92 s, and again warm at 43.65 GB private; his table is in #534 from 13:49Z). The cheap completion, using the value this loop already computes one line above: pass `plenty` into `try_reserve_wanted_slot` and cap the wanted branch at 2 when it is false — one parameter, one constant, testable with your existing barrier harness by flipping the `wanted()`/plenty pair. @⁠remembering7896 has been offering exactly this A/B in #534 and would have a headroom-gated constant to test against. Suggest title/description say "race" rather than "low commit", so nobody closes the OOM from the changelog.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 15:25 UTC · original · edited 2026-11-24 15:29 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 0da4c35 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: wanted_compiles_contend_for_the_last_slot_under_memory_pressure.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 15:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7135995104) · edited 2026-11-24 15:29 UTC Full-suite run, since this PR has no test report yet. Tested exact head `0da4c35` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `wanted_compiles_contend_for_the_last_slot_under_memory_pressure`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 16:28 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 16:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7137716335) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Author
Owner

@⁠Gevroska on GitHub · 2026-11-24 16:56 UTC · original

I updated the title and description to make the race fix explicit. The OOM in #534 remains open. A six-versus-two comparison under matched memory and cache conditions would help determine whether to change the admission policy separately.

**@⁠Gevroska** on GitHub · 2026-11-24 16:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7138453159) I updated the title and description to make the race fix explicit. The OOM in #534 remains open. A six-versus-two comparison under matched memory and cache conditions would help determine whether to change the admission policy separately.
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-25 11:25 UTC · original

Test report for head 0da4c35 as pushed (not merged onto current main) – NVIDIA, wave32.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (Ampere, 32-lane waves only), driver 32.0.16.2124; AMD Ryzen 5 7500F; 32 GB RAM; Windows NT 10.0.26300; Rust 1.100.0 (stable-x86_64-pc-windows-msvc); debug; DXC 1.9.2609.5
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests on this adapter: 2 (no wave64)
  • this PR's test wanted_compiles_contend_for_the_last_slot_under_memory_pressure ran and passed
  • no XCL_SAMPLE_* data set (game-data tests not run)

Not tested

  • retail contention / a smoke run on a title; AMD / native wave64; release build; the head merged onto current main

AI use

  • Claude (Claude Opus 5.5) wrote the script that ran the suite on my PC, read the log and wrote and posted this report with my approval; the run is mine.
**@⁠xpatfussy69x** on GitHub · 2026-11-25 11:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7161022945) Test report for head `0da4c35` as pushed (not merged onto current `main`) – NVIDIA, wave32. **Tested** - NVIDIA GeForce RTX 3060 12 GB (Ampere, 32-lane waves only), driver 32.0.16.2124; AMD Ryzen 5 7500F; 32 GB RAM; Windows NT 10.0.26300; Rust 1.100.0 (stable-x86_64-pc-windows-msvc); debug; DXC 1.9.2609.5 - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 752 passed, 0 failed, 41 ignored - SKIPPED GPU tests on this adapter: 2 (no wave64) - this PR's test `wanted_compiles_contend_for_the_last_slot_under_memory_pressure` ran and passed - no `XCL_SAMPLE_*` data set (game-data tests not run) **Not tested** - retail contention / a smoke run on a title; AMD / native wave64; release build; the head merged onto current `main` **AI use** - Claude (Claude Opus 5.5) wrote the script that ran the suite on my PC, read the log and wrote and posted this report with my approval; the run is mine.
Author
Owner

@⁠4usphs on GitHub · 2026-11-25 11:52 UTC · original

AMD run on the exact head 0da4c35 (0da4c35890), as pushed on its base 930e8b4 (not merged onto current main), on two AMD adapters with native 64-lane waves: RDNA4 and the console's generation, RDNA2.

Tested

  • Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug, clean checkout, XCL_TRANSLATED_CACHE=0; adapter picked with XCL_ADAPTER.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:
    • AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: 752 passed, 0 failed, 41 ignored
    • AMD Radeon(TM) Graphics, the 9800X3D's iGPU (RDNA2, gfx1036), driver 32.0.21045.29003: 752 passed, 0 failed, 41 ignored
  • No SKIPPED tests on either adapter.
  • This PR's test wanted_compiles_contend_for_the_last_slot_under_memory_pressure runs and passes on both adapters.

Not tested

  • smoke or a retail title (I have none), a release build, Linux.

AI use

  • Claude Code (Claude Opus 5.5) read the diff, ran the tests and the base-commit controls on my PC and wrote this report. I have not reviewed the code.
**@⁠4usphs** on GitHub · 2026-11-25 11:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7161623220) AMD run on the exact head `0da4c35` (0da4c3589012e886c47c7681314e9b2fbfdf93d6), as pushed on its base `930e8b4` (not merged onto current `main`), on two AMD adapters with native 64-lane waves: RDNA4 and the console's generation, RDNA2. **Tested** - Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug, clean checkout, `XCL_TRANSLATED_CACHE=0`; adapter picked with `XCL_ADAPTER`. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: - AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: **752 passed, 0 failed, 41 ignored** - AMD Radeon(TM) Graphics, the 9800X3D's iGPU (RDNA2, `gfx1036`), driver 32.0.21045.29003: **752 passed, 0 failed, 41 ignored** - No `SKIPPED` tests on either adapter. - This PR's test `wanted_compiles_contend_for_the_last_slot_under_memory_pressure` runs and passes on both adapters. **Not tested** - smoke or a retail title (I have none), a release build, Linux. **AI use** - Claude Code (Claude Opus 5.5) read the diff, ran the tests and the base-commit controls on my PC and wrote this report. I have not reviewed the code.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1364/head:github-bot/gh-1364'
git switch 'github-bot/gh-1364'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1364'
git switch 'github-bot/gh-1364'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1364'
git switch 'github-bot/gh-1364'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1364'
git switch 'main'
git merge --squash 'github-bot/gh-1364'
git switch 'main'
git merge --ff-only 'github-bot/gh-1364'
git switch 'main'
git merge 'github-bot/gh-1364'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.