Repository navigation
Conversation
…ll locks the heap xcl.exe's manifest (embedded by build.rs on MSVC) asks Windows for the segment heap as the process heap. During the shader preparation DXC and NVIDIA's compiler allocate from it on many threads at once, and the NT heap's lock serialises them (xcl-dev#156): a cold preparation of a retail title took 3357 s against 3724 s (mean of two runs each, RTX 3060). The segment heap brought out a hang at every ExitProcess: the NtTerminateProcess hook logged (and allocated) during ntdll's NtTerminateProcess(0, ...), which runs under the loader lock and the process heap's lock. The NT heap lets the same thread take that lock again; the segment heap does not. The end is now logged from a hook on RtlExitUserProcess, before those locks and while the other threads still run, so the thread dump of a non-zero exit is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Under Wine + vkd3d-proton on an RTX 4070, the Setup:
Not tested: native Windows; the segment heap itself (no manifest in a GNU build); the shader preparation's time; the whole test suite. AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment. |
xcl.exe asks Windows for the segment heap as its process heap, through a manifest embedded at link time. During the shader preparation, DXC and NVIDIA's compiler allocate from the process heap on many threads at once, and the NT heap's lock serialises them (#156, @wondercrash's finding). In a cold preparation of a retail title on NVIDIA, the segment heap took 9.9 % less time: 3 357 s against 3 724 s, the mean of two runs each (numbers on #156).
The segment heap brought out a hang at process exit. XCL's
NtTerminateProcesshook logged during ntdll'sNtTerminateProcess(0, …), which runs while ntdll holds the loader lock and the process heap's lock. The NT heap lets the thread that holds its lock take it again; the segment heap does not, so every title that ended throughExitProcesshung there. That included the e2e test title. It was found with an in-process probe of the loader lock's owner and its stack (details on #156). The end of the process is now logged from a hook onRtlExitUserProcess, before ntdll takes those locks and while the other threads still run, so the thread dump on a non-zero exit is kept.TerminateProcessof the process itself still goes through theNtTerminateProcesshook.Part of #156. Related: #2698 fixes the same kind of wait on another path. Its watchdog's
TerminateProcessgoes through the same hook while a suspended thread holds the heap, and it calls the realNtTerminateProcessthere. Both PRs changeeh.rs, so whichever lands second needs a small rebase.What is in it
crates/xcl/xcl.manifest(new) andcrates/xcl/build.rs: the manifest (<heapType>SegmentHeap</heapType>), embedded into thexclbinary on MSVC with/MANIFEST:EMBED /MANIFESTINPUT:.crates/xcl/src/eh.rs: theRtlExitUserProcesshook, with the logging shared with theNtTerminateProcesshook (log_process_end).crates/xcl/tests/segment_heap.rs(new):xcl.exehas a process manifest that asks for the segment heap.crates/xcl/tests/e2e.rs: the test title's end is in the log. Without the hook change the test hangs at the title's exit under the segment heap.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4(debug), onmain06f90c19plus this change: 1459 passed, 0 failed, 47 ignored.cargo test --release -p xcl --test e2e: 4 passed. Before theeh.rschange, all four hung at the title's exit.XCL_ACTIVITY=1, warm caches, one run each,main06f90c19against this PR (f0ccacd7). Peak process commit 37 063 MB against 36 908 MB (−0.4 %), local video memory 18 029 against 18 102 MB, frames 1 795 against 1 793. So the segment heap leaves RAM and VRAM use where they were; the gain is the preparation time.Regression run
scripts/smoke.ps1 -Game <title folder>, 60 s, release, A pressed every 4 s from 20 s, warm caches:main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code