Skip to content

D3D12.X: big compiles of bound programs take turns under a bind budget - #1686

Open
CalvyPZ wants to merge 1 commit into
xcl-dev:mainfrom
CalvyPZ:bound-compute-compiles
Open

CalvyPZ wants to merge 1 commit into
xcl-dev:mainfrom
CalvyPZ:bound-compute-compiles

Conversation

@CalvyPZ

@CalvyPZ CalvyPZ commented Nov 24, 2026

Copy link
Copy Markdown

With XCL_PSO_WAIT_MS set, a bind waits for a compute pipeline within a budget and then goes on with the stand-in. Its build stayed "wanted", and a wanted build of a big program (256 KB of DXIL or more) takes neither the one slot for big driver compiles nor waits for 3 GB of free commit. That rule is for a bind that waits until the pipeline is built; with a budget nothing holds the title, and the builds piled up in the driver. Under a budget a big build now always takes a turn. Without XCL_PSO_WAIT_MS nothing changes. Part of #1269 (claimed there: #1269 (comment)).

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: bound_compile_turn – under a bind budget, a big build nobody has bound stays in the one-at-a-time queue (BIG_COMPILES); one the title has bound takes a slot of a second queue and waits for the commit like the others. bound_compiles_at_once sizes that queue from the machine: half the logical processors, one per 8 GB of memory, at least one (4 on 16 threads / 32 GB). Tests bound_builds_go_several_at_once_and_wait_for_the_commit, bound_builds_at_once_follow_the_threads_and_the_memory.
  • crates/xcl/src/hle/d3d12x/pso_async.rs: binds_have_a_budget and build_is_bound (a bind waits for the build, or went on without it). Test a_build_hears_that_its_pipeline_is_bound.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (32-lane waves), driver 32.0.16.1088; Ryzen 7 5800X (16 threads), 32 GB RAM; Windows 11 Pro 26300; rustc 1.96.1 stable-x86_64-pc-windows-msvc; DXC 1.9.2609.5; tests in debug, title runs in release.

  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on 6bf360e: 861 passed, 0 failed, 42 ignored.

  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

  • Retail title, world start, XCL_PSO_WAIT_MS=100, XCL_PSO_DISK_CACHE=0, a new exe name per run (cold driver cache), scripted A presses. These runs were on main 930e8b4 with temporary log lines around the driver's compile of big programs (not in this PR), before the rebase:

    930e8b4 with this change
    big compiles in the driver at once, at most 9 1
    big compiles begun with less than 3 GB of commit free 8 (down to 0.8 GB) 0
    process commit, 88 s → 114 s (video memory flat) +2.3 GB +0.7 GB

    The "with this change" column is a run of an earlier form of the change that put every bound build back into the one-at-a-time queue. A run of the form in this PR (with D3D12.X: a bind does not wait for a pipeline behind the workers' queue #1273 applied locally on top) also had one big compile in the driver at a time and none begun under 3 GB free; its bound builds were waiting for the commit, which was under 3 GB from 90 s on (0.6 GB at 122 s) from the world load alone.

Regression run

scripts/smoke.ps1 -Game <folder> -Seconds 60, release, main c160d86 and this PR's head 6bf360e:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 5070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1368 (PresentX 1368)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15027 MB
xcl-smoke v1
commit: 6bf360e6e8089b52d2df9662b81d64f0522fd5c5
gpu: NVIDIA GeForce RTX 5070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15804 MB

Not tested

  • The regression runs do not reach the changed code: they run without XCL_PSO_WAIT_MS and without input, so the title stays in its front end.
  • Several bound builds at once in a title run. This machine had less than 3 GB of commit free by the time the title bound its big programs, so only the unit test shows it. A machine with more memory free is needed for that, and for whether threads / 2 and one per 8 GB are the right sizes.
  • The title's world start still ends at its hang watchdog on this machine, with and without the change (frames stop about 90 s in); this PR does not address that. Builds waiting for a turn each hold a worker, which that stall may make worse; not measured apart from it.
  • A title run of the rebased commit 6bf360e with XCL_PSO_WAIT_MS (the measurements above are on 930e8b4).
  • AMD, Intel, Linux / Wine, GPUs with 8 GB, a machine with less than 32 GB of RAM.

AI use

  • Claude Code with Claude Fable 5.2: read the code, ran the measurements, wrote the change, the tests and this description. I ran the title runs on my own hardware and files.

🤖 Generated with Claude Code

With XCL_PSO_WAIT_MS a bind waits for a compute pipeline within a budget
and goes on with the stand-in. The build stayed "wanted", and a wanted
build of a big program (256 KB of DXIL or more) takes neither the one
slot for big driver compiles nor waits for 3 GB of free commit: that
rule is for a bind that waits until the pipeline is built, which would
hold the title. With a budget nothing holds the title, and the builds
piled up in the driver.

Measured on a retail title's world start (RTX 5070 Ti, 16 threads,
32 GB, XCL_PSO_WAIT_MS=100, cold driver cache, main 930e8b4): nine big
compiles in the driver at once, eight of them begun with less than 3 GB
of commit free (down to 0.8 GB), and 2.3 GB more process commit in 28 s
with video memory flat.

Under a budget a big build now always takes a turn. One nobody has bound
stays in the one-at-a-time queue; one the title has bound (a bind waits
for it or went on without it) takes a slot of a second queue, sized from
the machine (half the logical processors, one per 8 GB of memory, at
least one), and waits for the commit like the others. Without a budget
nothing changes.

Same run with the change: one big compile in the driver at a time, none
begun with less than 3 GB free. The machine had under 3 GB free by the
time the title bound its big programs, so several at once was not seen
in a title run; the unit test covers it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@CalvyPZ
CalvyPZ marked this pull request as ready for review November 24, 2026 19:18
@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@lewisnic94-max lewisnic94-max left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My earlier comment reported EXEC-mask results from #1801. I reviewed the compile scheduler here at 6bf360e6e8089b52d2df9662b81d64f0522fd5c5.

With the free-commit check held false, I promoted a worker that already held the background slot. It released that slot, occupied one bound slot and stayed blocked until I allowed the commit check to pass. Both slot counts returned to zero after the worker finished. I found no actionable defect in that handoff.

The independent batch002_scheduler fixture and the big_compile_tests and a_build_hears filters ran serially with cargo test --offline --locked -j 1 -p xcl --lib <filter> -- --test-threads=1 --nocapture. Across those runs, 6 passed, 0 failed, 0 ignored, and 0 skip notices. Windows 11 build 26200.9974, Ryzen 7 5800X, RTX 3080 driver 616.92, debug MSVC Rust 1.100.0. The fixture controlled the memory predicate. It did not measure driver memory under load, the DXC reserve or preload-worker priority.

Codex (GPT-6) inspected the scheduler, wrote the promotion fixture and checked the test logs.

@not-rex

not-rex commented Nov 24, 2026

Copy link
Copy Markdown

Reading this against main 20cf1302: resolve_within (pso_async.rs:588) marks a late pipeline wanted and nothing clears it, and this PR stops that from bypassing the big-compile turn and the commit wait in real.rs. Two other places still treat a late, skipped build as wanted, in case you want them in scope:

  • dxc.rs:427, wait_for_memory: through wanted_here(), up to six wanted compiles skip the 6 GB + 1 GB-per-compile reserve, so late DXC compiles under a bind budget still run past it.
  • pso_async.rs:72-104: a preload worker building a wanted pipeline is raised from LOWEST to NORMAL priority, so late builds keep competing with the title's threads after the bind has given up on them.

Context from an RTX 3080 world run with XCL_PSO_WAIT_MS=50: all 23 xcl-pso workers were inside the driver compiler on one heap lock (the pool is cores - 1), and in another run commit jumped from ~31 GB to 55 GB at ~690 s, which fits unthrottled late builds. I haven't run this PR yet.

AI use: Claude Code (Claude Opus 5.5) read the code and wrote this note.

@JJAutoCompare

Copy link
Copy Markdown

XCL PR #1686 — Windows / Intel Arc A770 verification

Head 6bf360e6e8089b52d2df9662b81d64f0522fd5c5, detached and clean before and after testing. The diff changes crates/xcl/src/hle/d3d12x/pso_async.rs and crates/xcl/src/hle/d3d12x/real.rs.

STOR-WINLAB ran Windows 11 Enterprise Evaluation x64 (build 26200.9974) on an AMD Ryzen 7 3800X and Intel Arc A770 (driver 32.0.101.9175). dxc.exe --version reported 1.9.2609.5. Rust was 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), with unoptimized profiles and debug info disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the Arc mutex. The latter built 19 test executables.
  • cargo test -p xcl --lib a_build_hears_that_its_pipeline_is_bound passed 1 test. It checked that a worker sees no bind initially and sees the pipeline as bound both during the wait and after the 300 ms budget returns the stand-in.
  • cargo test -p xcl --lib bound_builds_ passed 2 tests. They checked that bound builds wait for a slot and free commit, that a queued background build moves to the bound slots when bound, and that CPU threads and memory cap concurrency with a minimum of one. Both focused commands were CPU-only with XCL_ADAPTER=NONE_CPU_ONLY, with 0 failures, 0 ignored and 0 skip lines.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once inside Invoke-ArcTest.ps1 with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1. Cargo exited 101. Summing all 20 result lines (19 test executables and one doc-test target) gave 843 passed, 18 failed, 42 ignored. All three focused tests also passed in this run.

Workspace failures and skips

