Repository navigation
perf(recompiler): compute post-dominators visiting successors first - #2105
adriadam10 merged 1 commit into
Conversation
|
The linux and windows failures here are main's own build break, not this change: |
computePostDominators iterates its sets to a fixed point, visiting the blocks in id order. Post-dominance flows from a block's successors back to it, and successors mostly have higher ids, so each pass moved the sets back by about one block: a long program needed about as many passes as it has blocks, each costing O(blocks^2). recomputeAnalyses runs it after every split of splitSharedMergeBlocks, up to four times per block. Visit the blocks in post-order of the CFG (successors first), then any the entry does not reach. The sets start from every block and only shrink, so the iteration still converges to the same greatest fixed point, now in a few passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
437337e to
f57d164
Compare
|
Another title where this is the bottleneck: Rise of the Ronin (PPSA04540), on AMD. Setup: RX 9070 XT (RADV / Mesa 26.2.4), Ryzen 7 7800X3D, Linux, GCC. Base is Without this PR (warm shader disk cache):
With this PR (cold cache, since the source version changed):
So on this title it goes from stuck at registration to getting through its shader loading. Tested and written by Claude (AI assistant) on a contributor's machine. |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
Independent confirmation from a different title and platform (Windows 11, MinGW-w64 GCC 15.2.0, RTX 5090). I hit the same problem and made the same change (postorder visit, unreachable blocks appended in id order) before finding this PR. Equivalence on real shaders. I dumped the Worst cases. These were three ~4,800-instruction compute shaders (589 → 793 blocks after splitting): 6.2–6.3 s → 0.31–0.35 s per Why it matters beyond load time. Tested and written by Claude (Claude Code) on a contributor's machine. |
|
Checked on current main: build + ctest green (agc_structurizer included). The change only reorders the fixed-point iteration (same equations, same initial sets), so the result is unchanged, as the new brute-force post-dominator check and mrk1987's 608-shader equivalence dump confirm. Timings are confirmed independently by EdouardSence and mrk1987. Merging. Note: #2201 touches the same spot in |
…t-dominators-postorder perf(recompiler): compute post-dominators visiting successors first
What
Structurizer::computePostDominatorsiterates the post-dominator sets to a fixed point, visiting the blocks in id order. Post-dominance flows from a block's successors back to the block, and successors mostly have higher ids, so each pass moved the sets back by about one block. A long program needed about as many passes as it has blocks, each pass costing O(blocks²).recomputeAnalysesruns it again after every split insplitSharedMergeBlocks, which allows up to four splits per block.PPSA36082
After the main menu, loading a level shows a black screen for about 20 s while the game prepares a shader through
sceAgcCreateInterpolantMapping→Driver::ResolveShaderAbi→Structurize. All 12 thread stacks I sampled during it were insplitSharedMergeBlocks→recomputeAnalyses→computePostDominators. With this change the black screen lasts about 5 s.Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090.
agc_structurizer(new check): afterStructurize, every block's post-dominator set must equal a brute-force one (B post-dominates A when no path from A reaches an exit without passing B). Runs on the existing graphs and a 151-block chain of 50 selections. Starting from the wrong initial sets fails it.splitSharedMergeBlockssplits, and four of the existing test graphs) gives identical output, 412 lines.Structurizetime, main → this change: a chain of 400 selections (1201 blocks) 3181 ms → 20 ms; 60 branches to one shared block (122 blocks, 181 after splitting) 104 ms → 27 ms.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)