perf(relinker): reserve the reachable instruction set before the graph walk #12270
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12270"
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-28T06:20:12Z.
What
Reserve capacity for an initially empty reachable-address set in the compatibility
buildGraphAPI, using a quarter of the input text size. A nonempty set keeps its existing capacity policy. Graph traversal and resulting addresses are unchanged.Main now includes #13825, whose incremental byte-state API is used by
CodeInstructionCollector; this reservation no longer affects that production hot path. The earlier conversion speedups below describe the old implementation and do not establish a current-main conversion or runtime improvement. The remaining compatibility-API benefit has not been remeasured.Tested
Current-main refresh (2026-11-01): linear head
ddbcfaa792deef1467ec4617a5949f66e818b713on main93dbd0f82aea. Main's incrementalExtendControlFlowGraphand byte-per-offset reached state are retained. 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. No new Windows, macOS, title or performance measurement.Historical qualification, before #13825:
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).main0cd07dc4abagainst this branch on it, both Release. Each ranrelinker --windows --skip-sce-module --registry <eboot.elf> app.exeon four titles' executables, alternatingmainand this branch, 3 rounds, wall time in ms:mainapp.exesha256 (identical on both)62c8241f…0b1db4e7…6465a4b2…f2f65cf7…app.registry.jsonis byte-identical too in every round.mainplus #12154 and #12203. Most samples were inCodeInstructionCollector::CollectandbuildGraph, much of it instd::unordered_setinsert and rehash. With both of those PRs applied, the same change takes PPSA07923 from 27.7 s to 22.8 s with identical output, so it adds to them rather than overlapping.This measures conversion only, not anything at game run time. Those original measurements did not test Linux or macOS and do not apply to the current hot path.
Independent macOS follow-up: Apple clang/libc++, head
96bbd3af91merged onto main2227f13661, 378/378 CTests and byte-identical outputs/registries for nine homebrew conversions across 15 alternating rounds. Small-input speed differences and memory costs are reported separately; these are the reviewer's measurements: rooklz's report. The offline performance-report format remains awaiting maintainer guidance in discussion #12358.Current refresh source proofs and unedited test logs, SHA-256
8c0931882d0f81671b3606f9714526651a605ffbb291bd9bfffb2480968a7d1f.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:56:20Z.
Review: COMMENTED
The reported conversion timings are directly relevant to this offline relinker change: paired runs on the same machine and inputs, alternating revisions, with identical output hashes and repeat counts. A game runtime capture and
trace_digest.pycannot measure this pre-launch conversion, as you explain. However,CONTRIBUTING.mdcurrently says PRs titledperf(...)need two validaps5-summary.jsonllines, and the automated label still marksperf numbers missing. I do not see a way to satisfy that runtime-specific format for this operation. I’m leaving this as a comment rather than requesting an irrelevant game capture; please get maintainer guidance on whether the rule has an offline-tool exception or what alternate report format they want. No code correctness issue found in the one-line reserve change, and the current relinker/ASan CI matrix passes.Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T11:59:03Z.
Review: COMMENTED
Independent run on the platform the body lists as untested: macOS 26 arm64 (Apple clang, libc++), Release,
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON.Setup. Head
96bbd3af91merged onto currentmain2227f13661(clean; the diff against main is still this one line). I compared it with amainbuild from the same compiler and flags.buildGraphis present in the macOS binary (nm), so the walk runs here on libc++'sunordered_setand not only on libstdc++.--skip-syscall-check --skip-sce-module --registry, in all three output modes. 15 rounds, alternating which build runs first, median wall ms:mainregistry.jsonare byte-identical betweenmainand this PR in all 9 cases, on every round./usr/bin/time -l,--macos, 3 runs each): kstuff goes from 22.4–23.3 MiB to 24.1–24.2 MiB (about +1.8 MiB). websrv is unchanged (15.9 vs 15.9 MiB).codeSize / 4reservation can be larger than the final reachable set, so on small inputs the bucket array shows up in the peak.No correctness concerns: one
reserveguarded byempty(), walk order and outputs unchanged. I'm leaving this as a comment because the open question is the maintainers' perf-report format for offline tools (#12358), not the code.AI-assisted: yes (Claude Code)