Repository navigation
Shader split: decompress zstd files in-process, so a worker no longer deadlocks against the zstd command's pipes (Ocarina of Time's split hung at 88 %) - #1463
Conversation
… deadlocks against the zstd command's pipes Feeding the zstd CLI through stdin while capturing stdout deadlocks on macOS once a frame is larger than the pipe buffers: the worker's blocking write waits for zstd to read, while zstd's output writer waits for the worker to drain stdout. Ocarina of Time's sound archives hit it at 88% of the split (164,256 of 186,587 files), and the build hung for good. compression.zstd (Python 3.14, backports.zstd before) is already used for dictionary frames; it decompresses frames without one too. test_split_zstd.py covers files and bounded RomFS entries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
With the change, the same Ocarina of Time build's split finished: |
|
The full build finished on the fixed split: Mac shaders 42,847 of 42,854 (49:36 on this M3 Max), the pipeline archive and the app (36.0 GB); the game runs through Kokiri Forest from it. The 7 that did not translate are |
The shader split of Tears of the Kingdom (303,856/304,243) and Ocarina of Time (170,960/186,587) stops for good with every worker in os.write() to an idle `zstd -d -c -q` child. Carry seedds/nxnative#1463 (Jon Page, cherry-picked unchanged) until upstream merges it: `unzs` decompresses frames without a dictionary with compression.zstd / backports.zstd, the module the dictionary frames already use, so no child and no pipe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shader split: decompress zstd in-process, so the split no longer hangs at 99% (patch of seedds/nxnative#1463)
…cess (Ocarina of Time's split hung at 88 %)
…std files in-process, so a worker no longer deadlocks against the zstd command's pipes (Ocarina of Time's split hung at 88 % Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… deadlocks against the zstd command's pipes Feeding the zstd CLI through stdin while capturing stdout deadlocks on macOS once a frame is larger than the pipe buffers: the worker's blocking write waits for zstd to read, while zstd's output writer waits for the worker to drain stdout. Ocarina of Time's sound archives hit it at 88% of the split (164,256 of 186,587 files), and the build hung for good. compression.zstd (Python 3.14, backports.zstd before) is already used for dictionary frames; it decompresses frames without one too. test_split_zstd.py covers files and bounded RomFS entries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 82a24a4) Upstream-Status: forwarded seedds#1463 Reason: Shader splits of Tears of the Kingdom and Ocarina of Time hang at 99% with every worker blocked writing to an idle zstd child; until upstream merges seedds#1463 Issue: LNPANDY/NX2Apple#837
|
Thanks @jonpage0 for pinning down the zstd hang and confirming a complete 42,854-shader split on Ocarina of Time. Main now decodes zstd in process as well (6aaf73b). The landed checks found identical shader packages and tables across three games and the synthetic archives. I'm closing the duplicate implementation. |
What and why
Symptom: building The Legend of Zelda: Ocarina of Time (
0400486024DEC000, v131072) as a Mac app from current main stops for good at the shader split:splitting: 88%, 164,256/186,587 files, then no new line, the worker processes asleep and fourzstd -d -c -qchildren at 0 % CPU.Cause: since #394,
unzsindm/gfx/tools/shader_split.pyfeeds a frame without a dictionary to thezstdcommand on stdin while capturing its stdout (subprocess.run(..., input=d, capture_output=True)). Once a frame is larger than the pipe buffers the two block on each other: the worker's write waits forzstdto read, andzstd's output write waits for the worker to drain stdout, whichsubprocess.rundoes only after the write has finished. Ocarina's sound archives are big enough; the split hangs with every worker in that state.Fix:
unzsdecompresses in-process withcompression.zstd(Python 3.14;backports.zstdbefore), which the dictionary frames already go through (unzs_dict): no pipes, and a bounded RomFS image entry is read the same way as a file. An invalid stream is a red line naming the path, as the other readers do.Reference entry: The split hangs decompressing a large zstd file; the symptom index is regenerated.
Checked
python3 -m unittest dm/tools/tests/test_split_zstd.py: 4 tests, OK (a 2 MB+ file and the same bytes as a bounded RomFS image entry, withsubprocess.runpatched to fail; concatenated frames; a dictionary frame through its named dictionary; truncation and a checksum error rejected with the path in the message).python3 -m unittest dm/tools/tests/test_docs.py: OK;python3 dm/tools/docs_symptoms.py --check: current.zstdcommand before; the bytes are the same).Docs
docs/reference/shaders.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)🤖 Generated with Claude Code