The library had 17 failures. Thirteen reported CreateComputePipelineState error 0x80070057. Four reported GPU result mismatches (fused arithmetic, mip sampling, packed 16-bit ALU and wave reductions). The test-title e2e failed its dynamic depth-bias pixel check. Six lines began with SKIPPED : two for wave64, two for missing D3D12 debug-layer support, one for tiled tier < 2 and one for unavailable heap windows. These skips provide no coverage.

Not tested

No matched main run, retail-title smoke run, or measurement of driver compile concurrency under retail load. Optional game sample variables were unset. Other GPU vendors were outside this run.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1686-suite.log and published.

@justrhoto

Copy link
Copy Markdown

Test report: #1686 rebased onto main 6020a33, RTX 4070 Ti SUPER, retail title with XCL_PSO_WAIT_MS=500

This is a local rebase, not the PR head. 6bf360e does not cherry-pick cleanly onto 6020a33: main has moved the compute gate into driver_compile_identified, sizes the commit wait per program (big_compile_headroom) and has a separate lane for compiles of 4 MiB and up (GIANT_COMPILES). How I resolved it:

  • the binds_have_a_budget branch now sits in driver_compile_identified (compute only) instead of at the compute call site, which is main's as it is;
  • bound_compile_turn gets || big_compile_commit_free(big_compile_headroom(bytes)), and the PR's no-argument big_compile_commit_free is dropped;
  • a giant compile uses GIANT_COMPILES for both lanes under a budget, so it stays one at a time and is never let through without a slot.
let commit_free = || big_compile_commit_free(big_compile_headroom(bytes));
let slot = huge
    .then(|| match kind == "compute" && super::pso_async::binds_have_a_budget() {
        true => {
            let lane = compile_slots(bytes);
            let bound_lane = if std::ptr::eq(lane, &GIANT_COMPILES) { lane } else { bound_compiles() };
            Some(bound_compile_turn(lane, bound_lane, commit_free, super::pso_async::build_is_bound))
        }
        false => big_compile_turn(compile_slots(bytes), commit_free, super::pso_async::build_is_wanted),
    })
    .flatten();

#751 was applied on the same tree (it applied cleanly and only touches title_textures.rs). Tested commit: local aa1f25d = 6020a33 + #751 + this PR as resolved above.

Tested

  • NVIDIA GeForce RTX 4070 Ti SUPER 16 GB (32-lane waves), driver 32.0.16.1088; Ryzen 5 5600X3D (6 cores, 12 threads); 64 GB RAM; Windows 11 Home 26200; rustc 1.100.0; DXC 1.9.2602.17. Tests in debug, the title in release.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on aa1f25d: 1159 passed, 0 failed, 46 ignored. The PR's three new tests pass.
  • SKIPPED (26): 20 no wave64; 3 f16 / f32 cases the recompiler refuses (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics); ir_text_assembles_signs_and_runs (no dxil.dll); heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows); pso_measurement_compiles_an_exact_synthetic_record (needs Developer Mode).
  • Retail title 1.0.2.1, world start, XCL_PSO_WAIT_MS=500, nothing else set. The driver blob cache was warm from earlier runs, so most big programs came from disk. One run, 475 s:
    • Logged big compute programs the title has bound are built 6 at once (12 threads, 64 GB: min(6, 8)).
    • 7 cold big compute compiles went through the bound queue, all gated, with up to 5 in the driver at once. A 10.9 MB program (95cc13288a27a96e) ran on the giant lane from 17 s and had not finished at 475 s.
    • No compute compile was let through without a slot. The only two wanted at once (no slot) lines are cached graphics pipelines (2 ms each), which this path does not gate.
    • Per-compile cost: ~1 MB programs took 193–255 s each with 4–5 others in the driver. A run on this machine without a budget built the same size in 44–47 s when one was alone. ~290 KB programs took 17–31 s.
    • The run ended in a crash in the title at 475 s: game_scarlett_master.exe+0x8ac62c, write at 0x376d0, on the main thread inside window-message dispatch (USER32 frames). It is not in code this PR changes, and I don't know its cause.
  • For comparison, an earlier run on this machine with XCL_PSO_WAIT_MS=500 on a build without this PR (around cbc296a; I can't confirm the exact commit, and its cache was colder) had 10 or more big compiles in the driver at once, all wanted at once (no slot). 260–440 KB programs took 35–70 s each there.

Regression run

  • None: I did not run scripts/smoke.ps1.

Not tested

  • The PR head 6bf360e itself.
  • A cold driver cache (XCL_PSO_DISK_CACHE=0). Only 7 cold big compiles reached the new queue in this run.
  • Whether 6 at once is right for a 6-core CPU. Each compile was about 4–5× slower than alone. I did not measure total throughput against fewer slots.
  • A second run, and AMD / Intel GPUs.

AI use

  • Claude Code (Claude Opus 5.5) resolved the rebase conflict, ran the tests, read the title logs and wrote this report. I ran the title.

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.

7 participants