Repository navigation
runtime: a guest Sleep sits out host-only pipeline compiles, so the title's startup hang check survives a cold boot (RT-5 follow-up, stop 18) - #7858
Conversation
…e startup hang check) The retail title's startup hang check loops on Sleep(1000) and ends the process after 30 rounds without progress from the main thread; a round that returns more than 2 s late starts its count again. A cold driver compile of the XboxBvhBuilder compute pipelines takes 25 to 60 s on the title's thread, so a first boot ended about 31 s in. src/host_stall.h keeps a ledger of host-only stalls. The layer marks the vkCreateComputePipelines call of a compute pipeline state as one, and shims/host_stall.cpp serves Sleep for mapped images: the host's Sleep, which does not return while a stall is open and lasts as much longer as stalls overlapped it. A Sleep no stall overlaps is unchanged. host_stall_test covers the ledger and the served Sleep on synthetic threads. docs/retail_boot_chain.md section 5 has the measurement. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested
AI-assisted (Claude Code). |
|
Tested 4a51079 on NVIDIA GeForce RTX 3060 (driver 617.14), Windows 11 26H2 (26300), MSVC 19.44.35229 (v143) + Ninja, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Independent timing comparison on native Windows, RTX 4080, MSVC 19.44, SDK 10.0.26100 and Vulkan SDK 1.4.363. This measures the existing pipeline-cache path; it is not a validation of this PR's Sleep implementation. The two runs used identical runtime and TLS-helper bytes, the host Sleep, the same translated catalog, and the same protected offline launcher. The sole runtime-input change was adding a prepared
The seed was produced by the existing Base: All 55 imported Winsock/WinHTTP entries remained bound to offline shims. All protected game-file metadata and all 17 PE hashes were unchanged, as were the runtime, TLS helper and cache seed. No assertions were skipped. Only aggregate measurements and API names are reported here. |
# Conflicts: # docs/README.md
|
Retail boot test (RT-5): own 1.0.2.1 copy, Windows 11, i9-12900KF, RTX 3070 (NVIDIA 617.42), MSVC 2022 RelWithDebInfo, Result: clears the startup hang check (stop 18) on NVIDIA. Without it, with this PR's stop 17 fix in (#7235): a write to address 0 at 32.4 s, the same with and without Cherry-picked AI-assisted test run. |
|
Independent synthetic Windows timing at |
|
Data point from a retail boot on AMD, in case it helps others who hit the startup hang check (I have not applied this PR yet). Setup: own 1.0.2.1 copy, Windows 11 (26200), Ryzen 7 9800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), Finding: implicit Vulkan layers on the machine make the cold boot trip the hang check.
One run without layers so far; I have not yet isolated which layer is responsible (Fossilize is my first suspect). Suggestion: AMD testers could try |
|
Thanks, useful data point. This PR targets exactly that stop: it holds the guest |
|
Tested 631e531 on Windows 11, AMD Radeon RX 7800 XT (RDNA3), AMD driver 26.7.1 (Vulkan), MSVC 14.43 RelWithDebInfo, own 1.0.2.1 copy, LEONIDA_D3D12=vulkan, LEONIDA_SHADERS on a full local translation (26,573 modules), pipeline_cache.bin seeded from spirv/bvh with vk_pipeline_check (52 pipelines; LoadInstances alone took 45.5 s to compile on this GPU). Base: main@7ec305678 + a local merge of the RT-5 stack (#4313 and #6582 rebases, #4348, #7078, #6954, #2490, #6953, #7075, #7021, #7066, #7052, #7235, #7110, #7115, #7163, #7201, #7286, #7323, #6279, #7009, #7111, #7099, #7240, #7330, #7403, #7290).
This is the AMD boot timing run #7586 asks for: even with the seeded BVH cache, the title's thread was held about 37 s on this GPU, and with this PR the hang check no longer fires. AI-assisted (Claude Code). |
|
Independent verification on AMD (RX 7900 XTX, retail 1.0.2.1, the boot stack above): without the change, the title's hang check fires at t≈32.1 s on this machine too — the same 32.4 s your RTX 4080 measured — and on AMD the trigger is aggravated by |
|
Tested Setup: Windows 10 22H2 (19045), Radeon RX 6700 XT (Navi 22, gfx1031), AMD driver 32.0.21045.29003, Ryzen 5 5600X, MSVC 14.42 RelWithDebInfo, Vulkan SDK 1.4.363.0,
Counts and timings only; no game data, logs or traces. AI-assisted (Claude Code). |
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
|
checked: #7858631e531 | with: AI-assisted (Claude Code). |
|
Independent Intel UHD 770 validation (32.0.101.7088, Windows 11, i7-14700K): the retail startup reaches the literal write-to-null at 32.06 s after 1,640 D3D12 calls, matching the cold-compile watchdog signature, not an Intel driver AV. Outside the title, the actual runtime Vulkan PSO builder compiled 49 of the 52 BVH shaders (the smaller modules) successfully in 46.2 s and saved a device-specific cache. A warm-cache retest still needs the remaining three. I did not skip or patch the title assertion. |
|
Thanks, that confirms the stop is the hang check on Intel too. If you get a chance, a cold run with this PR applied would show whether holding the title's Sleep during those compiles gets the UHD 770 past 32 s (on an RX 7800 XT it did, after a 37 s hold). AI-assisted. |
|
Warm-cache A/B follow-up on the same Intel UHD 770: created all 52 actual BVH compute PSOs (the largest alone took 118.45 s cold). The title loaded the 16,284,980-byte Intel cache; nine instrumented large BVH compiles now finished in 0 ms each. It passed the previous cold stop and reached 1,656 graphics calls, then a different title breakpoint with E_NOTIMPL in the error path, before the first present. No timer change or assertion skip. The cache removes the cold-compile barrier in this case; it does not make the title playable. |
fladit123
left a comment
There was a problem hiding this comment.
Independent Windows concurrency and timing review — REQUEST CHANGES
Tested head: 631e53120fa12d58ee30bc1601d72756af9bead7
Comparison baseline: dfe4e4ad3acfc7fe804e299e643ab06a88f1c8a7
Environment: Windows 11 build 26300, MSVC 19.51, RTX 4060, NVIDIA 610.88, Vulkan SDK 1.4.363.1.
The existing host_stall_test passes all 23 checks. The synthetic watchdog also resumes detecting lack of progress after the final stall.
However, additional independent probes identified three issues that I recommend addressing before merging.
1. Process-wide Sleep interception can prevent unrelated thread progress
In a bounded synthetic test, the thread holding the stall marker waited up to 180 ms for an acknowledgement from another thread using Sleep(10).
- Baseline: acknowledgement arrived within the deadline.
- PR: the wait expired; acknowledgement arrived only after the stall ended.
SleepEx(10, FALSE)control: acknowledgement arrived within the deadline on both versions.
This demonstrates a circular progress dependency with a safety timeout. An unbounded dependency of the same shape could deadlock.
I did not observe a permanent deadlock in the Vulkan driver or retail title.
Please consider a narrower interception policy that preserves unrelated thread progress, together with a strategy for detecting a host compilation that never returns.
2. Late native wake-ups can be compensated twice
Ledger::wake_time() uses the actual host wake-up time plus the accumulated stall duration. If the native wake-up was already delayed, this can charge part of that delay twice.
In a controlled probe:
- Requested sleep: 15 ms.
- Native wake-up: approximately 185 ms.
- Covered stall time: 185 ms.
- Guest return: approximately 386 ms.
- Expected completion under the documented non-stalled-time contract: approximately 200 ms.
A deterministic virtual-clock example confirms the discrepancy:
| Event | Time |
|---|---|
| Sleep(1000) starts | 0 s |
| Stall ends / native thread resumes | 6 s |
| Required non-stalled budget completed | 7 s |
| Current calculated deadline | 12 s |
Please capture the starting timestamp together with the ledger mark and compensate only for the remaining non-stalled sleep budget.
3. The stall scope also covers pipeline-cache initialization
The scope is constructed before evaluating device_.pipeline_cache() as a function argument.
Instrumented Vulkan calls on RTX 4060 showed:
| Vulkan call | Baseline: stall active | PR: stall active |
|---|---|---|
| vkCreatePipelineCache | 0/1 | 1/1 |
| vkCreateComputePipelines | 0/2 | 2/2 |
| vkCreatePipelineLayout | 0/2 | 0/2 |
The marker closed correctly after successful compilation and a synthetic driver error. No Khronos validation errors were observed.
If the intended scope is specifically driver pipeline compilation, retrieve the pipeline cache before constructing Scope. This also excludes cache-seed loading and waiting inside std::call_once. Otherwise, please explicitly document and justify the broader scope.
Additional observations
- Overlapping and nested stalls were counted correctly.
- Cross-thread completion preserved the remaining active marker.
- No internal lost wakeup was reproduced.
- Sleep(0), Sleep(INFINITE), SleepEx and the other tested synchronization bindings behaved as expected.
- The synthetic watchdog fired again after the last stall.
However, a virtual-clock model with recurring stalls accumulated 30 seconds of non-stalled time over 63 seconds of wall time without triggering the watchdog, because each late round restarted its counter. Thus, preservation of hang detection is conditional on the stall pattern.
Verdict: REQUEST CHANGES.
The startup improvement reported by other contributors is valuable. My concern is the broader synchronization contract and the possibility of masking or introducing genuine progress failures.
I recommend addressing the unrelated-thread dependency, correcting deadline accounting and narrowing or explicitly defining the compilation scope, with deterministic regression tests.
Synthetic fixtures only. No proprietary game files, repository changes or assertion bypasses. AI-assisted review and testing with OpenAI Codex.
…ly pipeline compiles, so the title's startup hang check survives a cold boot (RT-5 follow-up, stop 18) Squashed from ItsNotRexed#7858 by throny, head 4a51079 (security scan PASS). Conflict in scripts/build_runtime.ps1 only: the file list keeps ItsNotRexed#7516's xbox_bvh_builder.cpp and adds host_stall.cpp.
…ompiles are host stalls Slot 57 now creates every pipeline as one pipeline state stream through the proxy's create_pso_from_stream (ItsNotRexed#7759), which keeps the stream on the PSO, so slot 55 can derive from slot-57 pipelines; the stub request goes the same way. A device without ID3D12Device2 refuses slot 57 as it refuses slot 86. The Vulkan device's vkCreateGraphicsPipelines now runs inside the same rt::host_stall::Scope as the compute compile (ItsNotRexed#7858), so a guest Sleep sits out the slot-57 compile burst instead of tripping the title's hang check. xs_native_pso_test: the mock answers only PC slot 47, its root signature and pipelines are COM objects with private data, and a new case derives through slot 55 from a slot-57 pipeline.
The Scope around vkCreateComputePipelines was constructed before device_.pipeline_cache() was evaluated as an argument, so the first call also counted vkCreatePipelineCache, the seed load and a second thread's wait inside std::call_once as a host-only stall. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tside stalls, and a stall counts for at most 60 s - Only a Sleep of 1,000 ms or more is held; a shorter one is a poll and stays the host's, so a thread the stall's holder waits for goes on. - Ledger::owed replaces wake_time: the sleep's start time is read with the ledger mark, and a sleep returns once its length has passed outside stalls. A late host wake-up is no longer charged twice. - Stalls are tracked one by one and each counts for at most kStallLimit (60 s). After that held Sleeps return, the time counts as the title's, and the shim prints one line. - host_stall_test: the ledger, the limit, sleeps and a stand-in hang check on a virtual clock, and the served Sleep on real threads. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…es that take turns One compute pipeline compile measured here took 50 s, so 60 s left no room for a slower machine. host_stall_test gains the compile-gate order: a compiler that waits for its turn opens the stall only around its driver call, no stall time is counted between two turns, and Sleep(1) polls and a Sleep(1000) go on there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@fladit123 all three points and the note are changed at
AI-assisted (Claude Code). |
|
A measured side effect of the global gate on a cold cache, from the retail 1.0.2.1 boot. Base: GitHub main + the boot PRs + this PR + #7021 + #9137 + #9276/#9014 + #9586. RTX 5060 Ti, driver 621.01. AI-assisted. Loading stalls while compute pipelines compile, because every title Sleep is held.
So on a cold cache the gate turns long back-to-back compute compiles into a loader stall of minutes. The title's Sleep-based loader and poller threads stay held the whole time, not only the thread that waits on the compile. This is a strong inference from the dump and the timing; I have not yet run the on/off test. Possible directions, untested:
|
…; link Threads Review on ItsNotRexed#9082 (the ItsNotRexed#7858 integration order): the pipeline cache is now fetched before the gate, so creating the cache or loading its seed holds no ticket, and the ticket covers vkCreateComputePipelines alone. A host-stall marker placed around that call (ItsNotRexed#7858) then nests inside the ticket, in the order measured to keep unrelated guest Sleeps returning between admissions: cache, ticket, contention log, marker, driver call, marker closed, ticket released. admits() compares without adding, so a weight near UINT64_MAX cannot wrap; compile_gate_test links Threads::Threads like the other threaded runtime tests, for toolchains whose pthreads are not in libc. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A single compute pipeline compile of 626 s was measured on an RTX 4080 (a wave64-emulated module of 8.6 MiB), above the 10 minutes of the previous commit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Correction to my reply above: the stall limit is 60 minutes at
AI-assisted (Claude Code). |
|
Measured your new head ( The gate is now nearly empty, but loading still waits on the compiles themselves.
So with your change the gate itself no longer blocks loading. What remains is the first-time compile of a handful of huge compute modules. With those stubbed (#9250), loading moves on. Numbers are on #9250 and #8851. |
Independent Windows revalidation — follow-upThanks @throny for addressing the earlier findings. I independently revalidated The following findings from my original review are resolved in the tested composition:
All 69 host-stall checks and 76 experimental scenarios produced the expected results, including negative controls. One concern remains: an independent worker returned from The duration threshold reduces the impact, but does not distinguish watchdog-related waits from unrelated long sleeps. I also acknowledge AAyberkU's newer retail results showing substantially fewer held threads and improved loading progress. My synthetic result does not establish that the reported retail loading stall persists on the current head. Could we narrow eligibility to the watchdog context, or establish that holding other long sleepers is safe for independent progress? The integration order with #9082 is now validated from my side. The remaining question is limited to global Sleep eligibility. Synthetic inputs only. AI-assisted investigation with OpenAI Codex. |
A cold first boot of the retail executable no longer ends at about 31 s inside the
XboxBvhBuildercompiles: with this change it survives a 56 s cold compile and goes on to the next stop (1,661 D3D12 calls, was 1,641).Claimed in the coordination issue as: new RT item (RT-5 follow-up), #7496 (comment)
Builds on no open pull request. It is next to #7516, #7535, #7360 and RT-601 (which shorten or avoid the compiles), not instead of them.
What and why
Sleep(1000)(imported fromapi-ms-win-core-synch-l1-2-0.dll), and after 30 rounds in which the main thread's progress mark did not change it writes to address 0. A round whoseSleeptook more than 2 s byQueryPerformanceCounterstarts the count again, as after a console suspend. From a static read of the loop: import names, counts and values only.D3D12XboxCreateDevice.runtime/src/host_stall.hkeeps a ledger of host-only stalls. The layer marks thevkCreateComputePipelinescall of a compute pipeline state as one, and only that call: the pipeline cache is fetched before it (runtime/shims/d3d12_vulkan_device.cpp).runtime/shims/host_stall.cppservesSleepfor mapped images: aSleep(n)of a second or more returns oncenms have passed outside stalls since it was called. The title's own late-round rule then starts its count again.Sleepshorter than a second, and one no stall overlaps, is the host's, unchanged. No pipeline is skipped and the check stays armed.SleepEx, waits with a timeout and all clocks stay the host's. Graphics pipelines and time lost outside a marked stall are not covered (docs/retail_boot_chain.md§5.3).Sleeps return, the time counts as the title's and the runtime prints one line. So for a boot that really hangs the check fires after 30 rounds with no stall open, within 60 min + 31 s of a marked host call that never returns, and within 31 s of the last compile when other threads go on compiling (finitely many: one per pipeline). Stalls shorter than the title's 2 s rule start no count again. Rounds that recurring stalls make longer than 2 s do, by the title's rule (§5.2).Tested
Tested on NVIDIA RTX 4080, driver 610.88, Windows 11, i9-12900K. MSVC 2022
RelWithDebInfo, Vulkan SDK 1.4.363.0.SleepPipodi:boot-integrationatb2e606620(main1cc6e3c12with docs/retail_boot_chain.md: stops 13-17 (descriptor heap at an address, device slots 70, 127, 25) #6982's pull requests and stand-ins) plus runtime/shims: add offline ws2_32.dll Winsock2 shim for mapped EXE #6943,LEONIDA_SKIP_ASSERTS=20, the 52 builder programs translated with--wave64-emulate, this change ported for "after". Cold = one unused constant added to each module, so the driver cache missed. A second pair gave the same result; four more runs without the change ended at 32.4 to 34.1 s.WS2_32and 30WINHTTPimports to shims, none to the host.host_stall_test(new, CPU only): 69 checks pass ata4241cc7c, 3 of 3 runs, 8.4 s underctest. The ledger and its limit with times passed in; sleeps and a stand-in hang check on a virtual clock (back-to-back, recurring, short and never-ending stalls); the servedSleepon real threads, including compiles that take turns as behind a compile gate. Negative controls: everySleepheld, 4 fail; stall time charged twice, 18 fail;Sleepnever held, 4 fail.4a51079bb, before the review changes of915db783f..a4241cc7c. A cold run with those is not done yet; it will be posted here.ctest, 273 tests, serial, at4a51079bb(maindde82f27e): 270 pass.d3d12_vulkan_device,d3d12_indirect_dispatch_countandd3d12_depth_resolvefail, and fail the same way on unmodifiedmainhere (the first two ata779d6411, the third atdde82f27e).tests/test_build_runtime_fallback.py: 8 pass.tests/test_docs_*.pyandscripts/check_no_game_data.py: as onmain(test_docs_cli_flags.pyandtest_docs_links.pyfail there too, on other pages).AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (Not a translator change.)🤖 Generated with Claude Code