Skip to content

Shaders: bound default compile workers by available memory - #572

Draft
WebIdentity1 wants to merge 1 commit into
xcl-dev:mainfrom
WebIdentity1:codex/memory-bounded-compile-workers
Draft

WebIdentity1 wants to merge 1 commit into
xcl-dev:mainfrom
WebIdentity1:codex/memory-bounded-compile-workers

Conversation

@WebIdentity1

@WebIdentity1 WebIdentity1 commented Nov 24, 2026 •

Copy link
Copy Markdown

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 b7aa9f3 now 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

Tested

  • Native Windows 10 Home 19045, Ryzen 7 7800X3D / 32 GB, RTX 3090 driver 591.74 plus AMD integrated graphics 32.0.21030.2001; Rust 1.98.1 MSVC, debug, SDK DXC 1.8.2502.11, Agility 1.620.2. NVIDIA selected for recompiler tests; some fixtures use default AMD. XCL_DXC_THREADS unset.
  • 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. Same gpu_clamp_and_omod_per_instruction failure as main 508a0c7 (679/1/41); Recompiler: complete remaining RDNA2 integer CLAMP=1 saturation (#105) #202 addresses it. Interactive desktop session.
  • Four explicit skips included in pass counts: 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.
  • Separate native probe: available parallelism 8, free physical memory ~25 GiB; both title/offline counts remained CPU-limited at 7, explicit override 4 selected 4. The 32-thread low-memory cases are synthetic policy tests, not an induced memory-pressure run.

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

  • The #542 reporter tested this exact commit in a multi-PR retail stack, with the override unset, and reports four runs without the earlier system unresponsiveness. They did not measure the chosen worker count or run this PR alone against main. Their later runs were stopped by their watcher for low free commit. This is external, mixed-stack evidence, not a paired regression run or a measured performance gain from this PR alone; the draft and smoke requirement remain.

AI use
Codex (GPT-6) inspected the code, implemented the patch/tests, ran native Windows validation and prepared this description.

Budget one GiB per worker after the existing title or offline reserve, using the smaller of free physical memory and available commit. Preserve explicit XCL_DXC_THREADS overrides and set the offline reserve before choosing the worker count.

Part of xcl-dev#542. Native Windows tests: policy 3 passed; old-decision control 1 passed and 2 failed. Workspace 682 passed, 1 pre-existing integer CLAMP failure, 41 ignored, four explicit skips. Retail regression not run; draft only.
@Grimkaaah

Copy link
Copy Markdown

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

  • Windows 11, RX 7900 XTX + AMD iGPU, Ryzen, MSVC, branch codex/memory-bounded-compile-workers at the PR head.
  • 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=4 remains the manual escape hatch for 8 GB cards until this lands.

JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.
@woreksami

Copy link
Copy Markdown

Test report from the machine in #542 (i9-14900K, 32 threads, 32 GB), with XCL_DXC_THREADS unset as asked.

Tested

What ends the runs now: commit, not physical memory

  • Commit limit 43.2 GB (system-managed pagefile, 11.5 GB allocated). Before launch ~24 GB of it is already committed by Windows and other programs (a browser with ~5.5 GB among them).
  • In three later runs commit fell to 2.4–2.5 GB free within 36–80 s, while 8.4–9.0 GB of physical memory was still free. The title's own commit grows by ~16.5 GB in that time; the pagefile did not grow (still 11.5 GB). My watcher stopped those runs at under 3 GB free commit.
  • So taking the smaller of physical and commit, as this PR does, is the right reading here: commit is the one that runs out. It does not help with the title's own growth, as the PR says.

Not tested

  • This PR alone on main (paired scripts/smoke.ps1 runs); the logged worker count; a larger fixed pagefile; AMD.

AI use

  • Claude Code with Claude Opus 5.5: built the branches, ran the title, read the logs and memory counters and wrote this report from those runs; watching the screen and listening was done by me.

JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.
JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.
JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.

(cherry picked from commit 8b9313f)
JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.

(cherry picked from commit 8b9313f)
JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.

(cherry picked from commit 8b9313f)
@asd3670576

Copy link
Copy Markdown

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

  • Windows 10 Pro for Workstations 19045.3324 (22H2), Rust/cargo 1.100.0, host toolchain x86_64-pc-windows-gnu (no MSVC, no Windows SDK: cargo build here needs MinGW-w64 on PATH or it dies with error calling dlltool 'dlltool.exe': program not found), Ryzen 9 5950X (32 logical CPUs), 64 GB RAM.
  • GPU: RTX 3080 20 GB, driver 610.88. DXC 1.9.2609.5 at H:\leonida\dxc\bin\x64 (XCL_DXC_DIR). Agility 1.620.2 at H:\leonida\agility\build\native\bin\x64 (XCL_D3D12_DIR) but it cannot load on this OS build (no ID3D12SDKConfiguration1 before KB5029331), so the inbox runtime caps at Shader Model 6.5 and XCL's GPU recompiler path is unavailable here.
  • Release profile throughout, XCL_DXC_THREADS left unset in every command. No title run here, so no xcl-smoke block 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 --porcelain empty before the build and after it. This PR is a draft and the API reports mergeable: false, mergeable_state: dirty against current main; I did not test a merge onto main.
  • cargo build --release --workspace → exit code 0:
    Finished `release` profile [optimized] target(s) in 26.99s

Tests

cargo test --release -p xcl --lib -- worker_tests -- --test-threads=1 --nocapture, the way the description runs them:

running 3 tests
test gpu::recomp::dxc::worker_tests::default_workers_fit_physical_memory_and_commit ... ok
test gpu::recomp::dxc::worker_tests::default_workers_leave_a_cpu_free_and_handle_missing_memory ... ok
test gpu::recomp::dxc::worker_tests::explicit_workers_keep_the_existing_override_and_bounds ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 661 filtered out; finished in 0.00s

cargo test --release -p xcl --lib -- gpu::recomp::dxc (toolchain, cache and worker tests together, default threads):

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 647 filtered out; finished in 0.44s

cargo test --release -p xcl --lib -- kernelx::lazy, three runs on the default thread count:

run 1: test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 662 filtered out; finished in 0.03s
run 2: test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 662 filtered out; finished in 0.02s
run 3: test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 662 filtered out; finished in 0.02s

cargo test --release --workspace --no-fail-fast -- --test-threads=4 → exit code 0. 16 test result: lines (one per test binary plus the doc-test run); the xcl lib is:

test result: ok. 643 passed; 0 failed; 21 ignored; 0 measured; 0 filtered out; finished in 6.09s

all 16 are ok; summed over them: 683 passed; 0 failed; 41 ignored. Skips, reported rather than counted as coverage: 86 SKIPPED lines, 84 : no GPU and 2 : no wave64, for example

SKIPPED gpu::recomp::tests::gpu_bvh_intersect_ray: no GPU
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no GPU
SKIPPED gpu::recomp::mesh_dispatch::tests::gpu_dispatch_matches_native_wave64_reference: no GPU

Forcing 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):

