Recompiler: serialize dxc::wait_for_memory slot admission (#2463) #2642
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2652"
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 fixgep on 2026-11-26T05:05:00Z.
Fixes the TOCTOU admission race in
dxc::wait_for_memory(crates/xcl/src/gpu/recomp/dxc.rs) where concurrent DXC worker wakeups readWORKINGwithout synchronization before callingfetch_add(1), admitting bursts past both the commit headroom check andWANTED_AT_ONCE. Part of #2463, Part of #1566, Part of #1269.What is in it
crates/xcl/src/gpu/recomp/dxc.rs: wrapWORKINGadmission checks (plenty,timed_out,cur == 0, andcur < WANTED_AT_ONCE && wanted()) andfetch_add(1)in aMemoryGatemutex while keepingMemorySlot::droplock-free and sleeping outside the mutex; add synthetic multi-threaded unit tests inmemory_gate_tests.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug & release builds on commit88d7b0a1.cargo test -p xcl --lib gpu::recomp::dxc:: -- --test-threads=4: 24 passed, 0 failed, 0 ignored (0 SKIPPED); also 24 passed, 0 failed underXCL_ADAPTER=warp.cargo test -p xcl --lib -- --test-threads=4: 1312 passed, 1 failed (gpu::recomp::tests::gpu_clamp_and_omod_per_instruction,v_pk_add_i16clamp mismatch on RTX 3060), 27 ignored (25 SKIPPED: 21no wave64, 3wave32 per-lane refused, 1cannot disable the driver cache).XCL_ADAPTER=warp cargo test -p xcl --lib -- --test-threads=4: 1312 passed, 1 failed (hle::d3d12x::list_x::tests::mid_list_write64_wait64_split_avoids_cycle_and_reuses_sparesunder parallel adapter/UMA init; passed on default GPU), 27 ignored.cargo test -p xcl --test '*' -- --test-threads=4: 126 passed, 0 failed, 20 ignored across 33 integration test suites (1 SKIPPED:no heap windows).Regression run
Not tested
AI use
MemoryGateandmemory_gate_tests, test/smoke execution, and PR description drafting.Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-26T05:06:53Z.
Tested: exact clean head
88d7b0a19a276f81491e8430acb5d7dd501ebb1e, Windows MSVC target under Wine 11.0 on Linux, 16 GiB RAM / RTX 4060 Laptop GPU host. FreshCompiling xcl .../xcl-pr2652/crates/xclprovenance confirmed.cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib memory_gate_tests -- --nocapture --test-threads=1: 4 passed, 0 failed, 0 ignored, 0.14 s. This covers tight synthetic commit headroom, the wanted burst limit, draining concurrent waiters, and the single unwanted progress slot. Tests internally spawn concurrent callers despite the serial test harness. Run through the local Wine wrapper in a scope with MemoryMax=9G / MemorySwapMax=512M.Not tested: real compiler-memory peaks, Windows-native execution, GPU dispatch, retail title, or matched-parent regression. These are CPU synchronization tests with supplied memory values, not proof of Wine's commit telemetry or a hard memory budget. The existing 60-second escape remains; this addresses #2463 item 2, not its separate title-thread driver-compile bypass. No title-safety or FPS claim.
Local log:
.compat-xcl/logs/verify-pr2652-wine-memory-gate.log. AI use: omp / OpenAI Codex GPT-6 Astra, test execution and report; no source changes.Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-26T05:29:57Z.
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. This PR does not change the mad/mac red on RADV.Targeted run of
low_commit_unwanted_admits_only_one_progress_slot,tight_commit_headroom_bounds_concurrent_admissions,wait_for_memory_drains_concurrent_waiters_within_cap,wanted_burst_never_exceeds_wanted_at_once: 4 passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-26T08:31:55Z.
Independent native AMD test report for #2652 (issue #2463, item 2) on exact head
88d7b0a19a276f81491e8430acb5d7dd501ebb1e, against its exact parentb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7(main, also the merge base). Both were clean detached checkouts with no local changes; PR head and comments were rechecked before posting. This is a test report only, not a source review.Tested
stable-x86_64-pc-windows-msvc), debug build. The suite log namesAMD Radeon RX 7800 XTas the adapter (D3D12.X: backend 'real'). No other xcl process was using the GPU.cargo --locked -j 4. Workspace binaries were built before the tests (cargo build --workspace, thencargo test --workspace --no-run).cargo test -p xcl --lib memory_gate -- --test-threads=1: 4 passed, 0 failed, 0 ignored (low_commit_unwanted_admits_only_one_progress_slot,tight_commit_headroom_bounds_concurrent_admissions,wait_for_memory_drains_concurrent_waiters_within_cap,wanted_burst_never_exceeds_wanted_at_once). I ran them 10 more times with--test-threads=4: 4 passed each time. The tests use supplied memory values, not real compiler memory peaks.cargo test -p xcl --lib dxc -- --test-threads=4: head 48 passed, 0 failed, 3 ignored. Parent 44 passed, 0 failed, 3 ignored. The difference is the 4 new tests, which do not exist on the parent (memory_gateon the parent runs 0 tests).cargo test --workspace --no-fail-fast -- --test-threads=4: 1438 passed, 1 failed, 47 ignored (lib: 1312 passed, 1 failed, 27 ignored).gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,seed 722: res[30] = 0x1, CPU 0x7fffffff. It is a baseline failure on this adapter, not caused by the PR.f16_programs_on_the_gpu/f32_programs_on_the_gpucases (refused ... its #1426 semantics differ) andheap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows. None of them touchesdxc.rs. I do not count skips as coverage.memory_gatetests, discarded it, rebuilt the parent from its own path (Compiling xcl ... xcl-2652-src-parent) and reran. The parent counts above come from that rerun.Regression run
scripts/smoke.ps1and used no title or game data.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T08:59:11Z.
Independent native Windows/NVIDIA test of PR #2652 head
88d7b0a, based on mainb49be18. Clean exact-head checkout; RTX 3080 Ti (driver 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. DXIL cache was isolated under this checkout'stargetdirectory.Tested
cargo build --offline --locked --workspace: passed.cargo test --offline --locked -p xcl --lib memory_gate_tests -- --nocapture --test-threads=1: 4 passed, 0 failed, 0 ignored, 0 skips. The tests internally spawn concurrent callers for commit headroom, wanted-burst admission, draining, and the one-progress-slot rule.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet: 1,439 passed, 0 failed, 47 ignored across 37 test targets, with 25 explicit GPU skip notices. Skips are not counted as GPU coverage.Not tested: a measured DXC memory peak under retail world load, deliberate system commit exhaustion, AMD/Intel hardware, or my own paired title smoke. These results verify the synthetic admission tests and workspace behavior on this machine; they do not establish a title-level memory or frame-rate improvement.
AI-assisted: Codex (GPT-6.2 Sol) ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-26T13:08:30Z.
Two contributors checked independently and found that #1417 solves the same problem (for #2463) in a different way: #1607, group D126. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by fixgep on 2026-11-26T14:19:24Z.
Thanks for flagging #1417, @throny
I checked #1417 (
9a3230fa) against this PR (88d7b0a1) and think it makes sense to keep #2652 open unless maintainers prefer rebasing #1417:README.md(mergeable: false, flagged on Nov 24 and not yet rebased), whereas #2652 touches onlycrates/xcl/src/gpu/recomp/dxc.rsand merges cleanly ontomain.try_admit_compileCAS loop prevents theWORKINGrace forrunning == 0andWANTED_AT_ONCE, but readsGlobalMemoryStatusExoutside the CAS loop and re-evaluateswanted()(lockingPending::demandinpso_async) on every retry. #2652'sMemoryGateevaluatesavail_page_file(),wanted(), and theworkingincrement together while keepingMemorySlot::droplock-free and sleeping outside the mutex.memory_testscoverWANTED_AT_ONCEandrunning == 0; #2652'smemory_gate_testsalso cover tight commit headroom (avail >= need), timeout fallback, and concurrent waiter draining.Happy to defer to whichever approach maintainers prefer.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T23:44:09Z.
Independent desktop NVIDIA verification of PR #2652 at head
88d7b0a19a276f81491e8430acb5d7dd501ebb1e(1commit; exact parent & merge-base:b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
88d7b0a1)cargo test --release -p xcl --lib tight_commit_headroom_bounds_concurrent_admissions -- --nocapture1 passed; 0 failed; 0 ignored; 1339 filtered out(0.04s)cargo test --release -p xcl --lib wanted_burst_never_exceeds_wanted_at_once -- --nocapture1 passed; 0 failed; 0 ignored; 1339 filtered out(0.01s)cargo test --release -p xcl --lib wait_for_memory_drains_concurrent_waiters_within_cap -- --nocapture1 passed; 0 failed; 0 ignored; 1339 filtered out(0.08s)cargo test --release -p xcl --lib low_commit_unwanted_admits_only_one_progress_slot -- --nocapture1 passed; 0 failed; 0 ignored; 1339 filtered out(0.00s)cargo test --release -p xcl --lib gpu::recomp::dxc::(3 consecutive runs)24 passed; 0 failed; 0 ignored; 1316 filtered out× 3 (0.44s,0.44s,0.43s)cargo build --release -p xcl --bin xcl1m 07s, exit0)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):PR #2652 (
88d7b0a19a276f81491e8430acb5d7dd501ebb1e):Runtime log observations (
xcl.log)9220log lines,0[ERROR]/ device-removal / panic lines.19621 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14016 MB committed by the process; video memory 6114 MB local, 4683 MB non-local.Limits of coverage
dxc::wait_for_memoryslot admission under tight commit headroom, concurrent waiter draining, wanted bursts, and single-slot unwanted progress were verified via all 4 newmemory_gate_testsand 3×gpu::recomp::dxc::(24/0/0).title: 29640639rather than reproducing cold DXC commit-pressure bursts (frame-count delta vs. cached parent smoke reflects single-run startup variance, not this PR).AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:01:21Z.
merge-check claim
head:
88d7b0a19aImported from ivall/xcl. Originally posted by throny on 2026-11-28T03:16:05Z.
merge-check
base:
753e8b1ahead:
88d7b0a19amerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1516 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: none blocking. The gate is polled every 50 ms as on main, not signalled, so no wake-up can be lost; there is no queue order, as on main, and starvation stays bounded by the per-waiter timeout; a poisoned mutex is recovered and a panic in the wanted check leaks no slot. The wanted check now runs under the gate mutex and takes the demand lock, and nothing holds that lock while calling into the gate (not every closure was traced). The admission rules are main's. For the maintainer: triage marked #1417 as a duplicate of this; no decision yet.
performance: no frame cost. It changes a translator source (dxc.rs is in the hashed list): every tester re-translates the HLSL-path shaders once.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T12:05:23Z.
merge-check claim
head:
88d7b0a19aImported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T12:40:12Z.
merge-check
base:
e429936c10head:
88d7b0a19amerge: clean
build: cargo build --workspace -> ok; the test build (cargo test --workspace --no-run) -> failed: error[E0428]: the name
memory_gate_testsis defined multiple times (crates\xcl\src\gpu\recomp\dxc.rs:2009, previous definition at :1890)tests: not run (the lib test target does not compile on the merge)
review: not repeated in full: the diff adds a second
mod memory_gate_teststo dxc.rs with four tests (tight_commit_headroom_bounds_concurrent_admissions, wanted_burst_never_exceeds_wanted_at_once, wait_for_memory_drains_concurrent_waiters_within_cap, low_commit_unwanted_admits_only_one_progress_slot); main already has a module of that name with the same four tests (commita34eaed4, merged with #2959), so on main the diff is a duplicate.performance: no runtime change (test-only diff).
verdict: not yet: the test build fails on the merge (duplicate module; main already has these tests); drop them or rebase onto main
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge defff6e520a0801abfc05bc616a28a40d2a5ced6 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-12-01T05:54:31Z.
merge-check
base:
d0832e614fhead:
88d7b0a19amerge: clean
build: cargo build --workspace -> ok
tests: not run:
cargo test --workspace --no-runfails on the merge with E0428,memory_gate_testsdefined twice (crates/xcl/src/gpu/recomp/dxc.rs, main's at line 2354, this PR's at 2473)review: this PR is already on
main, byte for byte.git patch-id --stableof its diff against its merge base (b49be183) isdd611ebb…, the same as main'sa34eaed4("Recompiler: serialize dxc::wait_for_memory slot admission", bmjask, landed with #2959). All 101 distinct lines it adds are in main'sdxc.rs. Git merges the code once but adds the test module a second time, hence the error. throny's "safe to merge" was on an older base, before #2959; KOLESNiii's "not yet" is right about the merge. Nothing is left to merge. The PR can be closed as carried by #2959 (author credit is the maintainer's call).performance: none: no change against
main.verdict: not yet: already on
main(identical patch toa34eaed4via #2959); the merge's test build fails on the duplicate module, close or rebase to nothinghardware / tool and model: RTX 5070 Ti 16 GB + AMD Radeon iGPU, Ryzen 7 9800X3D, Windows 11 26300 (no suite ran: the test build fails). Claude Code, Claude Opus 5.5: merge, build, test build, patch-id comparison and review.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:34:38Z.
Triage (#1607) – head
88d7b0aThis change is already on main: commit
a34eaed4(same title, "Recompiler: serialize dxc::wait_for_memory slot admission") has the samegpu/recomp/dxc.rsdiff as this PR's commit88d7b0a: theMemoryGatemutex around the admission check plus the four threaded tests. Only the hunk offsets differ.#1417 fixes the same race with a compare-exchange loop instead.
Recommendation: close (superseded by main commit
a34eaed4).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:56:53Z.
Closing as superseded: this change is already on
main(a34eaed4). main commita34eaed4has a dxc.rs patch identical line for line to PR head88d7b0a1(diffed)Two independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed