Repository navigation
kernelx: Sleep does not count the time a bind waits for a pipeline build - #1288
Conversation
|
Independent overlapping-bind check on I gated two synthetic pipeline builds and called the production Both runs and all three stock |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Full-suite run to go with the subset check above. Tested exact head Tested
Not tested
AI use
|
|
Linux (Wine + vkd3d-proton) + NVIDIA test of 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, Tested
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
Not tested: past 140 s (the card would be measured, not the change); AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the tests and the four runs with |
|
Test report for 95299f4, on the retail title's story load, without pre-built pipelines. Tested
Runs (the same build and caches; the off run uses
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. |
…vall#1286-ivall#1291, ivall#1294, ivall#1296-ivall#1297, ivall#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 ivall#968 (sparse::queue lock-free for late_release), ivall#1286 (v_dot2_f32_f16 NEG_HI abs), ivall#1287 (XMA >8 channels), ivall#1288 (Sleep pauses during PSO bind waits), ivall#1289 (pipeline stream bounds check), ivall#1290 (root signature MAX_ARGS cap), ivall#1291 (console UAV clears ivall#53/ivall#54), ivall#1294 (shadowed PENDING accuracy), ivall#1296 (16-bit compare low halves), ivall#1297 (fence_x pre-cell signal arming), ivall#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)
|
A regression run under Wine on Linux, on a retail title. Tested
Regression run main (first run): this PR: The last Not tested
AI use
|
|
Verified head
Not tested: AMD, Linux/Wine, retail smoke ( |
|
@Royalflamejlh thanks for the runs and for reading the diff. On your question: Yes, as written it is every 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 AI use: Claude Code with Claude Fable 5.2 wrote this reply. |
…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)
|
Test report: #1288 ( Tested
Why #751 is in the tree: on a warm run of plain
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 |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
RTX 5090 test of #1288 (
|
| 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 |
- On
main,ListX #101is first called at 62–78 s, presents stop at ~82 s and the title's watchdog fires about 30 s later in both runs. - With kernelx: Sleep does not count the time a bind waits for a pipeline build #1288 the watchdog did not fire in either full run (300 s each). The title still never got past the world load: 0 presents from ~82 s to 300 s, with only 0–13 dispatches per 2 s. So on this card kernelx: Sleep does not count the time a bind waits for a pipeline build #1288 turns the crash into a stall that did not end within 300 s.
- kernelx: Sleep does not count the time a bind waits for a pipeline build #1288 run 1 ended at 46.7 s, right after the story load began, with
0xc0000005inVCRUNTIME140.dll+0x1c45a(read at0xc49059f00) on atitle_textures::subresources_onworker:tiling::Chain::detile_level(tiling.rs:438) ←title_textures::subresources(title_textures.rs:1182). That is the in-place title memory read that D3D12.X: title texture reads outside the coherent window use the safe copy #751 replaces. I don't think kernelx: Sleep does not count the time a bind waits for a pipeline build #1288 causes it: the code is not touched, and the same build ran clean twice after.
What the title waits for in the #1288 runs
- Run 2 (blobs partly warm): after 82 s, one compute pipeline after another is built in the driver, each taking 1–33 s (52 builds over 1 s; the biggest is 928,928 B DXIL in 33.4 s).
- Run 3 (warmer, 215 pipelines from disk blobs): from 120 s to 297 s, one thread builds 8 compute programs (430,604 / 359,908 / 411,296 / 339,724 / 423,444 / 352,852 / 404,008 / 332,644 B DXIL, 4.8–8.1 s each) and then the same 8 sizes again, in the same order. The driver-blob directory has two files with different DXIL hashes for each of these 8 lengths (one from each round). So the second round is not a cache miss. A shader dump shows that they are the title's own permutation pairs: two console programs whose code is the same except for the inline multiplier of one
s_mul_i32(e.g. 23 vs 31) and the header nop literals. Each one needs its own driver compile (details in Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505: Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 (comment)). xcl shaders shaders.rpf --precompile --only cs --pipelinessaved 425 pipelines in ~45 min, then stayed on a single driver compile for over 30 min at 85 GB private / one core, so I stopped it (it can be resumed). This matches what D3D12.X: compute programs of 4 MB DXIL or more build in their own queue #1278 says about the screen-probe programs.
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
- kernelx: Sleep does not count the time a bind waits for a pipeline build #1288 rebased onto
930e8b4(the PR head is onb8b1f49, so it doesn't have930e8b4's copy-scratch fix); runs longer than 300 s; AMD;XCL_PSO_WAIT_MStogether with kernelx: Sleep does not count the time a bind waits for a pipeline build #1288; D3D12.X: a bind does not wait for a pipeline behind the workers' queue #1273 / D3D12.X: compute programs of 4 MB DXIL or more build in their own queue #1278 on this machine.
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>
|
Test report: #1288 ( Tested
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. |
95299f4 to
9cdae10
Compare
|
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 @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 Plan for a small follow-up PR (written, its unit test passes, the suite and the regression pair still to run):
One thing would help me aim it: in the thread state at your abort, which XCL function was above I cannot reproduce it here (NVIDIA, where the long waits are all in AI use: Claude Code with Claude Fable 5.2 wrote the change and this reply. |
…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.
…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>
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>
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
Sleepand 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 inresolve_waitfor a pipeline still being built (a counter around the wait, with or withoutXCL_PSO_WAIT_MS). Testa_bind_waiting_for_a_build_holds_the_title.crates/xcl/src/hle/kernelx.rs:Sleep(a title imports it throughapi-ms-win-core-synch, which XCL resolves to kernelx): a sleep of 100 ms or more returns aftermsof time in which the title was not held, taken in steps of at most 20 ms; a shorter sleep, a yield (0) andINFINITEare passed on as they are.XCL_SLEEP_HOLD=<ms>sets that length,0leaves the PC'sSleep. Testsa_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.Sleeptests and thepso_asyncone 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
stable-x86_64-pc-windows-msvc; debug for the tests, release for the title.cargo build --workspace && cargo test --workspace -- --test-threads=4on9cdae10: 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).XCL_NETWORK=0, scripted pad, binds waiting (noXCL_PSO_WAIT_MS). First, with this PR's first head (95299f4, every sleep held):mainb8b1f49+ 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 itsCopyFromSubresourcecall) 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).main+ #68495299f4main+ #68495299f4main+ #68495299f425c6f7eand9a272d4a build or a compile the title waits for goes on at once onmain; the runs above have both. Before the rebase, on47efa2e+ XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, it was the same: the title's exit 32.1 s and 31.5 s after the set-up in two runs without the rule, and running at the limit in the one run with it.resolve_wait: Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 (comment)). @sander110419 ran a local implementation of the plan on Linux / Wine: the title did not end itself in 930 s after the set-up, 0 dispatches skipped (Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 (comment)).mainb8b1f49+ XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, in turn, 330 s runs from the same cache start state as above. What the load did is counted over the 170 s after the set-up began, or up to the time limit where that came first:95299f4)95299f4)95299f4)tiling::Chain::detile_levelundertitle_textures::subresources).Sleepis 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).Regression run (default settings)
main:
PR:
A second round of the same two binaries:
main1405 frames, PR 1377. The PR's head is onb8b1f49, the commit of the main block;mainhas gone on tob7aa9f3since (no file in common with this PR, and it merges cleanly).Not tested
XCL_SLEEP_HOLDis set lower.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.AI use
Duplicate check (16:47 UTC, 24 Nov): no open PR takes the title's
Sleepor keeps its stall check from counting a bind's wait; read #889, #1007, #828, #1442 (build ahead: they shorten the wait), #1273 (withXCL_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