Skip to content

d3d12x: cap cumulative PSO bind waits per PresentX frame - #2114

Open
rdj415 wants to merge 6 commits into
xcl-dev:mainfrom
rdj415:d3d12x-pso-per-frame-wait-cap
Open

rdj415 wants to merge 6 commits into
xcl-dev:mainfrom
rdj415:d3d12x-pso-per-frame-wait-cap

Conversation

@rdj415

@rdj415 rdj415 commented Nov 25, 2026 •

Copy link
Copy Markdown

Split from #1652 (Part of #156 / #1833 / #1452 / #505): cap cumulative pipeline bind waits per PresentX frame across all threads so bursts of cold pipeline builds cannot stall PresentX past a title's watchdog, and release wanted when a bounded wait expires so late builds return to memory/slot throttling.

Note on defaults (per @milesah3ad review): on main, unset XCL_PSO_WAIT_MS waits until each pipeline is built; with this PR, while a title runs (crate::state::boot().is_some()), unset XCL_PSO_WAIT_MS / XCL_PSO_FRAME_WAIT_MS defaults to 250 ms per pipeline and 2,000 ms process-wide cumulative per PresentX frame, meaning unbuilt compute dispatches are skipped during cold compile bursts (#1452 / #505). Passing XCL_PSO_WAIT_MS=0 waits until built (unless XCL_PSO_FRAME_WAIT_MS is explicitly set > 0, in which case the explicit frame cap wins). XCL_PSO_FRAME_WAIT_MS=0 disables the per-frame cap while keeping XCL_PSO_WAIT_MS (or the 250 ms title default when XCL_PSO_WAIT_MS is unset while a title runs).

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs: expose present::frame_generation() reading the monotonic BOUNDARIES frame counter.
  • crates/xcl/src/hle/d3d12x/pso_async.rs:
    • Add WaitCaps / resolve_caps and a process-wide FRAME_BUDGET: Mutex<FrameBudget> keyed by present::frame_generation(), briefly locked only before/after cv.wait_timeout_while so multiple recording threads share one per-frame wait cap instead of multiplying N * 2,000 ms.
    • Add reservation & cross-frame accounting (FrameBudget::reserve / FrameBudget::settle + FrameWaitGuard) so concurrent waits in the same frame reserve out of the shared remaining budget and late completions from an older frame never roll back or wipe a newer frame's spent/reserved budget. When per_frame is None, FrameBudget::reserve returns (caps.per_pso, false) immediately before checking frame generation so stale frame samples never zero out waits when the cumulative per-frame cap is disabled, while preserving stale-generation rejection when per_frame is Some(_).
    • Add TimedWantGuard (Pending::want_timed + Demand::timed_waiters / unbounded_wanted) so wanted stays raised only while a bounded wait is actively blocked; timed-out late builds return to real::big_compile_turn and dxc::wait_for_memory commit throttling instead of bypassing memory gates (huge, wanted at once (no slot)).
    • Keep spared (image_only) dispatches non-blocking before entering bounded wait budgeting, and once the frame's cumulative wait budget is exhausted, enqueue remaining pending binds and continue immediately with the stand-in without marking those pipelines late so they get a fresh wait window on the next PresentX frame; already-built pipelines still resolve immediately.
    • Add 6 unit tests (wait_caps_respect_env_and_title_boot_state, frame_budget_caps_cumulative_wait_and_resets_on_new_frame, frame_budget_stale_frame_sample_keeps_full_wait_when_per_frame_disabled, a_frame_budget_caps_a_burst_of_slow_pipelines_and_resets_next_frame, timed_out_bind_releases_wanted_so_late_builds_respect_throttling, and concurrent_binds_in_same_frame_share_reserved_budget).

Tested

  • hardware & toolchain: NVIDIA GeForce RTX 5060 Ti (driver 616.64 / 32.0.16.1664), 12th Gen Intel(R) Core(TM) i5-12400F, rustc 1.98.0-nightly (096694416 2026-06-29), release build and debug unit tests on Windows.
  • cargo test -p xcl --lib pso_async -- --nocapture (commit 21c88bc): 16 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=warp cargo test -p xcl --lib -- --test-threads=4 (commit 21c88bc): 1202 passed, 0 failed, 26 ignored (simulating GPU-less CI).
  • Paired retail smoke comparison via scripts/smoke.ps1 -Seconds 60 on clean 06c9f55 (upstream/main) and clean 21c88bc (d3d12x-pso-per-frame-wait-cap).
  • Earlier on e03690d (prior to the 1-function stale-sample fix in 21c88bc): ./scripts/test.ps1 --skip test_title_runs_and_game_folder_is_untouched --skip fuzz_validate_and_gpu (xcl --lib 1197 passed, 0 failed, 26 ignored; 19 workspace integration test binaries passed).

Regression run

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1418 (PresentX 1418)
presents per 2 s (last 3): 42 61 52
device removals: 0
crashes: 0
peak commit: 10622 MB

PR:

xcl-smoke v1
commit: 21c88bc26b60de5b7ef05b9a0fae5eb61fa6fc16
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1455 (PresentX 1456)
presents per 2 s (last 3): 60 60 53
device removals: 0
crashes: 0
peak commit: 10351 MB

Not tested

  • Full ./scripts/test.ps1 workspace integration binaries on 21c88bc (last run on e03690d), test_title_runs_and_game_folder_is_untouched, Python helper tests, and XCL_DXC_THREADS=4 / 34 GB multi-run world-loading stress test on commit 21c88bc.
  • Wave64 AMD GPUs, Linux (Wine + vkd3d-proton), and multi-title runtime runs beyond 3c290c16.

AI use

  • Gemini 4 Hydrogen: assisted with fixing FrameBudget::reserve stale-sample handling when per_frame is None, adding the regression unit test, running pso_async / XCL_ADAPTER=warp / scripts/smoke.ps1 verification, and updating/validating the PR description (building on earlier PR work).

@milesah3ad

Copy link
Copy Markdown
Contributor

Test report and three review notes for 8044bed. The split came out well: 249 lines in two files, and the tests reset per frame as described.

Tested

  • RTX 5080 16 GB, driver 621.24; Ryzen 7 9800X3D, 64 GB; Windows 11 Pro 26300; rustc 1.100.0 MSVC; DXC 1.9.2609.5; debug.
  • cargo test -p xcl --lib pso_async: 9 passed, 0 failed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1,093 passed, 4 failed, 46 ignored. The 4 are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (0x8007000E), the same as on main here, so not this PR. SKIPPED: the wave64-only tests.
  • The two new timing tests (frame_budget) 20 times in a row with 14 busy threads loading the 16-thread CPU: 20 / 20 passed. The < 20 ms and < 250 ms bounds held under load.

Review notes

  1. This changes the default, not only the knobs. On main, with XCL_PSO_WAIT_MS unset, a bind waits until its pipeline is built. The module's own doc says why for compute: "a skipped dispatch would corrupt what it computes". With this PR, while a title runs, the unset default becomes 250 ms per pipeline and 2,000 ms per frame. So compute dispatches are skipped during compile bursts by default (your run: 46,227 skipped). That is what gets the title past its watchdog, and it is also a candidate for wrong output in those frames (cf. the flat grey intro shots on Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505). Worth stating plainly in the description and README. It may also be worth asking @ivall whether the first step should be opt-in, as heap windows were.
  2. The cap is per thread. FRAME_BUDGET is thread_local! and the WaitCaps doc says "per thread within one PresentX frame", but the description and the wait_caps doc say "cumulative per frame". With several recording threads, the waits of one frame can add up to N × 2,000 ms if they happen one after another (they overlap when the threads wait at the same time). Either the docs could say per thread, or a process-wide atomic keyed on frame_generation would make it per frame.
  3. Minor, resolve_caps: XCL_PSO_WAIT_MS=0 ("wait until built") together with XCL_PSO_FRAME_WAIT_MS=N gives per_pso = per_frame = N, so the 0 no longer means "until built". That may be intended (the frame cap wins), but the doc of wait_caps doesn't say so.

Not tested: any title (no smoke pair here), AMD / Intel, release builds.

AI use: Claude Code (Claude Opus 5.5) ran the tests on the machine above, read the diff and wrote this. I checked the results.

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Test of 8044bed merged onto main 6020a33, on the retail title, XCL_DIRECT_DXIL=1, otherwise defaults. Caches were warm: every compute pipeline had been precompiled and the graphics pipelines built in earlier runs. No input after the menus.

run last presents presents after 82 s budget exhausted skipped draws / dispatches queue waits released device removed end
15-minute run 134 s 78 27 times 10 111 / 1 889 14, from 111 s no stopped by my memory guard at 137 s (process commit 34.3 GB)
two earlier runs 96 s, 102 s 6, 66 – ~4 400 / ~800 – 1 000 0 no memory guard at 98 s, 108 s (33 GB)

For comparison, main 177cd40 with the same warm caches ends in a device removal (0x887a0005) at 92 – 100 s, in 4 of 4 runs (#1452). With this PR none of the three runs removed the device, and the longest kept presenting to 134 s. Whether it gets past the watchdog, as in your 694 s run, I can't tell here: this machine gives the process about 34 GB before my guard stops it, and the title passes that at 137 s.

Tested: RTX 4080 16 GB (driver 610.88), i9-12900K, 64 GB RAM (commit limit 68 GB), Windows 11 26300, release.
Not tested: the suite on this head, runs past 137 s, AMD.

AI use: Claude Code (Claude Opus 5.5): ran the tests and wrote this.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the RTX 5080 and RTX 4080 reports above, since neither covers AMD. Tested exact head 8044bed (on its base bf9eebd).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1086 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: wait_caps_respect_env_and_title_boot_state, frame_budget_caps_cumulative_wait_and_resets_on_new_frame, a_frame_budget_caps_a_burst_of_slow_pipelines_and_resets_next_frame.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1096 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 6020a33 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with main (1411 here; 1368 and 1370 on the two main runs). No a pipeline still being built after … ms line appears in the log, so the cap is not seen to act in this run; this is a regression run only.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 6e1e2befc7430126b1e7b98b5c3fe93813c866b6
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1368 (PresentX 1368)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 378a0775001770ee48f6d820a69f9da4a54017ad
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1411 (PresentX 1411)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The second main run: 1370 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the whole test suite on this head, a run where binds wait on pipelines (XCL_PSO_WAIT_MS or similar), native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@thehollowedone

thehollowedone commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent Windows verification at 378a077. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug.

Tested

  • Clean head: cargo build --offline --locked --workspace -j 3 passed. cargo test --offline --locked --workspace --no-fail-fast -j 3 -- --nocapture --test-threads=4 reported 1,158 passed, 0 failed, 46 ignored. Separately, 25 runtime skip notices (20 no native wave64, three unsupported per-lane forms, one driver cache disable probe, one no heap windows).

  • Two additional synthetic cases in cargo test --offline --locked -p xcl --lib pso_async -j 3 -- --nocapture --test-threads=1 failed on the PR implementation (10 passed, 2 failed, 0 ignored, 0 runtime skips). Two pending binds started together in the same frame charged 501.7 ms in total against a 250 ms cap. In a separate test, frame 2 spent 40 ms of its 100 ms allowance. Recording a late completion from frame 1 gave frame 2 its full 100 ms back instead of leaving 60 ms.

  • A local candidate reserved each capped wait while holding the budget mutex and settled it only against the frame that granted it. The same focused command then passed all 12 tests with 0 failures, ignores, or runtime skips. I have the patch if useful.

  • Follow-up on the local candidate applied to the same PR head: the workspace build and the full workspace test command above passed on the RTX 3080 Ti. The suite reported 1,160 passed, 0 failed, 46 ignored, and the same 25 runtime skip notices. Both added cases passed with four test threads.

Not tested
Retail load and frame pacing. The description check still asks for a smoke block from the current head.

AI use
Codex (GPT-6.2 Sol) wrote the synthetic cases and local candidate, ran the tests, and drafted this report.

@iggyvilla

Copy link
Copy Markdown
Collaborator

Test report on 378a077 merged as 0640e29 onto main 568e7db, vs main 568e7db itself. RX 6650 XT 8 GB / Adrenalin 32.0.21045.29003 / Ryzen 7 5700X /
32 GB (commit limit ~44 GB). Retail walk from a save (-FromSave), PRELOAD=0,
XCL_PSO_WAIT_MS=2000, local commit stop at 37.8 GB.

Tested: main, 2 walks; #2114, 1 walk.

What was measured: main (both walks): 0 submits and 0 presents after 130 s,
13–17 a pipeline still being built after 2000 ms waits. #2114 (1 walk): 25
per-frame pipeline wait budget (2000 ms) exhausted warnings, submits 16/28/6/35
per 2 s at 132–140 s, 1 present at 140 s, 0 device removals, stopped by the
commit stop at ~143 s (world not reached). Note: with only one walk on the PR
this is a positive signal, not a verdict — the frame-budget mechanism fires and
submissions continue past main's 126 s halt, but the wall (commit stop) does not
move.

Review notes (each confirmed in the #2114 diff at 378a077; the rest of the
XCL-130b review I did not re-verify and do not repeat):

  • Frozen frame (B4): the budget is keyed to PresentX (present.rs:145
    frame_generation() reads BOUNDARIES), and budget-exhausted binds return
    the stand-in without late (pso_async.rs:901-912, if !truncated_by_frame
    at :924). Once the title stops presenting, one 2 s window is spent and every
    later compute bind in that frame skips silently — matching this walk (budget
    exhausted 25×, presents 0 after the single 140 s frame).
  • Cross-frame settlement (B1) / no reservation (B2): record(frame, …) at
    :919 settles against the wait-start frame, and record at :834-840
    zeroes spent on a frame mismatch, so a wait ending in a later frame erases
    the new frame's spend; remaining() at :900 releases the mutex before the
    wait, so concurrent binds each get a full window. Both already reported
    upstream at this head (thehollowedone, with reproductions); direction is
    cap-loosening only.
  • XCL_PSO_FRAME_WAIT_MS=0 with XCL_PSO_WAIT_MS unset (B3): resolve_caps
    (None, _) => None (:772-775) gives unbounded waits, contradicting the doc
    at :793-794 ("disables the per-frame cap while keeping XCL_PSO_WAIT_MS").
    Do not use this combination as a frame-cap-off control arm.
  • Smaller confirmed nits: priority restore runs after the demand lock is
    released (bounded by the wait budget, not correctness); the PR body says "3
    deterministic unit tests" but the diff adds four; resolve_caps(Some(p), None, …) raises the frame cap to max(2000, p), so the knobs are not
    independent.

Not tested: suite run on this tree; repeat walks (variance); NVIDIA/other
GPUs; PRELOAD=1; world reached.

AI use: Measured by an omp agent running DeepSeek v4.1 Flash; review
findings first drafted by DeepSeek v4.1 Flash and confirmed in the diff by Muse
Spark 1.3, which wrote this text; checked (including three of the cited lines at 378a077) and posted by Claude Code (Claude Opus
5.5) on my behalf; I did not run the tests or write the text.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 5cb6779:

  • Demand::unbounded_wanted + TimedWantGuard (want_timed) cleanly restore THREAD_PRIORITY_LOWEST when bounded frame waits time out without letting them clear an active unbounded want() wait.
  • Diff audited and CI workflow approved (running).

Remaining before merge: Fix PR description, Build and test green, and dual-vendor verification on 5cb6779.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

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

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: 5cb67796609ff17f20cd4bd5fbb7e1acdde4ba75
gpu: AMD Radeon RX 9070
title: 34df7c50
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: 14592 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 100 % 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; a script posted this right after the run, with both blocks exactly as printed.

@iggyvilla

Copy link
Copy Markdown
Collaborator

Follow-up to my test report above: the control arm, same box, same protocol (378a077 merged onto main 568e7db, -FromSave walk, PRELOAD=0, XCL_PSO_WAIT_MS=2000, commit stop at 37.8 GB), one walk with XCL_PSO_FRAME_WAIT_MS=0.

arm frame-budget warnings presents after 130 s console counter, last line
main 0 0 16905 draws (0 skipped), 8192 dispatches (0 skipped)
#2114 25 1 (at 140 s) 17252 draws (2048 skipped), 11878 dispatches (277 skipped)
#2114, FRAME_WAIT_MS=0 0 0 16599 draws (0 skipped), 8192 dispatches (0 skipped)

With the per-frame cap off, the PR head behaves like main: submits stop at ~126 s and nothing is presented. So the extra submissions and the one present come from the per-frame cap, not from the build or cache warmth. The cost is the frozen-frame issue from my notes: 24 of the 25 exhaustion warnings are in frame 1907 and 1 is in frame 1909, the title presented 1910 frames in all, and the final "(4097 so far)" is the skip count of the frame it never left. All three walks still end at the commit stop (~141–143 s), so the world is not reached.

These walks are on 378a077. 5cb6779 (reservation across threads, cross-frame settlement, FRAME_WAIT_MS=0 keeping the per-pipeline cap) does not change this part: the budget still resets only when PresentX advances the frame, so I expect the same skips once the title stops presenting. I have not re-run on 5cb6779.

AI use: the walks and log tables were run by an agent on DeepSeek V4.1 Flash (open-weight, measurement only). I checked the counts above against the three xcl.log files with Claude Opus 5.5 (Anthropic), and it wrote this comment.

@rdj415

rdj415 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@iggyvilla @thehollowedone @raylitebull Thank you for the reviews and reproduction cases!

Merged upstream/main (06c9f55) into d3d12x-pso-per-frame-wait-cap at e03690d (keeping #2176 spared / image_only, #2178 orphan drain, #1782 pc_call, and #1988 PresentRing), and fixed a 4-vCPU CI test deadlock we hit on 5cb6779:

  1. Cross-frame settlement (B1): FrameBudget::reserve only advances self.frame forward (frame > self.frame; stale frames < self.frame return (ZERO, true)) and FrameBudget::settle only reconciles when self.frame == frame, so late wakeups from an earlier frame never roll back or wipe a newer frame's spent/reserved budget.
  2. Concurrent wait reservation (B2): FrameBudget tracks reserved: Duration under the mutex before cv.wait_timeout_while with RAII FrameWaitGuard::drop calling settle(), so simultaneous binds on multiple threads split the shared frame cap without oversubscribing it.
  3. B3 / B4 & CI test stability (e03690d): updated wait_caps() / resolve_within_in_frame() docs and tests (XCL_PSO_FRAME_WAIT_MS=0 keeps XCL_PSO_WAIT_MS or 250 ms while booted), resolved pso_async.rs cleanly against 06c9f55, and fixed a_frame_budget_caps_a_burst_of_slow_pipelines_and_resets_next_frame so ready builds before p1..p4 (submit_lazy + 30 s safety timeout) — previously, submitting 4 blocking jobs before ready saturated all 3 workers on a 4-vCPU CI runner (compile_threads() == 3), timing out p1 at 5 s before resolve_within_in_frame ran.

Re-verified on e03690d:

  • cargo test -p xcl --lib pso_async -- --nocapture: 15/15 passed (also 15/15 with XCL_DXC_THREADS=3 --test-threads=4 and --test-threads=1).
  • ./scripts/test.ps1 --skip test_title_runs_and_game_folder_is_untouched --skip fuzz_validate_and_gpu: xcl --lib 1197 passed, 0 failed, 26 ignored + all workspace test binaries passed.
  • XCL_ADAPTER=warp cargo test -p xcl --lib -- --test-threads=4: 1201 passed, 0 failed, 26 ignored.
  • Paired 60 s scripts/smoke.ps1 (06c9f55 -> e03690d): 1418 -> 1492 frames, 0 device removals, 0 crashes, 10622 -> 10378 MB peak commit.

@Gevroska

Copy link
Copy Markdown

I found a case on e03690d5 where a pending compute pipeline gets no wait time even though the cumulative frame cap is disabled and the per-pipeline cap is 250 ms.

I reproduced it in a standalone CPU test using the PR’s FrameBudget::reserve implementation. Caller A samples frame generation 1. Before A acquires the budget mutex, caller B advances the budget to generation 2. When A calls reserve with its earlier sample, it gets (0 ns, true). With the cumulative cap disabled, I expected (250 ms, false). In the caller, that zero grant returns the stand-in before entering the wait.

Three control cases passed. The stale-sample case was the only failure. In a separate fixture, returning the per-pipeline allowance before checking the generation when per_frame is None made all four pass, including stale-generation rejection when the cumulative cap is enabled. I’d add this combination to the regression tests. I haven’t measured how often it occurs in a title run.

I used Codex GPT-6.2 Sol for the fixture and a separate GPT-6.2 Sol agent for independent verification.

I reviewed and approved this comment before posting.

@rdj415

rdj415 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@Gevroska @raylitebull Fixed the stale-sample case on 21c88bc: FrameBudget::reserve now returns (caps.per_pso, false) immediately when per_frame is None before checking self.frame, so a stale frame generation sample no longer zeros out the per-pipeline wait when the cumulative per-frame cap is disabled, while stale-generation rejection is preserved when per_frame is Some(_).

Added regression unit test frame_budget_stale_frame_sample_keeps_full_wait_when_per_frame_disabled and re-verified:

  • cargo test -p xcl --lib pso_async -- --nocapture: 16 passed, 0 failed
  • XCL_ADAPTER=warp cargo test -p xcl --lib -- --test-threads=4: 1202 passed, 0 failed, 26 ignored
  • Paired 60 s scripts/smoke.ps1 (21c88bc vs 06c9f55, 3c290c16): 1455 frames vs 1418, exit: 0x0, 0 device removals, 0 crashes, 10351 MB peak commit vs 10622 MB; pr_check PROBLEMS: [].

@milesah3ad

Copy link
Copy Markdown
Contributor

Re-check of 21c88bc on the RTX 5080 after the review fixes. The code holds up. The branch now conflicts with main again.

Tested (RTX 5080 16 GB, driver 621.24; Ryzen 7 9800X3D; Windows 11 Pro 26300; rustc 1.100.0; DXC 1.9.2609.5; debug)

  • cargo test -p xcl --lib pso_async: 16 passed, 0 failed (including the new stale-sample and reservation cases).
  • The same 20 times in a row with 14 busy threads loading the 16-thread CPU: 20 / 20 passed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1,267 passed, 4 failed, 46 ignored. The 4 are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, the same as on main here.

Conflict: against main 397ea96, git merge-tree reports a content conflict in crates/xcl/src/hle/d3d12x/pso_async.rs only (present.rs auto-merges). Since this branch's merge base, pso_async.rs on main was changed by #2296 (5b97e22 "clamp PcCalls across frame boundaries and drop orphaned PSO jobs immediately") and 625a0f3 ("stand-ins of pipelines not built yet share the driver's pipelines"). The first touches the same frame-boundary bookkeeping as FrameBudget.

Not tested: a title run of 21c88bc, AMD.

AI use: Claude Code (Claude Opus 5.5) ran the tests on the machine above and wrote this. I checked the results.

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.