thread 'gpu::recomp::tests::gpu_bvh_intersect_ray' (20752) panicked at crates\xcl\src\gpu\recomp\runner.rs:439:9:
gpu::recomp::tests::gpu_bvh_intersect_ray: no GPU, but XCL_REQUIRE_GPU=mesh

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::dxc tests 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, so min(ullAvailPhys, ullAvailPageFile) minus the 6 GiB reserve is about 48, cores - 1 is 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.

JustDownTV added a commit to JustDownTV/xcl that referenced this pull request Nov 24, 2026
…hort

With the compile thread count bounded by free memory (xcl-dev#572), a machine with
~8 GB of commit free gets two compile threads, and the dedicated compute pool
(xcl-dev#533) took half of that: one worker. A single driver build of tens of seconds
then held every other compute pipeline behind it, and the per-frame wait
budget handed the title stand-ins for all of them.

Measured: bounded_compute_wait_shares_per_frame_budget_across_pipelines failed
with 8.3 GB of commit free (one compute worker) and passed with
XCL_DXC_THREADS=8. The pool now has 2 to 4 workers.

(cherry picked from commit 8b9313f)
@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 14d638a3 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 14d638a3ab3cf8d52f8eb6e6a88f0b559a530d5e
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1453 (PresentX 1453)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14741 MB

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants