Skip to content

Cut cold-build CPU 5.4x: stop duplicating big internal bodies across split parts; resolve manifest paths from the manifest directory - #558

Merged
blacktrs merged 3 commits into
mainfrom
perf/dyninl-hidden
Nov 2, 2026
Merged

blacktrs merged 3 commits into
mainfrom
perf/dyninl-hidden

Conversation

@blacktrs

@blacktrs blacktrs commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Why

A cold manticore build of examples/symfony-app took 29:30 wall / 5866 s CPU. Almost all of it was clang -O2 on the split IR parts, and most of that was the same functions compiled again and again.

Findings

  • __mir_dyninl_* (the shared fallback of the __call forwarders) is one 326k-line, 14.6 MB function emitted define internal. SplitModule copies an internal body into every part that calls it, so 48 of 65 parts carried their own copy: ~700 MB of duplicate IR. Compiling p13 alone: 94 s with the copy, 17.8 s without.
  • After that, ~190 MB of duplicates remained: closures and property accessors of 50-650 KB called from 47-64 parts.

Changes

  • dyninl helper is emitted hidden instead of internal, so it lives in one part.
  • SplitModule::promoteLarge: an internal body of at least 32 KB with two or more callers is promoted to a single hidden definition. Both split paths (run, runFile) apply it.
  • declareFromDefine ended the signature at the last ) of the header; a closure header ends with prefix [...] data, so it now stops at the paren matching the first one.
  • manticore build <path>/manticore.json resolves src, entry, output and the Composer root against the manifest's directory, not the caller's cwd. bin/build writes its temp manifest beside manticore.json, and tests/aot/runner/manticore.json is rewritten relative to its own directory.

Measured (symfony-app, cold object cache, loaded machine)

CPU (user) wall binary
main 5866 s 29:30 400 MB
dyninl hidden 1249 s 7:41 197 MB
+ promoteLarge 1086 s 7:17 180 MB

Verification

Not run

Linux gate, difftest, fixpoint, tools/ext_smoke.sh (its manifests still use repo-root paths).

…rnal bodies so split parts stop duplicating them (symfony-app cold build 5866 s -> 1086 s CPU)
…and resolve the compiler's own directory before build changes cwd
@blacktrs
blacktrs merged commit 99259a1 into main Nov 2, 2026
53 of 55 checks passed
@blacktrs
blacktrs deleted the perf/dyninl-hidden branch November 2, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant