Repository navigation
Conversation
A thread dump shows where each thread is, not what a waiting thread waits for. In the retail title's world-loading stall (xcl-dev#505) most title threads sit in WaitForSingleObject called straight from the title, so the stacks alone cannot tell which thread depends on which. With XCL_TRACE_WAITS=1 the title's event and semaphore imports (CreateEvent*, CreateSemaphore*, SetEvent, ReleaseSemaphore, CloseHandle, WaitForSingleObject(Ex), WaitForMultipleObjects(Ex)) go through wrappers in hle::waits that record each handle's maker and last signaler and each thread's current wait. Every thread dump then lists the title's threads waiting 2 s or more, with those details; a handle made elsewhere is named by its kernel type. Without the variable the import table is unchanged. On the retail title this showed the frame-loop thread (+0x23cf104) waiting at +0x43c3d5d on an event of a 128-entry ring made at +0x43c39dc, never set through SetEvent, while that ring's worker (+0x43c4314) built compute pipelines in its binds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A test run under Wine (xcl-dev#924) saw the process's host memory grow much faster with the variable set than without it. On Windows the commit with and without it is the same at 20 to 100 s. The tracer's two tables are keyed by handle and by thread and should stay small; printing their sizes with every dump shows whether they are what grows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Upstream PR xcl-dev#924 was closed or merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XCL_TRACE_WAITS=1: at each thread dump (XCL_THREAD_DUMP_AT, a crash), XCL lists the title's threads that have waited 2 s or more on the title's own events and semaphores. For each one it gives the handles, where in the title each handle was made, and when and from where it was last set or released ("never" when the title never signaled it). The thread stacks say where each thread is; this says which object a waiting thread is waiting for, and so which other thread it depends on. Part of xcl-dev#505.What is in it
a2b5007: each dump starts with the size of the tracer's two tables (handles known, threads waiting), after a Wine run in this thread saw host memory grow with the variable set.crates/xcl/src/hle/waits.rs(new):CreateEventA/W,CreateEventExW,CreateSemaphoreW,CreateSemaphoreExW,SetEvent,ReleaseSemaphore,CloseHandle,WaitForSingleObject(Ex)andWaitForMultipleObjects(Ex). Each calls Windows, then records the handle's maker and last signaler, and the calling thread's wait.long_waits()builds the report lines. A handle not made through these imports is named by its kernel type (NtQueryObject). Polls (timeout 0) are not recorded as waits.crates/xcl/src/hle/mod.rs: with the variable set, the wrappers join kernelx's exports, so the title's kernel-family imports reach them. Without it, the import table is unchanged.crates/xcl/src/eh.rs:dump_threadslogs the list after the thread stacks.a_thread_waiting_on_an_event_nobody_set_is_listed_until_the_event_is_seta_poll_is_not_a_wait_and_semaphores_count_releasesan_object_made_elsewhere_is_named_by_its_kernel_typeWhat it showed on the retail title of xcl-dev#505 (RTX 4080,
main1ec4c98+ this change,XCL_THREAD_DUMP_AT=88,98, A pressed throughXCL_PRESS_AT; frames stop at ~74 s,+0x23cf683at ~104 s)The dumps give one chain of waits, from the main thread down to a compute bind:
+0x23cf735) waits on semaphore0xff8. The frame-loop thread released it 619 times, from+0x23cf2c9, the last time at 73.6 s.+0x23cf104; it makes the firstListX #101call) waits from ~85 s until the abort at+0x43c3d5d. It waits on an event of a 128-entry ring made at start (+0x43c39dc, one event per entry). The title never sets that event throughSetEvent.+0x43c4314 ← +0x43c4591) builds compute pipelines in its binds during the stall: 31 builds on its own thread between 74 and 96.6 s, per the log lines.XCL_PSO_WAIT_MS=50) merged locally, the frame-loop thread's wait ends after ~25 s.This agrees with the compute-bind waits that
throny(#232),leondood1298andemusynths(xcl-dev#505) found in thread stacks. The new part is the objects and which thread each wait depends on.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4ona2b5007: 719 passed, 0 failed, 41 ignored. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).dc0fb78failedplaced_title_textures_share_vram_and_preserve_pixelsand the two tests whose mutex it poisons (Tests: placed_title_textures_share_vram_and_preserve_pixels fails now and then at its cubemap reuse check (main 9ce2070) xcl-dev/xcl#718, [upstream #1792] kernelx: commit a mapping call's sparse pages once per run, not per page #343). Those fail the same way onmain09940bbon this machine; this change does not touch them.cargo test -p xcl --lib waits: the 3 new tests pass.XCL_TRACE_WAITS=1: the runs above.Regression run (60 s,
XCL_TRACE_WAITSunset)main:
PR:
Not tested
SleepConditionVariable*,SleepEx,WaitOnAddress, and handles waited on inside system DLLs.SetEventnorID3D12Fence::SetEventOnCompletion(checked with a local hook that is not part of this PR).@throny: here is the branch, as you offered to run it.
AI use
🤖 Generated with Claude Code
Mirror of xcl-dev#924 (auto-synced, do not edit).