perf(relinker): mark reached code in a map while collecting instructions #13825
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13825"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-31T08:22:38Z.
What
CodeInstructionCollector::Collectbuilds the control-flow graph of each code segment, then decodes every reachable instruction. Two costs grew with the size of the segment:std::unordered_set. Every decoded instruction looked itself up, was inserted, and was also inserted into and erased from avisitedset.Collectpassed the same growing set to each pass of its root loop. Each pass then walked the whole set again, skipping what it had already decoded.This PR changes both:
visitedset was, so a later walk can queue the address again.ExtendControlFlowGraph: it takes a caller's map and returns only the addresses that one walk added, in address order.Collectkeeps one map per segment and handles only those addresses.rootsanddataTargetsare ordered sets, so handling the new addresses in a different order changes nothing.BuildControlFlowGraphwith a reachable set fills a map from the set, walks, then inserts the new addresses in the order they were found. The other overloads andIControlFlowGraphare unchanged.CheckReachedMapinControlFlowGraphTestscovers the new function:Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release. Both arms were built in one relinker-only build directory with the same options:
main828ac0b2ae, and this PR's code (28e28beaf1, identical to7e497b667bexcept that it lacks the new test). Each run converts a title'seboot.elfwithrelinker --windows, alternating the arms. The output check is a SHA-256 over every output file.eboot.elfmainmedianca84b8c937019c670b47749e422164371999b0114f6c7466579e2e0c44cde8e617d2d480e7b9eb97main44.85–49.67 s, this PR 26.99–28.62 s.main833be4af8dwith #12154, #12282 and #12270 merged, the same change took PPSA04158 from 22.92 s to 16.42 s (median of six), with the same output.Collect's path.ctest -j16), including the newCheckReachedMap. Conventions pass.2250da786conmaine8c25dd3ba.maindid not change the four files between828ac0b2aeande8c25dd3ba, so the diff is the tested one.Overlap
Collect, replacingdecodedInstructionsandinstructionswith vectors. A rebase after either merges is mechanical.reachablein the walk. After this PR the walk no longer inserts into that set, so the reserve only affects the set overload, and the two edit the same lines.TargetOfSlotlines inside the same walk, which this PR does not touch.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T08:27:18Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The relinker benchmark is useful, but this
perfPR still lacks the repository-required paired performance captures and remains labeledperf numbers missing.What I ran
Reviewed head
2250da786caefbcad6620af5c59e26ed852effa4. The PR base and currentmainweree8c25dd3baa6e78531d5eee067fec5cbe8af3dcf; the no-build merge preview was clean. Environment: Debian GNU/Linux 12, x86_64, Linux 6.1.0-54, Python 3.11.2. No local C++ build or CTest was run.Results
main.aps5-summary.jsonllines, attached traces, ortrace_digest.pyoutput. GitHub still showsperf numbers missing.Unedited outputs
Conventions check
Merge preview
Hosted checks (`gh pr checks`)
Findings
Blocking
CONTRIBUTING.mdrequires a speed-change PR to providemainand changed-build summary lines from the same machine and scene, plus the traces described by the performance-report form. The current description provides valuable relinker conversion timings and output hashes, but does not include those summary lines, traces, or digest output; GitHub'sperf numbers missinglabel confirms the missing summary lines. Please add the required matched captures, traces, andpython3 tools/trace_digest.pyoutputs. If the runtime capture format cannot represent this relinker-only measurement, please clarify the exception with maintainers and have the repository's performance requirement/label handled accordingly before approval.Non-blocking
Sources
Not verified
To get this to a good state
Add the matched performance evidence requested above, or resolve the tool-only performance-report exception with maintainers. I will refresh the PR and rerun the relevant checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T11:20:39Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The allocation-failure fix and regression test are improved, but the PR still lacks the performance evidence required for a
perfchange and remains labeledperf numbers missing.What I ran
Reviewed head
3f20e4b42d97787cbb8bca7ac0c050267f0d70d9against basee8c25dd3baa6e78531d5eee067fec5cbe8af3dcf; the merge preview against currentmainf5b82ff45302cd6748a58868611a3dbe89211cddwas clean. Environment: Linux x86_64, Python 3.11.2. I did not build or run C++ tests locally.Results
mainaps5-summary.jsonllines, attached traces, ortrace_digest.pyoutput; GitHub still showsperf numbers missingUnedited local convention output
Negative control
Findings
Blocking
main/change summary lines from the same machine and scene plus the traces described by the performance-report form. Because this tool-only change may not produce runtime-frame summaries, please either attach the prescribed paired captures/traces and digest or obtain a maintainer-approved exception for this case and have theperf numbers missinglabel handled. No approval is given while the repository requirement remains unresolved.Non-blocking
Sources
mainrequires matched summaries and traces for speed claims.maindescribes the capture artifacts.Not verified
I did not reproduce the relinker benchmark, the reported 543-test suite, or the allocation-failure control locally. The hosted performance requirement remains unresolved even though hosted relinker checks passed.
To get this to a good state
Provide the matched performance artifacts required by the repository or record a maintainer-approved exception and resolve the performance label. I will recheck the evidence and exact head afterward.