perf(relinker): return the collected instructions as a sorted vector #12282
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12282"
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-28T07:08:55Z.
What
CodeInstructionCollector::Collectreturned its instruction addresses as astd::set. After #12154 it already holds them sorted and unique in astd::vector, so building the set added one heap node per instruction (millions on a large title) and nothing else. Its consumers only walk the result in order and binary search it.Collectnow returns that vector. Each user searches it as before, now withstd::lower_boundandstd::binary_search:Collect;WindowsTlsBuilderandMacOsImage, whichlower_boundto each code segment and walk forward;ConversionTestsmembership checks.The set of instructions and its order are unchanged.
Tested
Windows follow-up (2026-11-02): exact head
17979bdcbband base main93dbd0f82a, WinLibs GCC 15.2.0 UCRT r7 Release: 560/560 registered tests pass on each. Six alternating Goat Simulator 3 executable conversions per arm give medians 28.84 s on main and 16.52 s on this PR, with identical full output-tree hashes. This is one offline conversion workload, not title runtime evidence; see the full follow-up. The offline performance-report rule remains awaiting maintainer clarification in discussion #12358.Current-main refresh (2026-11-01): linear head
17979bdcbb123db20af0dc7a47de0b98de38a1a5on main93dbd0f82aea. Main's incrementalExtendControlFlowGraphand byte-per-offset reached state are retained. The two prerequisite commits are the actual refreshed #12154 ancestry. Main's new initializer-array fixture now compares the ordered result as a vector. Linux x86-64, GCC 16.2.1, Ninja Release,ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON: rebuilt relinker and all registered tests, 557/557 CTests pass; conventions and whitespace pass. Historical platform and performance reports below remain pinned to their stated commits; no new conversion timing or runtime gain is claimed.Current qualification (2026-10-28)
@rooklz Fixed the pessimizing move in
c7a46a7dfb991c9ec2e9da4a35045bcd6bb33577:return instructionList;permits NRVO and retains the implicit move when elision is unavailable. This is the only changed source line on the previous head.Linux GCC 16.2.1 Release, relinker-only: a fresh build and all 373/373 CTests pass, with zero skips or failures. A separate Clang syntax check with
-Wall -Wextra -Werror=pessimizing-movefails on the old statement and passes without warnings on this source. Conventions, whitespace and current-main merge preview pass.Your macOS output-differential and test results remain attributed to the earlier head. No fresh macOS/Windows or speed measurement is claimed. The separate offline performance-report format question remains awaiting maintainers in discussion #12358; this warning fix does not clear that gate.
Source pins, reviewed patch/proofs, builds, controls, logs and JUnit, SHA-256
438ebb3ddb04bbedc39fb1b53e5d04b2a222831a55edb9004c076133b054d7ce.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
-DANYPS5_RELINKER_ONLY=ON.BUILD_TESTING=ON).ad732ce0ecagainst this branch on it. Each ranrelinker --windows --skip-sce-module --registry <eboot.elf> app.exeon four titles' executables, alternating, 3 rounds, wall time in ms:app.exesha256 (identical on both)62c8241f…0b1db4e7…6465a4b2…f2f65cf7…app.registry.jsonis byte-identical too in every round. The two bold rounds are outliers from machine-wide stalls on this host during this session; another relinker CTest run took 374 s instead of the usual 40 s, timing out unrelated Python tests too. They pull the large-title medians toward zero. Without them, PPSA07923 averages 25.6 s against the base median of 28.1 s (−8.6%), and PPSA34008 31.1 s against 34.5 s (−10.0%).A separate run on
main+ #12154 + #12203 + #12270 measured the same change at −15% to −18% (PPSA20423 4.6 → 3.9 s, PPSA07923 22.7 → 19.1 s, PPSA34008 21.6 → 17.7 s), with identical output.This measures conversion only, not anything at game run time.
MacOsImage.cppcompiles in this Windows build, but I haven't run a macOS conversion.Current refresh source proofs and unedited test logs, SHA-256
083d2668903c75794f1b3295acd852e3dd5bd106a6c2f30256aa518f7925a023.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-28T08:52:48Z.
Review: CHANGES_REQUESTED
The vector conversion is well covered by the relinker tests and the conversion-time measurements; I found no output-order or membership issue in the diff. I cannot approve the
perf-labeled PR under the repository’s current rule, though: it still hasperf numbers missing, and the required same-title/same-sceneaps5-summary.jsonllines, attached traces, andtrace_digest.pyoutput are absent. Please add the report required by the currentCONTRIBUTING.md/performance form, or get the repository rule clarified for this non-runtime relinker benchmark before removing that gate. The current CI relinker matrix passes; author-reported tests are 372 CTests x3.Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T11:33:46Z.
Review: COMMENTED
macOS evidence for the parts the body says are untested (
MacOsImage.cppwas only compiled on Windows).Setup: macOS arm64, Apple clang, Ninja, Release,
-DANYPS5_RELINKER_ONLY=ON. Headdf77e4df6d(stacked on #12154ad732ce0ec) againstmain3a40945e62.Tests:
ctest362/362 pass at this head.check_conventions.py --base upstream/mainpasses, andgit merge-treeagainstmainis clean.Output differential, including the macOS writer: I relinked 5 homebrew payload ELFs (ftpsrv, websrv, kstuff, elfldr, prosperotrace; none are game titles) with
--skip-syscall-check --skip-sce-module --registryin the Linux,--windowsand--macosmodes, using bothmainand this head. All 15 pairs exit 0 and the outputs are byte-identical.WriteMacOsImage→ScanTlsandWindowsPePatcher→WindowsTlsBuilder::Buildboth callCollectunconditionally, so the 10 Windows/macOS runs go through the changedlower_boundcallers. None of these inputs has a PT_TLS, so the TLS-access loop bodies themselves are only exercised by the CTests.Mutants on the stack:
sort(48 CTests fail, 6/6 corpus outputs differ) and dropping the finalunique(40 fail, 2/6 differ).staticTargetssort orunique, thedecoded[offset]bitmap dedupe, and the newreachable address outside its sectionthrow.The survivors make sense: the dedupes only affect speed because of the final sort+unique, and the throw is a defensive guard. They come from #12154's commits, so I'm noting them here rather than asking for changes.
One fix requested (new warning):
CodeInstructionCollector.cpp:584return std::move(instructionList);triggers clang-Wpessimizing-move("moving a local object in a return statement prevents copy elision").main's version of the file is warning-free under-Wall -Wextra.return instructionList;gets NRVO and a guaranteed move, and with it the file compiles with 0 warnings. Theconst auto& instructions = instructionList;alias doesn't block this.The
perfevidence question is still open (#12358); I'm not taking a position on it.AI-assisted: yes (Claude Code)