Skip to content

tools: dump threads when a run stops presenting (X2W_DUMP_ON_STALL) - #3674

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:startup/dump-on-stall
Dec 1, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:startup/dump-on-stall

Conversation

@Jess-Doit

Copy link
Copy Markdown
Contributor

Refs #870.

Problem

X2W_DUMP_AT=<seconds> writes every thread's stack at fixed times. A stall that ends a run often starts at a time that changes from run to run, because it depends on how fast the load goes. On a GTX 1060 host, ten fixed dump times between 600 and 900 s all missed one: that run stopped presenting at about 1,006 s.

Change

  • New option. X2W_DUMP_ON_STALL=<seconds> makes the startup debugger (tools/startup/debug_launch.py) read trap.log about once a second, from the end of the previous read, and follow the stand-in's x2w-d3d12 heartbeat: <n> frames presented count.
  • When it dumps. Once the count has not changed for that long, it writes every thread's stack to threads_stall_<seconds into the run>.txt and logs no new frame for <s> s (last heartbeat <n> frames): threads dumped.
  • Further dumps. It dumps again after each further stall of the same length, at most three times. A new frame count starts the wait again, and nothing is dumped before the first heartbeat.
  • Unset. Nothing changes.
  • The decision is in tools/startup/stall_watch.py, a small module without Windows imports, so it can be checked anywhere.
  • Docs. docs/startup-runtime.md has a row next to X2W_DUMP_AT.

Tests

tests/startup_stall_watch_check.py is registered in tests/cmake/startup_stall_watch.cmake and in tests/checks/python-linux. It checks:

  • no dump before the first heartbeat;
  • 14 s versus 15 s without a new frame;
  • the next dump only after a further stall;
  • a new frame count restarting the wait;
  • the cap of three dumps;
  • the last heartbeat in a block of text being the one that counts;
  • a zero time being refused.

Two controls must fail:

  • --mutate no-reset keeps timing from the first heartbeat after frames move on. It fails 2 cases.
  • --mutate early dumps before the first heartbeat. It fails 1 case.
Command Result
python -B tests/startup_stall_watch_check.py all cases passed
... --mutate no-reset / ... --mutate early exit 1 (as required)
tests/startup_debug_launch_args_check.py (runs debug_launch.py, so the new import is loaded) 15 malformed option values rejected
tests/startup_tools_lint_check.py, tests/docs_links_check.py, tests/run_checks_parallel_check.py, git diff --check pass

Use on a package run

Before this was split into a module, the same logic ran in two package runs on a GTX 1060 6 GB (Windows 10 19045):

  • One dumped at 804 s and at 1,190 s. The second dump showed the title's render thread parked and its main thread waiting.
  • One with the shared presets dumped at 423, 439 and 454 s. Title worker threads were queued on a stand-in request lock while one thread wrote request files, which led to startup: write mesh pipeline requests on a background thread #3664.

🤖 Generated with Claude Code

X2W_DUMP_AT needs the stall time in advance. X2W_DUMP_ON_STALL=<s> has
the startup debugger watch the stand-in's heartbeat frame count in
trap.log and write every thread's stack once it has not changed for
that long, at most three times. The decision is in stall_watch.py, with
a device-free check and two controls that must fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the opt-in stall watcher. It waits for the first heartbeat, restarts the interval when the frame count changes, and caps dumps. ctest --test-dir <build> --no-tests=error -j1 -R '^startup_stall_watch' --output-on-failure passed all three cases, including the early-dump and no-reset controls.

@R0Y00
R0Y00 merged commit a6cad06 into R0Y00:main Dec 1, 2026
5 checks passed
R0Y00 pushed a commit that referenced this pull request Dec 1, 2026
… control

The real_log_error control copies debug_launch.py plus a hard-coded list of local modules into a
scratch tree. #3674 (58352a6) added 'from stall_watch import StallWatch' to debug_launch.py and
did not update that list, so the copied launcher died with ModuleNotFoundError before reaching the
events.txt open. The control then reported that the debugger log error was not captured, because the
summary held the missing module instead of the PermissionError it looks for.

Derive the list from debug_launch.py's own imports so the next addition cannot break the control the
same way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants