DXC memory gate: reserve only the running compiles' growth, no stampede after a minute #139
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!139
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/139/head"
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?
@hexgeon1 on GitHub · 2026-11-23 14:58 UTC · original
hexgeon1:dxc-memory-gate→main· +318 −23 · 3 files · 3 commits · closed without mergingThe memory gate from #113 throttles DXC hard on a normal desktop. With 8.1 GB of commit free, Minecraft Preview's 716 programs took 12.7–15.2 s on the default 15 threads; with this change, 6.35–6.71 s. The DXIL is identical.
What was wrong
wait_for_memorylet a compile start while the system had 6 GB of commit left plus 1 GB for every compile already running.Changes (
crates/xcl/src/gpu/recomp/dxc.rs)may_start: a compile goes in at once while commit covers 6 GB plus 300 MB per running compile. The 300 MB covers their growth still to come; #113 measured a typical retail compile's peak at 0.1–0.3 GB. With less, compiles go one at a time.HANDOFF.md: the two places that describe the gate are updated.The second commit adds
dxc_bench_folder, an ignored test that times DXC for a folder of console shaders and prints HLSL and DXIL digests. It's how the numbers below were measured; drop it if you'd rather not have it.Numbers
Ryzen 7 5700X (8 cores / 16 threads), RTX 3090, DXC 1.9.2602, Minecraft Preview's 716 programs, 4 memory windows, default 15 threads. Free commit was 8.1 GB before every run. Both builds use the same benchmark, run interleaved, 3 runs each:
main(484dd57)mainand with this PR.Checked
cargo test --workspace --release --no-fail-faston an RTX 3090 with the Agility SDK 1.616.1: everything passes, 0 GPU skips.gate_testscovers the rule, short commit (one at a time, one escape per interval) and 32 threads through the real gate never exceeding what the commit allows.dxc.rs.mainhits the same way (being looked into separately).Not covered
xcl-psoworkers are still not memory-gated.🤖 Generated with Claude Code
dxc_bench_folder, DXC cost of a folder of shaders 75b0d04a93@tronLives111 on GitHub · 2026-11-23 17:02 UTC · original
The concurrency test can fail even when the gate admits every worker correctly. It computes
allowedfrom oneGlobalMemoryStatusExsnapshot, whilewait_for_memorychecks available commit again for each admission.I checked a short schedule against the thresholds in
5d84b26: the test initially sees 6,144 MiB, so it assertspeak <= 2(allowed + 1). The first worker enters at 6,144 MiB. If another process then releases 600 MiB, the second and third workers can both enter at 6,744 MiB while the first is still running. Their thresholds are 6,444 and 6,744 MiB, so all three admissions are valid, but the test rejectspeak == 3. The initial probe also ignores the Windows API return, so a failed probe can supply a zero baseline while later probes succeed.Could the admission loop take a test-only memory sampler so all workers in this test see a fixed budget? That would let the test assert the exact cap and leave a live-memory run as a smoke check. I verified the admission arithmetic with a deterministic schedule on macOS. I did not run the Windows concurrency test. AI-assisted review.
@hexgeon1 on GitHub · 2026-11-23 17:46 UTC · original
Thanks – you're right, the test could fail on a correct gate: its limit came from one reading while the gate re-reads commit per decision, and other tests' compiles share the real gate's count too. Fixed in
03e2efe: the gate is now aGatevalue andadmit(gate, commit)takes the commit reading, so the test runs on its own gate with a fixed budget (room for 3) and asserts the exact cap – 3 reached, 4 never (a gate letting one more in fails it). A separate test checks 32 workers get through the real gate. 30/30 runs pass; full suite green with the GPU on an RTX 3090. Would be glad to get feedback.@gefydev on GitHub · 2026-11-23 18:15 UTC · original · edited 2026-11-23 19:05 UTC
Measured on a machine with little commit: Ryzen 5 1600 (6C/12T), 16 GB RAM, 20.7 GB commit limit, GTX 1650, Windows 11 26300, DXC from SDK 10.0.26100, 11 DXC threads, debug build.
Synthetic bench, no game data: 200 different compute shaders through
pso_async+ DXC, no cache, no driver PSO. 3 runs each, interleaved, commit free before every run:maindb5dc26(this PR's base)03e2efeSo about 14 % less here. These shaders are small and alike, so this says little about memory growth of big programs. The 4
gate_testspass, including the reworked concurrency one. I did not run the rest of the suite on this PR.mainis at956a476now and conflicts indxc.rs: it addedRESERVE_GB/set_memory_reserve(6 GB with a title, 2 GB for--precompile) on the line this PR changes. The 1 GB per running compile is still there, so the PR's point still stands by reading; I have not measured it on top of956a476.@Kalmarv on GitHub · 2026-11-23 21:07 UTC · original
AI-assisted review (Claude Code). Windows 11 (10.0.26200), Ryzen 9 9950X (32 threads), Rust 1.99.0 MSVC, debug build, Windows SDK DXC 1.7.2308. Synthetic programs only, no game files, no GPU.
Tested
03e2efeon its basedb5dc26. It does not merge ontomain(956a476, and still not onto currenteaa36b6).dxc.rsconflicts, becausemainmade the 6 GB floorRESERVE_GB/set_memory_reserve(2 GB for--precompile), as gefydev noted. A rebase should useRESERVE_GBforCOMMIT_FLOOR. I did not test a rebased version.The PR's
gate_testspass on the head (4/4).Method: real concurrent DXC compiles through the gate, against a fixed commit budget.
GlobalMemoryStatusExignores a job's memory limit. Under a 9 GiB cap it still reported about 30 GB available.admit(gate, commit), on a gate of its own, exactly as a pool worker does, and then runscompile_hereon a real translated program (xcl-pso's #156 bench generator: wave32, 4 windows, 15 workers). The commit it sees is a budget minus the process's real private-commit growth since the start. That is the model in the PR: what the running compiles already use is out of available commit.db5dc26'swait_for_memoryloop, copied verbatim with the same commit source.One compile alone grows private commit by 160 MB for a 2000-round program (987 KB of HLSL) and by 460 MB for 4000 rounds (1.9 MB). A probe of 8000 rounds (3.8 MB, 65 s) grew 1.5 GB.
* In S3 the budget is below floor + one compile, so any running compile puts the commit under 6 GB. That is the "one at a time" case working as intended.
What this shows:
Accounting finding: 300 MB per running compile is too little for bigger programs, and compiles that start together aren't counted at all.
A cheap improvement: scale the reservation with the source, e.g. reserve per compile by HLSL size, since growth here went roughly with size: 160 MB at 1 MB, 460 MB at 1.9 MB, 1.5 GB at 3.8 MB. Or keep the per-compile reservation until the compile ends instead of only counting it. Even in S2 the PR stays better than the base, whose stampede reached 2.9 GB.
Not tested:
wait_for_memorypath with system commit (deliberately not driven on a shared machine);@Kalmarv on GitHub · 2026-11-23 21:07 UTC · original
Linux / Wine / GNU run of
03e2efeon its own basedb5dc26. It doesn't merge onto currentmaineaa36b6:gpu/recomp/dxc.rsconflicts, because main addedRESERVE_GB/set_memory_reserveand aWORKINGcount where this PR introducesGate. A rebase ontoeaa36b6is needed (as asked on #198), and the gate has to account for main'sset_memory_reserve(xcl shaders --precompilewith less reserve).Setup: Ubuntu 24.04, cross-built for
x86_64-pc-windows-gnu(release), under Wine 11.21 Staging. Under Wine,GlobalMemoryStatusEx's available commit is computed from Linux RAM and swap, sothe_real_gate_lets_every_worker_throughruns on a different commit source than on Windows.recomp::dxcfilter:db5dc2603e2efeAll four new
gate_testspass:compiles_start_while_commit_covers_the_floor_and_the_running_ones_growth,short_commit_lets_one_compile_at_a_time_and_one_escape_per_interval,concurrent_admissions_reach_and_never_exceed_what_the_commit_allowsandthe_real_gate_lets_every_worker_through.Not covered: the rebased PR; a run with little commit (this machine isn't short of it);
dxc_bench_foldertiming; no control with the old gate under the new tests (the tests need theGateAPI).AI-assisted test report (Claude); tests run locally as stated.
@raylitebull on GitHub · 2026-11-24 10:43 UTC · original
Closing as a stale, conflicting pre-template PR (touching
HANDOFF.mdand missing requiredCONTRIBUTING.mdsections). Feel free to open a fresh rebased PR if this is still needed.Pull request closed