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

Closed
Gevroska wants to merge 1 commit from upstream-pr/1364 into main
Gevroska commented 2026-11-24 15:16:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-24T15:16:54Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:5474951100 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1364). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-11-24T15:16:54Z. --- **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.
pickles976 commented 2026-11-24 16:07:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T15:20:35Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7135863219 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1364#issuecomment-7135863219). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T15:20:35Z. --- 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.
futurepro62 commented 2026-11-24 16:07:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:25:12Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7135995104 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1364#issuecomment-7135995104). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:25:12Z. --- 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.
DavidM1911 commented 2026-11-24 17:06:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:28:16Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7137716335 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1364#issuecomment-7137716335). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:28:16Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Gevroska commented 2026-11-24 17:06:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-24T16:56:54Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7138453159 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1364#issuecomment-7138453159). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-11-24T16:56:54Z. --- 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.
xpatfussy69x commented 2026-11-25 12:06:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:25:14Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7161022945 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7161022945). Originally posted by [xpatfussy69x](https://github.com/xpatfussy69x) on 2026-11-25T11:25:14Z. --- 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.
4usphs commented 2026-11-25 12:06:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-25T11:52:41Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7161623220 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7161623220). Originally posted by [4usphs](https://github.com/4usphs) on 2026-11-25T11:52:41Z. --- 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.
Gevroska commented 2026-11-28 18:00:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-28T18:00:05Z.


I closed this PR because main already fixes the same DXC slot-admission race in github.com/xcl-dev/xcl@a34eaed4d9. That change holds a mutex across the capacity check and the slot increment, so two workers cannot both claim the last slot. It also includes concurrent admission tests. The separate question in #534 is how many compiles to admit under memory pressure.

Thanks to everyone who tested this on AMD and NVIDIA hardware.

AI disclosure: I used Codex with GPT-6.2 Sol to verify the overlap. GPT-6.2 Astra drafted this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7243451008 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1364#issuecomment-7243451008). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-11-28T18:00:05Z. --- I closed this PR because main already fixes the same DXC slot-admission race in https://github.com/xcl-dev/xcl/commit/a34eaed4d9a49626ca1e84c4f4a2f09f89c8a82b. That change holds a mutex across the capacity check and the slot increment, so two workers cannot both claim the last slot. It also includes concurrent admission tests. The separate question in #534 is how many compiles to admit under memory pressure. Thanks to everyone who tested this on AMD and NVIDIA hardware. AI disclosure: I used Codex with GPT-6.2 Sol to verify the overlap. GPT-6.2 Astra drafted this comment.

Pull request closed

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!1354
No description provided.