Recompiler: fix the race for the last wanted DXC slot #1354
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1364"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
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.
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_ONCEwanted compiles because the fast path (WORKING.load < WANTED_AT_ONCE && wanted()) and theplenty || 60 sbranch eachfetch_addindependently, and the CAS(0,1) fallback could stack on top; thetry_reserve_wanted_slotCAS 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 failedat ~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: passplentyintotry_reserve_wanted_slotand cap the wanted branch at 2 when it is false — one parameter, one constant, testable with your existing barrier harness by flipping thewanted()/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.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 base930e8b4).Tested
cargo build --workspace, thenXCL_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.wanted_compiles_contend_for_the_last_slot_under_memory_pressure.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
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!
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.
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:25:14Z.
Test report for head
0da4c35as pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignoredwanted_compiles_contend_for_the_last_slot_under_memory_pressureran and passedXCL_SAMPLE_*data set (game-data tests not run)Not tested
mainAI use
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 base930e8b4(not merged onto currentmain), on two AMD adapters with native 64-lane waves: RDNA4 and the console's generation, RDNA2.Tested
XCL_TRANSLATED_CACHE=0; adapter picked withXCL_ADAPTER.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:gfx1036), driver 32.0.21045.29003: 752 passed, 0 failed, 41 ignoredSKIPPEDtests on either adapter.wanted_compiles_contend_for_the_last_slot_under_memory_pressureruns and passes on both adapters.Not tested
AI use
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.
Pull request closed