Skip to content

BUILD-2810: shader_disasm: a time limit per llvm-mc call, and ten failures in a row end the run - #7980

Open
Pablo-Barros wants to merge 2 commits into
ItsNotRexed:mainfrom
Pablo-Barros:shader-disasm-llvm-mc-timeout
Open

Pablo-Barros wants to merge 2 commits into
ItsNotRexed:mainfrom
Pablo-Barros:shader-disasm-llvm-mc-timeout

Conversation

@Pablo-Barros

@Pablo-Barros Pablo-Barros commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: BUILD-2810 (claimed as a new item in #6910 (comment))

Depends on: builds on none. It changes tools/shader_disasm.py and its test, which the open #4843, #6190, #7104, #4210, #7573, #4447, #4588 and #4267 also change, so it will need a rebase onto whichever of them lands first.

What and why

shader_disasm.py called llvm-mc with no time limit and reported each failed call as one failed shader before going on to the next file.

With LLVM_MC set to a WSL command (WSL 2.6.3, LLVM 21.1.8) on Windows 11, the shader stage of make_game.py disassembled 16,642 shaders in 13 minutes. Then every wsl.exe call waited about 100 s and failed with Wsl/Service/0x8007274c. The four workers went on to the next file each time, so the 9,092 shaders left would have taken about 60 hours. I stopped the stage, ran wsl --shutdown, and --stages shaders,pipelines resumed from the finished listings (BUILD-667). I have not found why WSL stopped answering. Separately, a call that never returns held a worker for good.

  • A time limit per call. One llvm-mc call may take 120 s. LEONIDA_MC_TIMEOUT gives another number of seconds, and anything but a positive finite number is one ERROR line. A call that runs out of time is one failed shader, llvm-mc did not answer within 120 s; at the probe it is one ERROR line.
  • The whole process tree is stopped. A relay hands the work to a child that keeps the output pipes open: wsl.exe starts another wsl.exe. With subprocess.run(timeout=1) on a command that does this, a 1 s limit returned after 12 s, when the child exited. So the call uses taskkill /F /T on Windows, as tools/xcl_compare.py does, and a new session with killpg elsewhere, as scripts/run_wine_tests.py does.
  • Ten failures in a row end the run. Ten shaders in a row with no disassembly, and no listing between them, give one ERROR line: llvm-mc gave no disassembly for 10 shaders in a row with no listing between them, first <path>: <reason>. ..., and the line says how many shaders were not started. The worker that counts the tenth closes the pool, so the shaders still queued are not started; with more than one worker, the calls in flight end on their own. One failed shader, or a few with listings between them, are reported as before. This is the part that covers the run described above, where each call failed on its own after 100 s.
  • docs/design.md, "Disassembling shaders", states both limits.

How 120 s was chosen. Through WSL, while a build was running: over the 30 largest listings of a 1.0.2.1 corpus (25,734 shaders), one llvm-mc call took at most 5.65 s (mean 0.42 s); over 90 others taken at random, at most 0.20 s.

Tested

No GPU is involved. Windows 11 build 26300, Python 3.12.10, main 242968218 plus this change.

  • Eight tests in tests/test_shader_disasm.py, each with a fake llvm-mc the test writes:
    • an llvm-mc that fails every shader ends at the tenth failure, says that two shaders were not started, and the twelfth is never started;
    • failures apart from each other, with a listing after each, are three failed shaders as before;
    • with two workers, a shader still in flight when the tenth failure closes the pool answers afterwards: the run still reports that it ended, and that 19 shaders were not started;
    • a relay that hands the work to a child and then sleeps is stopped and reported within the limit;
    • the same at the probe;
    • the next --skip-existing run reuses the listings written before the run ended;
    • LEONIDA_MC_TIMEOUT must be a positive number of seconds, and it is read from the environment.
  • python -I tests/test_shader_disasm.py: 37 tests OK, three runs in a row (36 before the commit for the review below).
  • tests/test_bvh_shaders_stage.py (13), tests/test_fspx_shaders_stage.py (22), tests/test_fssm_crosscheck.py (6) and tests/test_first_light.py (47, 4 skipped): OK.
  • Every standalone standard-library test of tests/ that CI runs with python -I, at 4152d045 (the commit after it changes only this tool and its test): 443 files, 416 pass and 27 fail on this machine. The same 27 fail on main without this change; none is new.
  • python -m compileall -q make_game.py tools tests: OK.
  • python -I scripts/check_no_game_data.py on the three changed files: OK.
  • With the real llvm-mc of WSL (LLVM 21.1.8) on 80 shaders of my own copy, the listings are byte for byte those of main 242968218.

AI-assisted: yes (ZCode)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. Not applicable: no translator rule changes.

…lures in a row end the run

With LLVM_MC set to a WSL command, every wsl.exe call failed after about 16,600 shaders, each after about 100 s,
and the tool went on to the next file: about 60 hours for the 9,092 left. llvm-mc was also called with no time
limit, so a call that never returned held a worker for good.

One call may take LEONIDA_MC_TIMEOUT seconds (120 by default) and is stopped with its child processes when it
runs out: wsl.exe starts another wsl.exe that keeps the output pipes open, so subprocess.run(timeout=1) returned
after 12 s. Ten shaders in a row with no disassembly, and no listing between them, end the run with one line;
the worker that counts the tenth closes the pool. make_game.py resumes from the listings written, as before.

AI-assisted (ZCode).
@noviw-rblx

Copy link
Copy Markdown

checked: #7980 | with: python -m pytest -q tests/test_shader_disasm.py | on: Windows 10, CPython 3.13, head 4152d04, CPU only | result: 36 passed, 14 subtests passed. No game data, no GPU.

@azterixx

Copy link
Copy Markdown

tools/shader_disasm.py:230: With --jobs > 1, shaders already running when the tenth failure in a row cancels the queue can still finish and write a listing. listing_written() then resets IN_A_ROW[0] to 0, so main() prints the generic "N shader(s) produced no disassembly" instead of the "the run ended here" message, and the shaders that never started go unmentioned (I got {'clean': 1, 'failed': 10} for 30 inputs). Repro: 30 shaders, --jobs 2, and a fake llvm-mc that fails fast except on one shader that answers after 3 s. A separate "ended" flag that listing_written() cannot clear would fix this, ideally with the count of shaders not started.

(AI-assisted review; reproduced locally on macOS / M1 Pro.)

@TieruYT

TieruYT commented Nov 23, 2026

Copy link
Copy Markdown

Windows, synthetic inputs. Tested 4152d04.

All seven focused disassembler tests passed on this revision on Windows using a stand-in llvm-mc, including a hung probe, a hung invocation with a child process, consecutive versus separated failures, and resume after interruption. The parent control exceeded my 100-second outer test deadline, so I have no completed parent-suite count.

AI-assisted verification · GPT-6.2 Astra Medium

… answers

Review of ItsNotRexed#7980 (azterixx): with more than one worker, a shader still running when the tenth failure closed the
pool can answer and write a listing, which zeroed the count. main() then printed the usual "N shader(s) produced
no disassembly" and said nothing about the shaders that were never started. The first failure of the run of ten
is now kept apart from the count, and the line says how many shaders were not started.

AI-assisted (ZCode).
@Pablo-Barros

Copy link
Copy Markdown
Author

Thanks @azterixx, you were right, and the case is now a test: 30 shaders, --jobs 2, and a fake llvm-mc that answers the first shader only once ten shaders have failed. On 4152d045 that test gets the usual 10 shader(s) produced no disassembly line, as you describe.

Commit b13e08cd2 keeps the first failure of the run of ten apart from the count, so a listing written afterwards cannot clear it, and the line now says how many shaders were not started (19 shader(s) were not started in that test). python -I tests/test_shader_disasm.py on Windows 11: 37 tests OK.

AI-assisted (ZCode).

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.

4 participants