Repository navigation
rdna2_decode: stream the text listing instead of retaining every instruction - #4963
tupacfan04 wants to merge 1 commit into
Conversation
7786790 to
595c5dc
Compare
595c5dc to
e54f1cf
Compare
|
Independent check of Environment: Windows 11, CPython 3.15.2, CPU only. Synthetic inputs, no GPU, no game files.
Read the diff: text listing now streams per-instruction instead of accumulating — the memory win the title claims, with the byte path preserved for the binary listing. No issues found. AI-assisted (Devin). |
|
Tested e54f1cf on Arch Linux (in a VM), CPython 3.14, LLVM 23.1.5: pass.
|
|
Tested e54f1cf merged with main 3faac55 on Linux (WSL2), CPython 3.12.16, CPU only: pass
|
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Reviewed at \e54f1cf1. Tested on Windows 11:
- \python -m unittest tests/test_rdna2_decode.py\ -> 14 passed, OK (1 skipped, 1.50s).
- _iter_decoded\ preserves exact PC stepping and invalid-word stepping for \decode_bytes.
- \disasm_bytes\ streams into \io.StringIO\ with identical output and trailing newline semantics across empty, invalid, and mixed streams.
- Peak memory bound verified (< 6 MiB for 8,192 instructions).
- \git diff --check\ clean. No game files. AI-assisted review (Gemini).
|
Integration check on Windows: The combined decoder suite had 18 passes and one LLVM-dependent skip. All 22 shader-disassembly tests passed. Against the target-aware non-streaming version, 520 combinations of synthetic buffers, GFX10.1/GFX10.3, and wave32/wave64 matched in both text and structured output, including the invalid count. No branch changes pushed. CPU only, synthetic inputs, AI-assisted. 在 Windows 上做了接入验证。当前 组合后的解码测试 18 项通过、1 项因依赖 LLVM 跳过,22 项着色器反汇编测试全部通过。与支持目标架构的非流式版本相比,合成缓冲区、GFX10.1/GFX10.3 和 wave32/wave64 的 520 个组合在文本输出、结构化输出及非法指令计数上均一致。未推送分支改动。仅 CPU 和合成输入,AI 辅助。 |
kacper-serewis
left a comment
There was a problem hiding this comment.
At e54f1cf, 165 stage-stratified cached modules matched parent text, complete structured decoder output and invalid counts. All production ranges were clean; six deliberately extended ranges separately exercised 20 invalid words. On the largest sample, peak traced Python allocation fell from 106,416,576 to 18,399,556 bytes (one measurement per revision). Windows CPython 3.13.15. AI-assisted.
|
Tested
|
|
Closing as superseded by #4943 ("Stream Python shader text disassembly to lower peak memory", merged as Checked on Windows 11,
Thanks @Atomic258, @SphyserX, @kapitche and @tahffo68hk-hash for testing it. AI-assisted (Claude Code). |
Claimed in the coordination issue as #4932 (claim).
What and why
rdna2_decode.disasm_bytes()calleddecode_bytes(), kept every decoded instruction dictionary, built a second list of formatted lines, and joined it. For a text-only caller that doubled the retained Python objects until the final string existed._iter_decoded(), which yields each instruction (orNonefor an invalid word) as soon as it is decoded.decode_bytes()keeps collecting the structured result its callers expect.disasm_bytes()formats each instruction and writes it to aStringIOimmediately, so the instruction dict and its formatted line are released before the next decode.code_starthandling, the trailing newline and the invalid-word count are unchanged.Measured on Windows 11 with CPython 3.14.7, using
bytes.fromhex("000040d501050e04") * 8192 + b"\xff"andtracemallocstarted immediately before the call:Both return the same 778,240-character listing and report one invalid word. This measures Python allocations only, not RSS or throughput.
Tested
py -3 -I -m pytest tests/test_rdna2_decode.py tests/test_rdna2spirv_decode.py tests/test_shader_disasm.py -q: 57 passed, 1 skipped, 72 subtests passed.py -3 -m compileall -q tools/rdna2_decode.py: exit 0.code_start,wave32=False, and the 2,048-instruction repeated input), compared by SHA-256 of the full listing plus the invalid count.AI-assisted: the change, tests and this description were written by an AI coding agent running in OpenCode and checked by the commands above.
Checklist
CONTRIBUTING.md), including in logs or reports quoted here.docs/design.md, with how it was confirmed. (Not a translator change.)Depends on: nothing.