D3D12.X: add opt-in per-frame PSO wait budget (XCL_PSO_FRAME_WAIT_MS) #1921
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1931"
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 gsucristo on 2026-11-24T23:40:45Z.
Adds an opt-in shared per-frame wait budget (
XCL_PSO_FRAME_WAIT_MS=<ms>, off by default) forpso_async::resolve_wait. When a title binds dozens of uncompiled compute pipelines in a single frame, a per-pipeline timeout (XCL_PSO_WAIT_MS) multiplies across each pending pipeline and can stall a frame for seconds; sharing one budget across the frame caps total stall time and refills onPresentX.What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs: parseXCL_PSO_FRAME_WAIT_MS, track remaining microsecond wait budget for the current frame, cap eachresolve_waitbymin(XCL_PSO_WAIT_MS, frame_remaining), deduct elapsed wait time, and exposebegin_frame()to refill the budget. Pipelines skipped solely because the frame budget ran out are not marked permanentlylate, so they can still be waited for on the next frame if not finished by a worker yet.crates/xcl/src/hle/d3d12x/present.rs: callsuper::pso_async::begin_frame()inpresent_x_frame.README.md: documentXCL_PSO_FRAME_WAIT_MS.shared_frame_budget_caps_multiple_slow_pipelines_and_refills_on_next_frameverifying that a second pending pipeline returns immediately once the shared frame budget is spent and resolves after refill.Tested
rustc 1.98.1, debug test build cross-compiled tox86_64-pc-windows-msvccargo test --target x86_64-pc-windows-msvc -p xcl --lib -- pso_async::: 7 passed, 0 failed, 0 ignoredRegression run
main:
PR:
Not tested
cargo test --workspace -- --test-threads=4scripts/smoke.ps1regression run on main and this PR (required before leaving draft)AI use
pso_async::unit tests under Wine, and drafted this PR description.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T00:57:07Z.
Code review on \e870dd2:\n\n- \XCL_PSO_FRAME_WAIT_MS\ in \pso_async.rs\ and \present.rs\ cleanly shares a microsecond per-frame budget across
esolve_wait\ calls, refills on \PresentX, avoids marking frame-budget-exhausted pipelines permanently \late, and handles \udget.is_zero()\ after \p.want(). \Build and test (Windows, no GPU)\ is green.\n\nWhat is still needed before merge:\n1. Fix the \PR description\ check (include an exact-head \xcl-smoke\ pair in the PR body for \hle/d3d12x/*\ changes).\n2. Independent AMD and NVIDIA verification on \
e870dd2.Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-25T01:35:26Z.
Test report: #1931 on the retail title's world load
I tested head
e870dd2, merged without conflicts ontomainbf9eebd(local merge2bce47f), in a release build. The title stops presenting at about 76 s onmain. WithXCL_PSO_FRAME_WAIT_MS=500it gets past that point, but then it crawls, and with a warm cache it crashes.Setup
XCL_PRESS_AT=16:A, default settings otherwise (no direct DXIL, no heap windows).Results
mainbf9eebd, fresh cachequeue.Waitwatchdog lines0xFFFFFFFFFFFFFFFF; no device removalFindings
queue.Waittimeouts: each waits on a value one step past what the GPU has completed. It is the same access violation @STmihan reported on #1269 (comment), which they tie to split recordings whose older segments are not reset. I did not test that fix; it has no PR. #1993 conflicts withmaininsparse.rs, so I did not run it.Not tested
XCL_DIRECT_DXIL, heap windows, AMD.AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:40:59Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by Dezmonius on 2026-11-25T06:54:07Z.
Native Windows comparison of the runtime hunks from
e870dd2, applied tocbc296abwith the same local DirectStorage late-page adaptation and activity counters in both runs. RTX 5070 / 610.88, i7-7700K, 32 GiB RAM, Windows 10 19045, Rust 1.100.0 release. Both runs were offline with direct DXIL, Series X profile, same scripted input and same warm cache location.XCL_PSO_WAIT_MS=1000in both; the 500 ms frame budget ran second.The enabled run had only a few later presents. The last sampled image remained loading artwork, and I did not verify any rendered gameplay. The final queue timeouts included a producer whose fence had been submitted but was still one value short of the requested completion. This directly shows the PSO wait signal dropping and queue timeouts appearing in this pair, without establishing that the timeouts caused the crash.
cargo test --locked --offline -j 4 -p xcl --lib pso_async:: -- --test-threads=1: 7 passed, 0 failed, 0 ignored on the candidate. Full suite not run. No game assets or raw logs attached. AI-assisted (OpenAI Codex, GPT-6).Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-25T07:25:17Z.
Test report for
e870dd2(this PR's head) onmain568e7db, alone and together with #929 (b3a969b), on the retail title.Builds: local merges, never pushed. This PR conflicts with
maininREADME.mdonly; that conflict was resolved tomain's side, and no code conflicted.5ada3de=main+ this PR (present.rs+1,pso_async.rs+127/−7).80ffe43=main+ this PR + #929, merged one at a time (addstitle_list.rs+167).Tested
xcl runof the retail title for 300 s, with a new emptyXCL_DXIL_CACHEper run. One run per row.queue.Waitwatchdog linesmain568e7db5ada3de(this PR)XCL_PSO_FRAME_WAIT_MS=500+0x23cf683)80ffe43(this PR + #929)XCL_PSO_FRAME_WAIT_MS=500+0x4e51965)main's stop at about 70 s, but slowly. Presents per 10 s after the stop:+0x23cf683(the offset seen onmainin earlier runs) to a later bad read.Not tested
XCL_PSO_FRAME_WAIT_MSvalues, a warm cache, and more than one run per build.AI use: Claude Code. A Claude Sonnet 5.5 session made the local merges, ran the title runs and collected the counts; Claude Opus 5.5 wrote this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-26T00:48:19Z.
Two contributors checked independently and found that #1652 #2114 solves the same problem (for #505) in a different way: #1607, group D95. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:04:28Z.
Review: COMMENTED
On
e870dd2, the frame budget is read beforeresolve_wait_for_exand debited only after it returns. Two title threads resolving different pending PSOs can each read the same 40 ms remaining value, each wait for 40 ms, and then subtract 40 ms. That admits roughly 80 ms of aggregate bind waiting in a frame whose setting promises a 40 ms total cap. The sequential unit test at lines 511–543 does not exercise simultaneous callers.There is a related frame-boundary race:
begin_framestores the new frame's allowance while an old wait is still in flight; the old wait's laterconsume_frame_budgetsubtracts its elapsed time from the new frame. Could each caller reserve its allowance atomically before sleeping, then refund unused time only to the frame generation it reserved from? A barrier fixture that starts two pending binds together, plus one that refills during an outstanding wait, would cover both cases.This is an exact-head source review. I did not run a concurrent repro or title smoke test.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:58:12Z.
Review (head
e870dd2b, diff read, not a merge-check; draft and conflicting, withPR descriptionred):resolve_wait(nowresolve_wait_budgets) andresolve_within, addedXCL_CS_PSO_WAIT_MSand a per-thread, per-second graphics budget (5904ad4b), and moved compute waits to the submit (#2118), so a rebase is a redesign against that code. Main has no per-frame budget; open #2988 adds a graphics frame budget and also conflicts.frame_rem,pso_async.rs~514-522) and never callsresolve_wait,begin_frame(~673) orconsume_frame_budget(~663).XCL_PSO_FRAME_WAIT_MSset, compute pipelines that were waited for until built get their dispatches skipped once the frame budget runs out (~577-597); main's docs say a skipped dispatch corrupts what it computes, and the README should say so. Concurrent waits on different threads each subtract their full wait from the one shared budget, so it runs out faster than the frame's wall-clock time.PR descriptionfails); AI use doesn't name the model.Fine: opt-in and off by default, refilled from
present_x_frame, and it doesn't mark pipelineslatewhen only the frame budget ran out. Recommendation: rewrite on main's budget code with a test throughresolve_wait/begin_frame, or close in favour of the per-thread budget main has.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:06:33Z.
Triage (#1607) – head
e870dd2Overlaps the D95 group. #2114 caps bind waits per PresentX frame by default (250 ms per pipeline, 2 s per frame) and isolates the queues per lane. #1652 carries an earlier version, bundled with unrelated changes. This PR is an opt-in global budget (
XCL_PSO_FRAME_WAIT_MS) that is refilled inpresent_x_frame. Main has since added its own cumulative limit (5904ad4b,XCL_GFX_PSO_WAIT_MSas a per-thread share of a second,gfx_wait_left) and a separateXCL_CS_PSO_WAIT_MSfor compute.resolve_waithas been rewritten, so this needs a rebase onto that design.Problems in the diff:
shared_frame_budget_caps_multiple_slow_pipelines_and_refills_on_next_framere-implements the budget in a local closure with its ownAtomicU64. It never callsresolve_wait,frame_budget_remaining,consume_frame_budgetorbegin_frame, so the new code is not tested.XCL_CS_PSO_WAIT_MSis set.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.