Category
performance · AOT compile pipeline
Problem
Every phpc build recompiles the fixed runtime helper set from scratch. Phase profile of phpc build -o /tmp/hello examples/000-HelloWorld/example.php (php-compiler:22.04-dev, LLVM 9, breadcrumb polling via PHP_COMPILER_JIT_PROGRESS_FILE, 2026-07-04, wall 2.66 s):
| Phase |
Wall |
Share |
| PHP boot + autoload + JIT context init |
0.66 s |
25% |
| user-script parse + lower |
0.06 s |
2% |
runtime JitHelper lowering (WeakRefRegistry, ErrorSilence, DirHandle, ParseStrNative, Progress, … — repeated runtime_parseandcompile_begin cycles) |
1.24 s |
47% |
| LLVM emit object |
0.61 s |
23% |
| link |
0.14 s |
5% |
The helper set is identical for every user script — none of it depends on user code. Larger web examples pay 5.3 s (006) for the same reason.
Proposal (split compilation into parts)
- Cache the runtime TU: lower all JitHelpers once into a versioned
build/user-runtime.o (key: compiler tree hash + LLVM version), reuse across builds — the bootstrap path already has the TU-sidecar mechanics (PHP_COMPILER_M3_* emit-helper TUs, prelinked/bootstrap-gen0 blobs); user builds should get the same treatment.
- Script TU: lower only
{main} + user functions per build; link script.o + user-runtime.o + runtime C objects.
- Optional: parallel emit when >1 TU is dirty.
Expected: hello-world ≈ 2.7 s → ≈ 0.9 s (boot + tiny lower/emit + link); web examples similar absolute savings.
Done when
Category
performance· AOT compile pipelineProblem
Every
phpc buildrecompiles the fixed runtime helper set from scratch. Phase profile ofphpc build -o /tmp/hello examples/000-HelloWorld/example.php(php-compiler:22.04-dev, LLVM 9, breadcrumb polling viaPHP_COMPILER_JIT_PROGRESS_FILE, 2026-07-04, wall 2.66 s):runtime_parseandcompile_begincycles)The helper set is identical for every user script — none of it depends on user code. Larger web examples pay 5.3 s (006) for the same reason.
Proposal (split compilation into parts)
build/user-runtime.o(key: compiler tree hash + LLVM version), reuse across builds — the bootstrap path already has the TU-sidecar mechanics (PHP_COMPILER_M3_*emit-helper TUs, prelinked/bootstrap-gen0 blobs); user builds should get the same treatment.{main}+ user functions per build; linkscript.o + user-runtime.o + runtime C objects.Expected: hello-world ≈ 2.7 s → ≈ 0.9 s (boot + tiny lower/emit + link); web examples similar absolute savings.
Done when
phpc buildof a different script skips helper lowering (cache hit logged)bin/compile.phpcolumn drops accordinglybenchmarks/README.mdphpc-build column regenerated