Skip to content

kernelx: Sleep does not count the time a bind waits for a pipeline build - #1288

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
imnicho:kernelx-sleep-hold
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
imnicho:kernelx-sleep-hold

Conversation

@imnicho

@imnicho imnicho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

A retail title ends itself half a minute to a little over a minute after the set-up of its world begins. Its own stall check – a thread that ticks once a second with Sleep and gives up after 30 ticks without a sign of the main thread, decoded in #505 – fires while the main thread is held in binds for compute pipelines the driver is still building. A console title never waits there. The ways around it so far skip the dispatches of a pipeline not built yet (XCL_PSO_WAIT_MS, #891: later passes then run on what the skipped ones left unwritten, #675) or change the title.

Here XCL takes the title's Sleep, and the time a bind is waiting for a pipeline's build does not count as the title's time: the check does not tick while XCL holds the thread it watches. Only a sleep of 100 ms or more is taken so; a shorter one is a poll and goes on as before (changed after @Royalflamejlh's question below, with the comparison under Tested). Nothing of the title is changed and no dispatch is skipped. The plan was posted in #505 (#505 (comment)). Part of #505.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: title_held() – whether a bind is waiting in resolve_wait for a pipeline still being built (a counter around the wait, with or without XCL_PSO_WAIT_MS). Test a_bind_waiting_for_a_build_holds_the_title.
  • crates/xcl/src/hle/kernelx.rs: Sleep (a title imports it through api-ms-win-core-synch, which XCL resolves to kernelx): a sleep of 100 ms or more returns after ms of time in which the title was not held, taken in steps of at most 20 ms; a shorter sleep, a yield (0) and INFINITE are passed on as they are. XCL_SLEEP_HOLD=<ms> sets that length, 0 leaves the PC's Sleep. Tests a_sleep_does_not_count_the_time_the_title_is_held, a_sleep_stops_counting_when_the_title_gets_held, a_short_sleep_is_passed_on_while_the_title_is_held, a_sleep_of_a_title_not_held_takes_its_time.
  • 184 lines added, about 105 of them tests. With the rule taken out, the first two Sleep tests and the pso_async one fail ("back after 300.8 ms: the 300 ms held were counted", "a bind waits for a build, but the title is not held").

Tested

  • hardware: Intel Core i7-7700K (4 cores / 8 threads), 16 GB RAM, NVIDIA GeForce RTX 5080 16 GB (driver 610.47, 32-lane waves), Windows 10 22H2 (19045), DXC 1.9.2602.17, rustc 1.100.0 stable-x86_64-pc-windows-msvc; debug for the tests, release for the title.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on 9cdae10: 754 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_wave32_program_in_wave64_hardware, gpu_geometry_wave32_prefix_count_over_a_mask – no wave64).
  • game checked: the newer retail title of the README, XCL_NETWORK=0, scripted pad, binds waiting (no XCL_PSO_WAIT_MS). First, with this PR's first head (95299f4, every sleep held): main b8b1f49 + XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 (without XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 the title stops earlier, at its CopyFromSubresource call) against the same + the PR; 330 s runs, the two builds in turn, 3 rounds, release. Every run starts from the same DXIL and driver-blob cache: the folder is put back before each run to the state one earlier run of the first build left (3,051 files, 109 driver blobs).
round build the world's set-up begins end of the run dispatches skipped compute pipelines made
1 main + #684 93.2 s the title's stall exit at 164.4 s, 71.2 s after the set-up began 0 209
1 the same + 95299f4 148.7 s running at the limit (330 s), 181 s after the set-up began 0 288
2 main + #684 145.9 s the title's stall exit at 177.5 s, 31.6 s after the set-up began 0 291
2 the same + 95299f4 122.7 s running at the limit (330 s), 207 s after the set-up began 0 289
3 main + #684 111.8 s the title's stall exit at 185.5 s, 73.6 s after the set-up began 0 297
3 the same + 95299f4 157.0 s running at the limit (330 s), 173 s after the set-up began 0 298
run sleeps held the world's set-up begins end of the run time compared after the set-up frames draws dispatches compute pipelines made (of 10 s or more) dispatches skipped GPU wait timeouts
1 every sleep (95299f4) 151.4 s running at the limit 170 s 8 221 7287 115 (4) 0 0
1 100 ms or more (this head) 184.5 s running at the limit 146 s 20 361 7874 131 (2) 0 0
2 every sleep (95299f4) 152.5 s running at the limit 170 s 9 227 7375 120 (2) 0 0
2 100 ms or more (this head) 151.0 s running at the limit 170 s 12 262 7873 115 (3) 0 0
3 every sleep (95299f4) 149.8 s running at the limit 170 s 14 295 7733 131 (1) 0 0
3 100 ms or more (this head) 166.2 s running at the limit 164 s 14 316 7416 122 (2) 0 0
4 100 ms or more (this head) 151.0 s running at the limit 170 s 41 594 7752 128 (1) 0 0
  • So with only the longer sleeps held the title was running at the time limit in every run as well (4 of 4), nothing was skipped and no GPU wait timed out, and the load got as far or a little further in the same time. That is why this head has the narrower rule.
  • One more run of the first head is not in the table: it ended at 110.5 s, before the world's set-up, in an access violation in XCL's reading of a title texture (tiling::Chain::detile_level under title_textures::subresources). Sleep is not on that stack; one event, so I cannot say whether the timing had a part in it. It did not come in the 14 other runs of these three builds today (4 without the PR, 6 of the first head, 4 of this one).
  • What it does not do: the title is then slow, not dead. It waits in the bind for each pipeline (single builds of 43 to 182 s among them in the first table's runs, for programs of 262 KB to 787 KB of DXIL), and these runs end at their time limit with builds still going. Building the pipelines ahead and in parallel (D3D12.X: compute pipelines are built ahead of their first bind #889, D3D12.X: boost low-priority preload PSO workers on demand and priorit… #1007) and making each build cheaper (Recompiler: memory windows from the descriptor heap (no per-access switch) #680) shorten that; this keeps the title alive meanwhile.

Regression run (default settings)

main:

xcl-smoke v1
commit: b8b1f491ea5e075a82293f6ebefd8eceffc74de7
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1401 (PresentX 1401)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14319 MB

PR:

xcl-smoke v1
commit: 9cdae10f0bdf21b64a80958a87498b8f8124ac1d
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1383 (PresentX 1383)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14320 MB

A second round of the same two binaries: main 1405 frames, PR 1377. The PR's head is on b8b1f49, the commit of the main block; main has gone on to b7aa9f3 since (no file in common with this PR, and it merges cleanly).

Not tested

  • AMD and Intel GPUs; Windows 11.
  • Other titles: only this one was run. A title that is never held in a bind takes its sleeps of 100 ms or more through the same code, in steps of at most 20 ms (the 60 s regression runs above are such runs). A check that ticks with sleeps shorter than 100 ms is not covered unless XCL_SLEEP_HOLD is set lower.
  • No log line says that sleeps are being held: a bind's long wait shows in the log when its build ends. A line while the hold goes on (suggested in the Wine report above) is not in this PR.
  • SleepEx, waits with a timeout and the title's clocks are not taken. A check that reads a clock is not covered – this title's other route (a scope older than 300 s) is one; it did not come in these runs.
  • Sound and video while the title is held: a thread that waits with sleeps of 100 ms or more stands still with it, shorter polls go on. Not judged by ear or eye.
  • Whether the world is drawn once the pipelines are built: not reached in these runs.

AI use

  • Claude Code with Claude Fable 5.2: found the approach, wrote the change and its tests, ran the suite and the title runs on the machine named, and wrote this description.

Duplicate check (16:47 UTC, 24 Nov): no open PR takes the title's Sleep or keeps its stall check from counting a bind's wait; read #889, #1007, #828, #1442 (build ahead: they shorten the wait), #1273 (with XCL_PSO_WAIT_MS, a bind does not wait for a build behind the workers' queue), #1046 (the release of GPU waits), #967 and #1062 (what happens after the title's exit), and the closed #980 (stepped over the title's exit), #533 and #267 (bound the wait and skip).

🤖 Generated with Claude Code

@thehollowedone

Copy link
Copy Markdown

Independent overlapping-bind check on 95299f4, Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug.

I gated two synthetic pipeline builds and called the production kernelx::Sleep(60) from a third thread. A 500 ms bind returned its stand-in while the other bind was still held. Sleep stayed pending, then returned after the last bind was released and its 60 ms elapsed (664 ms total in this run). In a fresh process with XCL_SLEEP_HOLD=0, the same call returned in 61 ms while both binds were still waiting. The bounded pipeline also resolved to its built result once its gate opened.

Both runs and all three stock a_sleep_ tests passed. This covers synthetic scheduler timing. Retail and driver compile behavior were outside this run. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib lib kernelx: 35 passed, 0 failed.

Thanks!

@futurepro62

Copy link
Copy Markdown

Full-suite run to go with the subset check above. Tested exact head 95299f4 (on its base b8b1f49).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: a_bind_waiting_for_a_build_holds_the_title, a_sleep_does_not_count_the_time_the_title_is_held, a_sleep_stops_counting_when_the_title_gets_held, a_sleep_of_a_title_not_held_takes_its_time.

Not tested

  • AMD, 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.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of 95299f4 on main 930e8b4 + #684, 2 runs of 140 s each way of a retail title: without it the title's watchdog ended the run at 132.6 s and 131.6 s; with it the watchdog had not fired by 140 s in either run, and pipeline builds went on to the end. Presents did not come back within those 140 s.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09, 32-lane waves), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), DXC 1.9.2609.5, XCL_NETWORK=0, XCL_PSO_PRELOAD=0, XCL_PSO_WAIT_MS unset. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s through XCL_PRESS_AT. 95299f4 merged onto main 930e8b4 + #684 (e56dbc3) without conflicts; #684 is there because main alone faults in copy_from before this point.

Tested

  • cargo test --release -p xcl --lib for a_sleep and a_bind_waiting under Wine, on the merge: 4 passed, 0 failed.
930e8b4 + #684, run 1 / 2 the same + 95299f4, run 1 / 2
last 2 s with a present 102.6 s / 102.2 s 102.3 s / 100.4 s
the title's null write at game+0x23cf683 132.6 s / 131.6 s none by 140 s / none by 140 s
the run ended at the null write at the 140 s asked for
compute pipeline builds of 4 s or more that finished after 103 s 5 (the last at 129 s) / 0 7 (the last at 140 s) / 3 (the last at 133 s)
frames presented 2163 / 2152 2180 / 2115

The card's video memory was full (9.6 to 9.7 GB local) from about 76 s in all four, as in every run of ours that reaches the world load on this 12 GB card.

Read

  • pso_async.rs:145 (title_held) is one counter for the process, and kernelx.rs:1405 (title_sleep) checks it for every Sleep the title makes. So while one bind waits, every thread of the title that paces itself with Sleep stops, not only the stall check: in these runs that is the 38 s and more from the last present to the end of the run. Is that the intent, or should only the thread that counts the ticks be held? A thread that polls with Sleep(1) for streaming or sound would resume all at once when the build ends.
  • pso_async.rs:543: the hold covers the wait in resolve_wait with or without XCL_PSO_WAIT_MS, as the description says. With the limit unset, as here, nothing was skipped (0 draws and 0 dispatches skipped in both runs with the change), so what it buys is time: the builds that were cut off at 132 s without it went on.
  • These runs stop at 140 s, so they do not show whether the title goes on once the builds are done; the description's run does.

Not tested: past 140 s (the card would be measured, not the change); XCL_SLEEP_HOLD=0; the preload of #690 on; the rest of the test suite; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the tests and the four runs with XCL_PRESS_AT, compared the logs and wrote this report.

@jessenic

Copy link
Copy Markdown
Contributor

Test report for 95299f4, on the retail title's story load, without pre-built pipelines.

Tested

  • RTX 5070 Ti 16 GB (driver 610.88), Ryzen 7 9700X, 32 GB RAM (72 GB commit limit), Windows 11 Pro 26300, rustc 1.97.0, release build.
  • Tree: main 930e8b4 + this PR (95299f4) + XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 (e56dbc3), merged locally.
  • XCL_NETWORK=0, XCL_ACTIVITY=1, no XCL_PSO_WAIT_MS (binds wait). Scripted input (XCL_PRESS_AT), save past the first-run menus. Driver-blob and DXIL caches kept from earlier runs. No xcl pipelines pass.
  • cargo test -p xcl --lib with the PR's tests and fine_timer_makes_short_sleeps_short: 5 passed, 0 failed. The whole suite was not run.

Runs (the same build and caches; the off run uses XCL_SLEEP_HOLD=0)

run first #101 last present end
rule off 89.3 s ~100 s +0x23cf683 at 129.6 s
rule on, 330 s 82.3 s ~104 s still running at the limit, exit 0
rule on again, 420 s 97.6 s ~102 s still running at the limit, exit 0
  • Both rule-on runs: 0 draws and 0 dispatches skipped, no device removal, no GPU-wait timeout. Commit 27.9 → 29.7 GB.
  • Slow, not dead, as you describe. After the last present the title binds and builds its compute pipelines one after another. Bursts of up to ~6,700 dispatches follow each finished build, then 0–2 draws per 2 s.
  • Second rule-on run: 230 compute pipelines compiled in the run, 660 s of driver time in all. Per minute after 120 s: 25, 9, 17, 3 and 3 builds, the longest 28–94 s each. It was still building new ones at 420 s, and no frame was presented after ~102 s.
  • So on this card, without the offline pass, the rule keeps the title alive, but the world load needs far more than 7 minutes of on-demand builds.

Not tested

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the runs on this PC, read the logs and wrote this report.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#1286-xcl-dev#1291, xcl-dev#1294, xcl-dev#1296-xcl-dev#1297, xcl-dev#1300

Prevent background shader preloading and concurrent DXC/RADV compiles from exhausting host RAM under Wine, and integrate 11 open upstream PRs:
- dxc.rs & real.rs: check free physical RAM (ullAvailPhys.min(ullAvailPageFile)) under Wine instead of swap-inclusive ullAvailPageFile, avoid bypassing the guard after 60 s under Wine, and serialize giant (>= 4 MiB DXIL) driver compiles with BIG_COMPILES under Wine.
- pso_async.rs: cap background preload workers to 1 under Wine.
- title_textures.rs: use real::create_raw_fence in submit_on_title_queue and read coherent-window hash bytes safely via with_title_bytes.
- Integrate upstream PRs xcl-dev#968 (sparse::queue lock-free for late_release), xcl-dev#1286 (v_dot2_f32_f16 NEG_HI abs), xcl-dev#1287 (XMA >8 channels), xcl-dev#1288 (Sleep pauses during PSO bind waits), xcl-dev#1289 (pipeline stream bounds check), xcl-dev#1290 (root signature MAX_ARGS cap), xcl-dev#1291 (console UAV clears xcl-dev#53/xcl-dev#54), xcl-dev#1294 (shadowed PENDING accuracy), xcl-dev#1296 (16-bit compare low halves), xcl-dev#1297 (fence_x pre-cell signal arming), xcl-dev#1300 (log driver compute PSO refusal).

Verified on RX 9060 XT under GE-Proton11-14 (MemoryMax=12G, 80 s): committed RAM stays flat at 4830 MB (down from 27.6 GB OOM), 1493 frames shown, exit 0x0.

Assisted-by: Antigravity (Google DeepMind)
@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux, on a retail title.

Tested

Regression run

main (first run):

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

this PR:

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

The last main run: 1338 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 test suite on this head; native Windows; AMD.

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.

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Verified head 95299f47ddc4dc842045f4c1b48cc7910eb7aa68 on Windows 11 / NVIDIA RTX 5080 (DXC 1.9.2602.17, Rust MSVC, debug build, clean worktree):

  • cargo build --workspace + cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored (0 new compiler warnings).

Not tested: AMD, Linux/Wine, retail smoke (scripts/smoke.ps1).
AI use: T3 Code (Antigravity / Claude Sonnet 5.5) ran the build and tests on our RTX 5080 and drafted this report.

@imnicho

imnicho commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@Royalflamejlh thanks for the runs and for reading the diff. On your question:

Yes, as written it is every Sleep of the title, on purpose: XCL does not know which thread counts the ticks, so the rule is "the time a bind is held is not the title's time" for all of them. The cost you name is real. A thread that polls with short sleeps (streaming, sound) stands still for the hold as well and gets going again all at once; the description's "Not tested" only says that sound and video were not judged.

A narrower rule is possible without knowing the thread: pass a short sleep on as it is and hold only a sleep that is long enough to be a wait for time. @sander110419's local version of the plan did that (100 ms or more) and their title stayed alive under Wine for 930 s after the set-up, so a threshold does not have to cost the fix. What I do not know is whether it changes how the load goes on (pipelines built and dispatches in the same time), or lets another time-out of the title through.

I will measure it here, the PR as it is against a variant that holds only sleeps of 100 ms or more: same main + #684, the same cache start state for every run, three rounds in turn. I will post the numbers in this thread and change the PR to the narrower rule if it keeps the title alive in every run and the load is not worse.

AI use: Claude Code with Claude Fable 5.2 wrote this reply.

anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
…d harden compute/sparse paths

- crates/xcl/src/hle/d3d12x/pso_async.rs (fixes 1 MiB thread stack overflow / deadlock seen alongside ivall#611):
  Add urgent_queue() spawning dedicated 64 MiB-stack xcl-pso-wait-* workers and offload unstarted jobs in resolve_wait_for(..., None) instead of executing job() inline on the title's 1 MiB stack threads, avoiding silent Wine thread deaths without skipping compute dispatches (ivall#675, ivall#891). Guard build() with std::panic::catch_unwind plus a Drop completion guard so panics always call complete(p, 0) and notify waiters.
- crates/xcl/src/hle/d3d12x/pso_async.rs & kernelx.rs (ivall#1288, ivall#505, ivall#232):
  Track active pipeline bind waits via HELD / title_held() and export kernelx::Sleep backed by title_sleep() so Sleep skips counting time spent blocked on background PSO compilation (XCL_SLEEP_HOLD=0 disables).
- crates/xcl/src/hle/d3d12x/bind.rs, device_x.rs & real.rs (ivall#1195):
  Track console compute PSOs (CONSOLE_COMPUTE) and Dispatch-capable command signatures (DISPATCH_SIGNATURES) so ExecuteIndirect skips dispatches against untranslated console compute stand-ins or fallbacks while still forwarding native PC compute pipelines.
- crates/xcl/src/hle/d3d12x/sparse.rs (ivall#1419, ivall#1277):
  Extract wait_fence_until() to ResetEvent before SetEventOnCompletion and re-check GetCompletedValue() until target or deadline so stale signals on the reusable auto-reset event cannot end waits early; bail cleanly from upload_dirty() if ring fence reclaim times out instead of holding STATE indefinitely.
- crates/xcl/src/gpu/recomp/emit.rs & tests.rs (ivall#1361):
  Split GFX10.30 SADDR == 0x7F (ST immediate-only 0u base) from SADDR == 0x7D (v[ADDR] base) in Em::scratch and update ENC_FLAT_SCRATCH VADDR test encodings to 0x7D.

Assisted-by: Antigravity (Gemini 4 Neon)
@HKEY-Funk-Machine

Copy link
Copy Markdown

Test report: #1288 (95299f4) with #751 (1a480bc) on AMD RDNA4, Windows: the watchdog no longer fires, and the intro renders

Tested

Why #751 is in the tree: on a warm run of plain main, the run died at 1m14s with 0xC0000005 in VCRUNTIME140.dll (memcpy) ← title_textures::subresources ← a subresources_on worker, which is the fault #751 fixes. With #751 alone, the run went past that point and hit the usual +0x23cf683 watchdog at 2m50s.

main (cold) main (warm) + #751 (warm) + #751 + #1288
Result watchdog at 2m22s memcpy fault at 1m14s watchdog at 2m50s no crash; killed by my 15-min timeout
Frames presented none shown (2421 by the title's count) — — first frame at 3840×2160, 1500 frames at ~30 fps

After 1500 frames, presents stop for the rest of the run (about 10 minutes). During that time the log shows 85 compute PSOs taking 554 s of driver time in total, the longest 47.1 s. So the title is held in binds for pipelines the driver is still building, as #1288 describes, and its stall check no longer counts that time. #1288 does what it says on AMD. The remaining wall is the driver's compile time for these programs, the subject of #1269.

Not tested

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title, extracted counts and timings from the XCL logs, symbolised the memcpy fault against xcl.pdb, and drafted this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored.

Thanks!

@HQasper

HQasper commented Nov 24, 2026 •

Copy link
Copy Markdown

RTX 5090 test of #1288 (95299f4): the watchdog no longer ends the run, but presents stay at 0 from 82 s to 300 s

Setup

  • NVIDIA GeForce RTX 5090 (32 GB, 32-lane waves), driver 32.0.16.2124; AMD Ryzen 9 9950X3D; Windows 11 Pro 26300
  • rustc 1.100.0, release builds; DXC 1.9.2602.17 (21d28f72)
  • Retail title 1.0.2.1 (TitleId 7952987A), first-run setup already done (saves present)
  • Every run: XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PRESS_AT=30:A,40:A, scripts/smoke.ps1 -Seconds 300; no XCL_PSO_WAIT_MS

Runs

run commit caches end frames presents stop peak commit
main 1 930e8b4 DXIL warm, driver blobs partly +0x23cf683 write at 0x0, 110.1 s 1756 ~82 s 28.8 GB
main 2 930e8b4 warmer +0x23cf683, 110.4 s 1792 ~82 s 29.5 GB
#1288 1 95299f4 warm 0xC0000005 at 46.7 s in XCL (see below) 1263 – 16.1 GB
#1288 2 95299f4 warm ran to 300 s, no crash 1767 ~82 s 31.6 GB
#1288 3 95299f4 + 425 compute pipelines from xcl shaders --precompile --only cs --pipelines ran to 300 s, no crash 1765 ~82 s 32.4 GB

What the title waits for in the #1288 runs

Tests on 95299f4

  • cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored (19 test binaries)
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)
  • The PR's own tests (a_sleep_*, a_bind_waiting_for_a_build_holds_the_title) pass

Not tested

Smoke blocks (same title, 300 s)

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5090
title: game files
seconds: 300
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 2
peak commit: 29512 MB
xcl-smoke v1
commit: 95299f47ddc4dc842045f4c1b48cc7910eb7aa68
gpu: NVIDIA GeForce RTX 5090
title: game files
seconds: 300
exit: 0x0
frames shown: 1765 (PresentX 1765)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 32429 MB

AI use: Claude Code with Claude Opus 5.5 ran the builds, tests and game runs on this machine, read the logs and wrote this report.

A bind of a pipeline still being built holds the title's thread until the build is
done (pso_async::resolve_wait): a console title never waits there. A retail title's
own stall check is a thread that ticks once a second with Sleep and ends the process
after 30 ticks without a sign of its main thread. While the driver built the compute
pipelines of its world the main thread was held in binds, and the title ended itself
about 30 s after the world's set-up began (ivall#505, ivall#232).

XCL now takes the title's Sleep (it comes in through api-ms-win-core-synch): a sleep
of 100 ms or more returns after its time has gone by in which no bind was waiting for
a build (pso_async::title_held), taken in steps of 20 ms. A shorter sleep is a poll
and is passed on as it is, like a yield and an endless sleep: a thread that paces
streaming or sound with short sleeps goes on while a bind waits. XCL_SLEEP_HOLD=<ms>
sets that length; 0 leaves the PC's Sleep as it is.

Nothing of the title is changed and no dispatch is skipped; a title that is not held
sleeps as before.

Tests: a_sleep_does_not_count_the_time_the_title_is_held,
a_sleep_stops_counting_when_the_title_gets_held,
a_short_sleep_is_passed_on_while_the_title_is_held,
a_sleep_of_a_title_not_held_takes_its_time,
a_bind_waiting_for_a_build_holds_the_title.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@iLucasRT

Copy link
Copy Markdown

Test report: #1288 (95299f4) on AMD RDNA3, Windows: the watchdog no longer fires (2 of 2 runs); presents do not come back within 300 s, and audio decoding nearly stops

Tested

  • RX 7900 XTX 24 GB (RDNA3, native wave64), driver 32.0.32029.2010 · Ryzen 7 5800X3D · 64 GB RAM · Windows 11 Pro 26300 · rustc 1.100.0, DXC 1.9.2602.17, release builds, game on NVMe
  • main b7aa9f3 against b7aa9f3 + this PR's diff (95299f4, applied cleanly with git apply, uncommitted). Without XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 and D3D12.X: title texture reads outside the coherent window use the safe copy #751.
  • Retail title 1.0.2.1, XCL_NETWORK=0, XCL_ACTIVITY=1, XCL_RUN_SECONDS=300, A every 5 s (XCL_PRESS_A_AT), binds waiting (no XCL_PSO_WAIT_MS).
  • Every run starts from the same title data and XCL caches (DXIL, driver blobs), put back from one earlier run of main. Order: main, PR, PR, main.
  • The PR's 4 tests and fine_timer_makes_short_sleeps_short pass on that tree (5 passed, 0 failed).
main r1 main r2 PR r1 PR r2
end +0x23cf683 at 112.7 s +0x23cf683 at 115.7 s ran to 300 s, exit 0 ran to 300 s, exit 0
last 2 s interval with a present ends 84.1 s 86.1 s 84.1 s 82.1 s
frames presented 1514 1557 1507 1503
dispatches after 88 s 244 583 8020 6902
compute pipelines made (from kept blobs) 111 (9) 115 (9) 254 (9) 308 (10)
driver builds of 1 s or more 17 11 66 26
driver time in all (sum over threads) 89.9 s 31.7 s 420.4 s 108.5 s
peak commit / local VRAM 31.0 / 15.7 GB 32.8 / 15.9 GB 33.2 / 15.9 GB 35.1 / 17.0 GB
xapu packets decoded (report.json) 45465 72905 3176 2973
  • main: the stall exit comes 28.7 s and 29.6 s after the last present. With the PR it does not come in either run; pipelines are still being built at the end (last one at 296 s). No present after 82–84 s. No device removal, no failed pipeline, no GPU-wait timeout. Dispatches skipped: 0 in the last counter line of each log (78–153 s; it does not cover the rest).
  • DirectStorage requests that failed (0x89240009, 54–78 s): 259 and 1686 on main, 5516 and 15 with the PR. They vary too much between equal runs to say anything about the PR.
  • Driver times drop between the first and second round of both builds; the AMD driver's own disk cache was not put back between runs, so they should not be compared across builds.
  • Sound: up to about 81 s all four runs decode ~50 Opus packets/s. On main this goes up to ~1300–1600 (r1) and ~1900–2700 (r2) packets/s until the crash. With the PR there are no more xapu lines after 81 s, and ~430–620 more packets in total by 300 s. I did not listen to these runs; this is the counter only. It is in line with the "threads that pace themselves with Sleep stand still" point above.
  • The heavy programs of PR r2 come in the same order as in @HQasper's report (430,604 / 359,908 / 411,296 / 339,724 / 423,444 B of DXIL, first builds at 234–297 s). My run ends before a second round could show.

Not tested

AI use: Claude Code (Claude Opus 5.5) read the diff, built the trees, ran the unit tests and the runs on this machine, read the logs and wrote this report.

@imnicho

imnicho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Update: it is up as #1782. After seeing #1747 I widened it: the guard covers the whole submission (XCL's uploads and tile mappings before the lists as well as the PC ExecuteCommandLists), a texture's placement, and a pipeline built in the title's call. Suite 890 passed, 0 failed; regression pair 1398 / 1397 frames.


@raylitebull thank you for merging, and for the edge case: a title thread blocked inside the driver's own call is a hold this rule does not see, because title_held() only knows the bind's wait in resolve_wait.

Plan for a small follow-up PR (written, its unit test passes, the suite and the regression pair still to run):

  • pso_async: pc_call() gives a guard for a call into the PC's D3D12 made on one of the title's threads. A call that has lasted 250 ms or more holds the title (title_held()), a shorter one does not, so a normal submission changes nothing.
  • real.rs: the guard is taken around the PC ExecuteCommandLists in q_execute_command_lists, and around the driver's pipeline creation in finish_pso when it runs in the title's own call (no stand-in; a worker's build is left out).

One thing would help me aim it: in the thread state at your abort, which XCL function was above D3D12Core.dll on the submission thread – q_execute_command_lists, a pipeline creation (finish_pso / dev_create_…pipeline_state), or something else (a Map, an upload in title_textures::refresh)? If it was something else, I would rather put the guard there than guess.

I cannot reproduce it here (NVIDIA, where the long waits are all in resolve_wait), so the PR will say what I measured on this card (no change in the regression runs, the title run as before) and that the AMD case rests on your trace. If you can run the branch once on the RX 9070 XT, that would be the real test; I will post it here when the suite is through.

AI use: Claude Code with Claude Fable 5.2 wrote the change and this reply.

wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…cl-dev#1288 Sleep hold, xcl-dev#1195 ExecuteIndirect skip)

Conflicts:
- tests.rs memory_windows_reject_out_of_uma_aliasing: xcl-dev#1693 builds the switch /
  heap form through direct_or (the direct translator with XCL_DIRECT_DXIL=1);
  the flat form of our flat window loads stays a DXC compile, as in
  gpu_sparse_vram_descriptors_buffers_and_xmem.
- pso_async.rs resolve_wait: xcl-dev#1288's `Held` guard (pso_async::title_held, which
  kernelx::Sleep does not count) goes into our resolve_wait_in after note_use, so it
  covers the bind's whole wait in every form: XCL_PSO_WAIT_MS /
  XCL_PSO_WAIT_MS_GRAPHICS budgets, XCL_PSO_SKIP_HUGE, a build on the binding thread.
  Its test calls our three-argument resolve_wait_for.

xcl-dev#1195 merged without conflict: in execute_indirect our skip of a pending stand-in or
a two-pass pipeline comes first, then xcl-dev#1195's skip of a Dispatch signature with an
untranslated console compute pipeline (a failed build's stand-in, the fallback of a
console shader that failed), which we sent to the PC call, then the PC-pipeline block
with 515b576's gpu_profile::end(.., breadcrumb). xcl-dev#1195's skip leaves a breadcrumb, as
our other ExecuteIndirect skips do.
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
…reads

A title's Sleep does not count the time a bind waits for a pipeline still being
built (pso_async::title_held). A title's thread can also be kept inside a call that
takes no time on the console: a submission, where XCL uploads and maps tiles before
the lists and a driver can compile in them, a texture's placement on reserved
memory, or a pipeline built in the title's call because it got no stand-in. On an
AMD RX 9070 XT a retail title's stall check still ended it after 30 s without a
present, with its submission thread inside the driver and no bind waiting (reported
on xcl-dev#1288).

pso_async::pc_call() is a guard for such a call. A call that has lasted 250 ms or
more holds the title, a shorter one does not, so an ordinary submission changes
nothing. It is taken for the whole of q_execute_command_lists, in
create_placed_resource_x, and around the driver's pipeline creation when that runs
in the title's own call (a worker's build holds nobody).

Test: a_long_pc_call_holds_the_title.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
imnicho added a commit to imnicho/xcl that referenced this pull request Nov 25, 2026
A title's Sleep does not count the time a bind waits for a pipeline still being
built (pso_async::title_held). A title's thread can also be kept inside calls that
take no time on the console: a submission, where XCL uploads and maps tiles before
the lists and a driver can compile in them, a texture's placement on reserved
memory, or a pipeline built in the title's call because it got no stand-in. On an
AMD RX 9070 XT a retail title's stall check still ended it after 30 s without a
present, with its submission thread inside the driver and no bind waiting (reported
on xcl-dev#1288) - and again with 16 384 texture placements of 1 - 50 ms each in 29 s,
none of them long by itself (reported on xcl-dev#1782).

pso_async::pc_call() is a guard for such a call. While it lasts the title is held
once the PC calls since the last frame shown, this one included, have taken 250 ms:
one long call, or many short ones in a row. The title's own time between the calls
still counts, and a frame shown starts the sum again, so a title that shows its
frames is not held by its submissions. The guard is taken for the whole of
q_execute_command_lists, in create_placed_resource_x, and around the driver's
pipeline creation when that runs in the title's own call (a worker's build holds
nobody).

Tests: a_long_pc_call_holds_the_title,
short_pc_calls_between_two_frames_hold_the_title.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.