Shaders: bound default compile workers by available memory #567
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/572"
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 WebIdentity1 on 2026-11-24T01:56:48Z.
Limit the default DXC and feeding PSO worker count by available memory. Part of #542: a 32-thread CPU currently starts up to 31 workers regardless of free physical RAM.
November 24 status
Still a draft; no source refresh yet. Main
b7aa9f3now admits up to six wanted compiles under memory pressure (9a272d4). This startup cap can create only one or two DXC/feeding-PSO workers when initial headroom is low, and its cached count does not grow when memory recovers. Before refreshing, that interaction needs a throughput/memory comparison; the existing policy tests do not establish watchdog safety. The admission-slot race is already covered by #1364 / #1417 and is outside this PR. All counts below remain evidence for the original revisions, not current-main integration or gameplay.What is in it
dxc.rs: one worker per GiB remaining after the existing reserve, using the smaller of available physical memory and commit; also keep the CPU-minus-one / 1–64 bounds. ExplicitXCL_DXC_THREADSretains its override. Without a memory reading, default to one worker.shaders.rs: set the offline 2 GiB reserve before the count is cached. Normal title runs retain the 6 GiB reserve. README documents the startup cap.Tested
XCL_DXC_THREADSunset.cargo test --locked -p xcl --lib worker_tests -- --nocapture --test-threads=1: 3 passed / 0 failed / 0 ignored. Restoring the old CPU-only decision while retaining these tests: 1 passed / 2 failed. Covers memory boundaries, CPU limits, offline reserve and overrides.cargo build --locked --workspace: exit 0.cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output: 682 passed / 1 failed / 41 ignored. Samegpu_clamp_and_omod_per_instructionfailure as main508a0c7(679/1/41); #202 addresses it. Interactive desktop session.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64);test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state(no debug layer). Sample inputs unset; system XGameRuntime comparison unavailable.Regression run
Not run: no retail title available. Keeping this draft; the required main/head smoke blocks are missing.
Not tested
Retail loading, memory-pressure performance, release builds or runaway compiler allocations. The count is fixed at first use; future memory changes remain the live gate's responsibility. No gameplay or total-memory reduction claim.
Independent follow-up
AI use
Codex (GPT-6) inspected the code, implemented the patch/tests, ran native Windows validation and prepared this description.
Imported from ivall/xcl. Originally posted by Grimkaaah on 2026-11-24T02:10:01Z.
Independent test (Grimkaaah) – friend's target is an RTX 4060 Ti 8 GB; this PR is the right mitigation for the cold-compile stampede on that class of card (#542 was filed on a 3060 8 GB).
Tested
cargo test -p xcl --lib worker_tests -- --nocapture --test-threads=1: 3 passed, 0 failed (same three cases as in the description).Looks good to undraft once CI/smoke are happy. Explicit
XCL_DXC_THREADS=4remains the manual escape hatch for 8 GB cards until this lands.Imported from ivall/xcl. Originally posted by woreksami on 2026-11-24T02:20:28Z.
Test report from the machine in #542 (i9-14900K, 32 threads, 32 GB), with
XCL_DXC_THREADSunset as asked.Tested
XCL_NETWORK=0,XCL_PSO_WAIT_MS=150main9ce2070+ #214 (960162e), #267 (043d1f7), #300 (9507d05), #503 (78f5510), #468 (0d407cf), #456 (017515c) + this PR (14d638a).cargo test --release -p xcl --lib: 658 passed, 0 failed, 21 ignored.XCL_DXC_THREADS=4: the default (31 here) made the machine unresponsive in the first compile wave. With this PR and no override, no run made the machine unresponsive (four runs).What ends the runs now: commit, not physical memory
Not tested
main(pairedscripts/smoke.ps1runs); the logged worker count; a larger fixed pagefile; AMD.AI use
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172upstream-sync referenced this pull request2026-11-24 11:05:44 +00:00
Imported from ivall/xcl. Originally posted by asd3670576 on 2026-11-24T10:25:05Z.
Built and tested the PR head on a Windows 10 machine that has no Shader Model 6.6 and only a GNU toolchain. Every count below is pasted from the run, not written by hand.
Machine
x86_64-pc-windows-gnu(no MSVC, no Windows SDK:cargo buildhere needs MinGW-w64 on PATH or it dies witherror calling dlltool 'dlltool.exe': program not found), Ryzen 9 5950X (32 logical CPUs), 64 GB RAM.H:\leonida\dxc\bin\x64(XCL_DXC_DIR). Agility 1.620.2 atH:\leonida\agility\build\native\bin\x64(XCL_D3D12_DIR) but it cannot load on this OS build (noID3D12SDKConfiguration1before KB5029331), so the inbox runtime caps at Shader Model 6.5 and XCL's GPU recompiler path is unavailable here.XCL_DXC_THREADSleft unset in every command. No title run here, so noxcl-smokeblock from this machine.Apply / build
git fetch https://github.com/ivall/xcl pull/572/head:pr572→14d638a3ab3cf8d52f8eb6e6a88f0b559a530d5e, checked out as-is: no rebase, no conflict resolution,git status --porcelainempty before the build and after it. This PR is a draft and the API reportsmergeable: false,mergeable_state: dirtyagainst currentmain; I did not test a merge ontomain.cargo build --release --workspace→ exit code 0:Tests
cargo test --release -p xcl --lib -- worker_tests -- --test-threads=1 --nocapture, the way the description runs them:cargo test --release -p xcl --lib -- gpu::recomp::dxc(toolchain, cache and worker tests together, default threads):cargo test --release -p xcl --lib -- kernelx::lazy, three runs on the default thread count:cargo test --release --workspace --no-fail-fast -- --test-threads=4→ exit code 0. 16test result:lines (one per test binary plus the doc-test run); the xcl lib is:all 16 are
ok; summed over them: 683 passed; 0 failed; 41 ignored. Skips, reported rather than counted as coverage: 86SKIPPEDlines, 84: no GPUand 2: no wave64, for exampleForcing the requirement shows the SM 6.5 cap directly (
XCL_REQUIRE_GPU=mesh cargo test --release -p xcl --lib -- --exact gpu::recomp::tests::gpu_bvh_intersect_ray):What this machine can and cannot verify. The three worker tests pass, and DXC 1.9.2609.5 itself loads and compiles here (those 17
gpu::recomp::dxctests are real), so the override, the bounds and the "no memory reading → 1 worker" path are covered. What this box cannot do is exercise the new bound for real: I measured 54.5 GiB free physical and 125.4 GiB free commit against a 153 GiB commit limit, somin(ullAvailPhys, ullAvailPageFile)minus the 6 GiB reserve is about 48,cores - 1is 31, and the CPU bound still decides — the default this PR picks here is the same 31 as before it. On this machine the memory term only becomes the limit once free headroom drops below ~37 GiB, which it never does at 64 GB of RAM. So the 8 GB-card behaviour this PR is for stays unverified here beyond the synthetic tests; and with SM 6.5 no GPU test ran at all, so nothing about the compile stampede of #542 can be reproduced on this box.AI use: an agent (DeepSeek Harness, "auto" route - I do not know the underlying model) built the head, ran the tests and pasted the output.
Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T02:58:02Z.
Regression run of
14d638a3on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 90 % of
main's frames, 99 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T13:18:40Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:44:18Z.
Triage (#1607) – head
14d638aNo open or merged PR makes this change: main's
compile_threadsis still cores - 1. #2127 caps the threads under Wine only, #2950 changes the live memory gate; neither bounds the default count by memory.Notes on
dxc.rs: the count is taken once (OnceLock) fromullAvailPhys/ullAvailPageFileat first use, so if that happens after the title has allocated, the run keeps a low count for its whole life (down to 1); and 1 GiB per worker is well above the 0.1-0.3 GB the old comment gives for a typical translation, so a 16 GB machine drops from 15 workers to a few. The default slowdown of shader compiles is not measured in the description.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.