Repository navigation
Conversation
3 tasks done
The dump logged every guest thread when no frame had been presented for the given time, but a frame can wait in the host too: the guest's main thread parked in nvn_queue_submit under _pthread_mutex_firstfit_lock_wait only says that the replay thread holds g_sub_mu, not what that thread is doing. The dump now also reads the host threads that declared a real-time policy (the acquire, the queue replay and the encode thread, from the registry in hle_nvn.c, nvn_rt_threads) before it reads the guest threads: each is suspended for a moment as the guest threads are, checked against the thread ID it was registered with (a port of a thread that has ended may name another), and logged as a `host '<name>'` line with its state and up to 54 host frames named by dladdr. Nothing is logged for a thread that has not registered. The limit of 24 dumps a run is unchanged. The host unit tests that link hle_thread.c without the graphics layer (t_condvar_stub.c, t_system_event.c) define nvn_rt_threads in their stubs, as they do dm_host_work. It is what found the cause of 50-130 ms stalls in Ocarina of Time's Hall of Fallen Foes: the replay thread inside arch_lookup under MTLCompilerScheduler::buildRequest while the guest's submit waited for it. Checked: the host builds; `make -C dm/host/tests GAME=0400486024DEC000 -k run` fails only memory-profile (a Python 3.9 type annotation in its script), as it does on unchanged main; dm/tools/env_switches.py --check prints what it prints on main (12 stale names, DM_SPLIT_REGISTERED_MAP without a meaning); the docs tests (test_docs.py) pass, with the entry in docs/reference/threads.md. No test covers the dump itself: it needs a stalled frame, and a run of the game on an M4 Max (macOS 27.3) with DM_HITCH_DUMP=25:100 logged the host lines for the three threads at each stall. clang-tidy was not run (not installed here). Only Ocarina of Time was run.
adurham
force-pushed
the
fix/hitch-dump-host-threads
branch
from
November 21, 2026 15:53
29243a0 to
c94754a
Compare
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.
What and why
DM_HITCH_DUMPlogged every guest thread when no frame had been presented for N ms, but a frame can also wait in the host: the guest's main thread parked innvn_queue_submitunder_pthread_mutex_firstfit_lock_waitonly says that the replay thread holdsg_sub_mu, not what that thread is doing.The dump now also reads the host threads that declared a real-time policy (the acquire, queue replay and encode thread, from the registry in
hle_nvn.c:nvn_rt_threads) first, suspended for a moment like the guest threads and only if the thread ID still matches the one registered, and logs each as ahost '<name>'line with its state and up to 54 host frames named bydladdr. The 24-dumps-a-run limit is unchanged. The host unit tests that linkhle_thread.cwithout the graphics layer (t_condvar_stub.c,t_system_event.c) definenvn_rt_threadsin their stubs, as they dodm_host_work.It is what found the cause of the stalls in the next PR of this series (the replay thread inside
arch_lookupunderMTLCompilerScheduler::buildRequestwhile the guest's submit waited for it). Reference entry:docs/reference/threads.md, "A stall in the host was not in the hitch dump".Checked
make -C dm/host/tests GAME=0400486024DEC000 -k runfails onlymemory-profile(a Python 3.9 type annotation in its script), as on unchanged main;dm/tools/tests/test_docs.pypasses.dm/tools/env_switches.py --checkprints what it prints on main (12 stale names,DM_SPLIT_REGISTERED_MAPwithout a meaning). clang-tidy was not run (not installed on the machine). No test covers the dump itself: it needs a stalled frame.DM_HITCH_DUMP=25:100; the log shows the threehostlines at each stall.regress.py check --games: not run; only Ocarina of Time is installed on this machine. The change is a diagnostic that runs only withDM_HITCH_DUMPset.Front ends
Nothing a front end has to act on.
Docs
docs/reference/threads.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)Written with AI: Claude (Hermes Agent) · Responsibility: Adam Durham