perf(relinker): single-pass CFG instruction decoding and zero-copy text span #2304
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2304"
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 HamidRezaLS on 2026-10-09T15:09:15Z.
What
Optimizes the CFG discovery fixed-point loop and PLT compaction in
core/relinker:std::vectordeep-copying of the.textsegment inCodeInstructionCollector::Collectwith a zero-copystd::span<const uint8_t>. Eliminates copying the full code segment into newly allocated vectors on every root-discovery iteration.decodedInstructionsandsectionReachable). Instructions are now decoded exactly once across the entire binary instead of re-disassembling previously visited blocks from scratch on every iteration (O(N)vs O(K . N)).PltCompactor::CompactPlt, validates all 4 structural bytes of the canonical 16-byte PLT thunk (0xFF 0x25 ... 0x68 ... 0xE9) before querying slots, skipping non-PLT indirect jumps immediately. Switched slot tracking fromstd::maptostd::unordered_map.Tested
ctest --output-on-failure:strict_nid_filter(Passed)rela_bounds(Passed)to_intel_linux_stubs(Passed)guest_intel_trampolines(Passed)amd64_only_converter(Passed)tls_function_coverage(Passed)python3 tools/check_conventions.pypasses with zero warnings.sha256sumon multi-pass test binaries and a 40,000-function image; hashes matched 100% identically down to the byte:SHA256: e6a211ff0fb6c99933368b98910135f5617f6f4defdcbc78657ad43dd67de571Benchmark (Measured with
/usr/bin/time -v):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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:15:21Z.
Could you give before/after conversion times for a real title's executable (title ID,
unused-filtermode used)? The 22.17 → 5.59 s figure is on a synthetic 40,000-function image, and perf PRs need numbers on real input for the change itself (#218). If a real conversion shows no measurable difference, I'd close it.Imported from boykopovar/AnyPS5. Originally posted by HamidRezaLS on 2026-10-09T21:12:43Z.
@oneandonlydean these are the before/after conversion timings on a real commercial PS5 title using
unused-filter=2:Test Environment & Workload
PPSA15552, SDK 6.00).textsegment (5.56M reachable instructions, 51.1k live functions, 3.3M address-taken roots traversed)In-Title Benchmark Results (
unused-filter=2)1. Windows Conversion Target (
--windows unused-filter=2)main)1529b661...1529b661...Full Windows SHA256:
1529b661933beef7aa3fbb7c7c71f9e0faa038c34f4df224ff6b38fdf4de79df2. Linux Conversion Target (
unused-filter=2)main)e5033cf9...e5033cf9...Full Linux SHA256:
e5033cf9904edc48b9ef45f09ca7ac14cbf6dfe6656c921681dd2Summary
Because commercial game engines have deep vtable structures and address-taken indirect branches,
unused-filter=2runs multiple root discovery passes..exeand.elffiles match the baseline byte-for-byte (sha256sum).tell me if you would like me to update the PR description with these metrics
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:18:31Z.
The PPSA15552 numbers answer the perf question. It now conflicts with main in
CodeInstructionCollector.cppandControlFlowGraph.cppafter #2238; please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:49:07Z.
Rebased onto current main as Dean asked: the conflict in
CodeInstructionCollector.cpp/ControlFlowGraph.cppwas the newfollowCodeAddressesparameter from #2238. The persistent-reachable overload now takes it (the collector passestrue, the other overloads keepfalseby default). Relinker build and the 57 relinker ctest tests pass on the rebased tree; merging on green CI.