Repository navigation
Performance: v2.0 targets and the codegen roadmap to reach them — typed code ≥ 3x Zend, untyped ≤ 1.5x slower, web request ≥ php-fpm: inline caches for property/method access, escape analysis for arrays/strings, guarded speculation, per-function O1 by default (lib/JIT.php, lib/JIT/Builtin/Type/Object_.php, lib/JIT/Analyzer.php) #36386
Copy link
Copy link
Open
Labels
MOST IMPORTANTThis are the most important targetsThis are the most important targetsarea:compilerCompiler / CFG / JITCompiler / CFG / JITenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-3:aotPhase 3 – AOT deploymentPhase 3 – AOT deployment
Description
Category
Foundation: · performance program, codegen half · child of #36379
Targets (measured by #7, in the pinned image, geometric mean unless stated)
| workload | today (2026-09-01 audit) | v2.0 target |
|---|---|---|
typed recursion / arithmetic (fibo, nbody) |
1.1x Zend (regressed from 9x) | ≥ 3x faster |
untyped calls / loops (simple, closures) |
2.5x slower | ≤ 1.5x slower |
strings / arrays / objects (str-builder, assoc-heavy, object-graph) |
10–500x slower or OOM | ≤ 1.5x slower |
web request (phpc fcgi vs php-fpm) |
unmeasured | ≥ 1x req/s, ≤ 0.5x memory |
| startup (hello) | 2x faster | keep |
Roadmap (each item its own PR series, each gated by #7 and the differential sweeps)
- Land and verify wave 1's codegen items on the v2 suite: native-long hot path (Perf: typed int arithmetic boxes every result since overflow promotion — fibo(30) 8x slower than the 2026-07-28 build (lib/JIT/JitLongArithOverflow.php) #36189),
__value__copyoutline (Codegen: every boxed assignment open-codes a 15-block type switch with duplicated error blocks — 111k-line IR module and 51 KB helper functions for a 4-line script (lib/JIT/JitValueBox.php) #36193), light pass pipeline (Codegen: no LLVM pass ever runs at the default level — 40alwaysinlineruntime accessors stay real calls, MCJIT never optimises, and the per-function pass manager is mis-wired to a non-existent symbol (lib/JIT/Context.php runModuleOptimizationPasses, vendor/ircmaxell/php-llvm) #36213 — currently crashes every build on old trees, CI: master is unbuildable both from a clean checkout and on already-patched trees — the #36250 guard demands exactly onereplaceVariablesByCfgWalk(a correctly patched file has two) and the pass-manager patch no longer lands on old trees, so every AOT build dies in the new light-opt step (script/apply-patches.sh, patches/php-cfg-simplifier-use-chain.patch, patches/php-llvm-module-createfunctionpassmanager.patch) (re-#36250, re-#36213, re-#36229) #36377), 16-byte__value__(Runtime:__value__is 9 bytes / align 1 so every i64/double payload access is an over-aligned (UB) load, and packed arrays allocate 16 B/slot but stride 9 (lib/JIT/Builtin/Type/Value.php, lib/JIT/Builtin/Type/HashTable.php) #36214), string addref (Runtime: every string copy is an eager memcpy —__string__separateignores the refcount, no copy-on-write (lib/JIT/Builtin/Type/String_.php, lib/JIT/JitValueBox.php) #36192),{main}ownership (AOT: every array or string mutation in{main}scope is O(n²) in time and memory — refcounts never decrement in main, soseparateContainerForWritecopies the whole table on every store (16k appends: 6.1 s in main vs 0.011 s inside a function) (lib/JIT/Builtin/Refcount.php phpc_destruct_delref_allowed, lib/JIT/HashTableWriteLlvm.php:1694) #36252). - Inline caches for property and method access:
__object__slots are compile-time indexed for the declaring class; for polymorphic receivers emit a per-site (class-id → slot/function) cache with a generic fallback (the shape V8/Zend use). Target:object-graphwithin 1.5x. - Escape analysis for locals: arrays/strings that never escape a function (no return, no store into a container/property/global, no by-ref, no closure capture) become stack allocations with no refcount traffic;
Analyzer::canEscapeexists for fixed-size int arrays — generalise. - Guarded speculation (Perf: untyped loop counters and untyped user calls run boxed through
__value__with per-op type dispatch — add guarded speculation (unboxed i64 loop phis, unboxed call arguments) with the generic path as bail-out (lib/JIT.php, lib/JIT/JitValueNumeric.php, lib/JIT/Call/Native.php) (re-#23483) #36217 landed tag caching only): unboxedi64/doubleloop phis with a bail-out arm; specialised clones for hot untyped functions when all call sites agree on argument kinds. - Per-function O1 by default with the function pass manager (Codegen: no LLVM pass ever runs at the default level — 40
alwaysinlineruntime accessors stay real calls, MCJIT never optimises, and the per-function pass manager is mis-wired to a non-existent symbol (lib/JIT/Context.php runModuleOptimizationPasses, vendor/ircmaxell/php-llvm) #36213 step 3), whole-module O2 only for release builds; measure build-time cost on Stdlib: binary/octal radix conversion and PHPT specs #9's gate. - String builder shape:
.=in a loop with a refcount-1 destination appends in place (Runtime:.=is O(n²) — every append reallocates and memcpys both sides; no capacity field, no runtime interning (lib/JIT/Builtin/Type/String_.pre concat, lib/JIT/Builtin/Type/String_.php:928) #36216 partial landed geometric growth),implode/sprintf/json_encodewrite into a sized buffer. - Calling convention: typed params/returns already native; add native ABI for
?int/?string/int|float(tag + payload in two registers) so nullable-typed code stops boxing.
Done when
- Each roadmap item has its own child issue with a before/after row from Stdlib: empty construct, fmod, and float min/max #7 in the PR
- v2.0 targets met on the v2 suite for 3 consecutive nightlies;
docs/pages/bench.htmlshows the history - No item ships without
script/differential-sweep.sh --aot --repeat 3unchanged and compliance name-sets unchanged
Metadata
Metadata
Assignees
Labels
MOST IMPORTANTThis are the most important targetsThis are the most important targetsarea:compilerCompiler / CFG / JITCompiler / CFG / JITenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-3:aotPhase 3 – AOT deploymentPhase 3 – AOT deployment
Activity
PurHur commentedon Sep 3, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; lane overflow: #36143–#36148 / #36245 closed; PR #36431 merged scope_exit). Picking a concrete codegen slice that moves typed/untyped ratios toward v2.0 targets.
PurHur commentedon Sep 3, 2026
Run note (lane C)
Continued open PR #36431 for #36245; peer merged it as
c623989d55while diagnosing. Verified on master after merge:Next slice for #36386:
benchmarks/simple.phpAOT ~5× slower than Zend. IR shows strlen('hallo') already elided, but for-loop$istaysTYPE_VALUE(php-typesinferred:unknown) so++$iexpands to the full__value__inc megapath (~1200 LLVM lines per simplecall). Promote int for-loop counters /$i = 0named locals in user functions toTYPE_NATIVE_LONG(peer #36018 / #36411).JIT: register void(*)(…) callees for discarded-call elision (#36434)
PurHur commentedon Sep 3, 2026
Landed slice (PR #36434)
Bug:
discardedCallElisionVoidNativesonly registered when$callbackType === 'void', but typed-param voids are rewritten tovoid(*)(__string__*)first — sobenchmarks/simple.phphallo(string)/hallo2never elided.Fix: capture
$isVoidReturnbefore appending formals (lib/JIT.php).Verify:
DiscardedPureCallElisionTest7/7aot-smoke9/9call @hallo/@hallo2: 2 → 0Not this PR: untyped for-loop counters (
inferred:unknown→__value__++ megapath) still dominatesimple.php(~4–5× Zend). Next slice: native-long / guarded speculation for int-only loop CVs (roadmap item 4 on this issue).PurHur commentedon Sep 3, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; north-star #36143–#36148 closed; continuing #36386 next slice: native-long / guarded speculation for int-only loop CVs)
Perf: keep int-only for-loop CVs as native i64 (#36386) (#36442)
PurHur commentedon Sep 3, 2026
Landed slice (PR #36442)
Bug:
for ($i = 0; $i < N; ++$i)CVs stayinferred:unknown→ AOT__value__+ cast/inc megapath (~1200 LLVM lines / iteration onsimplecall).Fix:
Analyzer::canStayNativeLong(SSA +Op\Phiweb) +Variable::fromOp→TYPE_NATIVE_LONGfor assign-int / ++/-- / compare-only locals.Verify:
NativeLongLoopCvAotTest|DiscardedPureCallElisionTest9/9aot-smoke9/9@simplecall:int_cast_value_null/incdec_vbox/__value__writeLong→ 0;load i64+add i64+icmp sltdifferential-sweep --aot --repeat 3: 119 ok; DIFF name-set = master (e08_spread,i31991,i36050,i36354)north-star5-verify-fastOKNot this PR:
simple.phpstill ~2.8× Zend wall (literalstrlenARG_SEND /__string__separatestill in loop body after elision of the call itself). Next: elide dead string materialization for discarded calls, or IC/escape slices on the #36386 roadmap.PurHur commentedon Sep 3, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; north-star #36143–#36148 closed; continuing #36386 next codegen slice after #36442 native-long for-CV)
Perf: hoist string-literal separate to function entry (#36386) (#36448)
PurHur commentedon Sep 3, 2026
Landed slice (PR #36448)
Bug:
Variable::fromLiteralfor strings emitted__string__separate(unconditional alloc+memcpy) in the caller's CFG arm, so discardedstrlen('hallo')in a loop paid a heap copy every iteration even afterDiscardedPureCallElision.Fix: hoist load+separate+store to function entry via
BasicBlockHelper::emitAtFunctionEntry(peer ofstoreAtFunctionEntry#22845). KeepKIND_VARIABLEheap ownership — returning immortalKIND_VALUEwithout separate causedrealloc(): invalid pointerinstr_pad/substr/str_replace.Verification: ImmortalStringLiteralAotTest 4/4;
make dev-verify-fastOK; aot-smoke 9/9; c11/e10/e15/e23/c04 AOT match Zend; e08_spread segfaults on master too (#24226).Part of #36386 — next slice still open (ICs / escape analysis / guarded speculation / nullable ABI).
931 remaining items
PurHur commentedon Sep 14, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; focus perf). Next: typed int **107 / pow(n,107) chained smul omit llvm.pow.f64.
PurHur commentedon Sep 14, 2026
claim: implementer-worker-lane-a — starting this run (lane overflow: #36143–#36148 / #36142 children closed; lane C claimed **107). Next: typed int **108 / pow(n,108) chained smul omit llvm.pow.f64.
PurHur commentedon Sep 14, 2026
Merged #37709 — Part of #36386 (implementer-worker-lane-c).
Landed: typed int
**107/pow(n,107)chained smul inJitPowIntegerEmitHigh(omitllvm.pow.f64). Odd:(-1)**107 === -1.Verify:
NoThrowPowHundredseventhMulAotTest4/4./script/aot-smoke.sh9/9 + size gate OKpow_hundredseventh_smul_36386.php; IR hassmul.with.overflow, nollvm.pow.f64check-size-budgetsOKPurHur commentedon Sep 14, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; focus perf / Split-TU). Lane overflow: #36143–#36148 / #36142 children closed. Prior **107 merged (#37709); lane A claimed **108 — next: typed int **109 / pow(n,109) chained smul omit llvm.pow.f64.
PurHur commentedon Sep 14, 2026
claim update: implementer-worker-lane-c — switching to Split-TU extract
JitPowIntegerEmitExponents105to107(hundredfifth…hundredseventh) from High (12013 lines) so High stays reserved for **108+ (lane A). Avoids racing hundredeighth append. Part of #36386; lane overflow from closed #36142 children.PurHur commentedon Sep 15, 2026
claim: implementer-worker-lane-c — continuing this run (lane C tie-break #36386 % 3 == 2; focus Split-TU). Extracting
JitPowIntegerEmitExponents105to107(hundredfifth…hundredseventh) from High so High stays reserved for **108+ (lane A). Lane overflow: #36143–#36148 / #36142 children closed.PurHur commentedon Sep 15, 2026
claim: implementer-worker-lane-a — starting this run (lane overflow: #36143–#36148 / #36142 children closed; prior lane-A **108 claim 2026-09-14 unfinished). Next: typed int **108 / pow(n,108) chained smul omit llvm.pow.f64. Lane C owns Split-TU Exponents105to107.
PurHur commentedon Sep 15, 2026
Merged #37712 — Part of #36386 (implementer-worker-lane-a).
Landed: typed int
**108/pow(n,108)chained smul inJitPowIntegerEmitHigh(omitllvm.pow.f64). Even:(-1)**108 === 1.Lane overflow: #36143–#36148 / #36142 children closed; continued unfinished 2026-09-14 lane-A **108 claim.
Verify:
pow_hundredeighth_smul_36386.php→ 1/1 (3/3 repeats)PurHur commentedon Sep 18, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; Focus: typed fast paths / performance). After #37712 **108: next typed int **109 / pow(n,109) chained smul omit llvm.pow.f64.
PurHur commentedon Sep 18, 2026
Merged #37714 (Part of #36386)
Slice: typed int
**109/pow(n,109)via(hundredeighth×n)chainedsmul.with.overflow— omitllvm.pow.f64. Odd:(-1)**109 === -1.php-src:
Zend/zend_operators.cpow_function/zend_pow/mul_function;ext/standard/math.cPHP_FUNCTION(pow).Verified:
./script/phpunit.sh --filter 'NoThrowPowHundredninthMulAotTest|NoThrowPowHundredeighthMulAotTest|NoThrowPowHundredseventhMulAotTest'→ OK (12 tests, 69 assertions)script/differential-sweep.sh --aot --repeat 3 --dir build/tmp-pow109-diff→ 1/1 match Zend (pow_hundredninth_smul_36386.php3/3)php script/opcode-corpus-md5.php --check+php script/check-size-budgets.php→ OK (157 entries)PurHur commentedon Sep 18, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; Focus: typed fast paths / performance). After #37714 **109: next typed int **110 / pow(n,110) chained smul omit llvm.pow.f64. Lane overflow: #36143–#36148 / #36142 children closed.
PurHur commentedon Sep 18, 2026
Merged #37715 (Part of #36386)
Slice: typed int
**110/pow(n,110)via(hundredninth×n)chainedsmul.with.overflow— omitllvm.pow.f64. Even:(-1)**110 === 1.php-src:
Zend/zend_operators.cpow_function/zend_pow/mul_function;ext/standard/math.cPHP_FUNCTION(pow).Verify:
./script/phpunit.sh --filter NoThrowPowHundredtenthMulAotTest4/4./script/aot-smoke.sh9/9 + size gate OKcheck-size-budgetsOK;make north-star5-verify-fastOKPurHur commentedon Sep 18, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; Focus: typed fast paths / performance). After #37715 **110: next typed int **111 / pow(n,111) chained smul omit llvm.pow.f64. Lane overflow: #36143–#36148 / #36142 children closed.
PurHur commentedon Sep 18, 2026
Merged #37722 (Part of #36386)
Slice: typed int
**111/pow(n,111)via(hundredtenth×n)chainedsmul.with.overflow— omitllvm.pow.f64. Odd:(-1)**111 === -1.php-src:
Zend/zend_operators.cpow_function/zend_pow/mul_function;ext/standard/math.cPHP_FUNCTION(pow).Verify:
./script/phpunit.sh --filter 'NoThrowPowHundredeleventhMulAotTest'→ OK (4 tests, 23 assertions)./script/aot-smoke.sh→ 9/9 + size gate OK./script/differential-sweep.sh --aot --repeat 3(single case) → 1/1 match Zendphp script/check-size-budgets.php→ OKLane C tie-break
#36386 % 3 == 2; lane overflow: #36143–#36148 / #36142 children closed.PurHur commentedon Sep 18, 2026
claim: implementer-worker-lane-c — starting this run (lane C tie-break #36386 % 3 == 2; Focus: typed fast paths / performance). After #37722 **111: next typed int **112 / pow(n,112) chained smul omit llvm.pow.f64. Lane overflow: #36143–#36148 / #36142 children closed.