@@ -267,6 +267,51 @@ Measured in the July 2026 benchmarks (callback-free absorptions gained
267267 measuring ≤0.5% get reverted — the failure mode is silent no-gain, and
268268 unproven native code is pure maintenance debt.
269269
270+ ## Performance frontiers (July 2026)
271+
272+ Status quo, measured on PHPStan's own single-threaded self-analysis of ` src/ `
273+ (interleaved A/B, user CPU): ** 59.6s with the extension vs 77.3s without —
274+ a 23% gain** . The remaining cost is structural, not hotspot-shaped: SPX
275+ counts ~ 535M userland calls spread over 20K functions, the top 120 functions
276+ by exclusive time explain only ~ 15% of the run, and an on-CPU sample
277+ attributes 42.7% to VM call mechanics (frame setup, argument passing,
278+ return-type checks), 23.3% to other VM opcodes, ~ 8% each to memory/GC and
279+ syscalls — and only 2.3% to this extension's own code. Every further tier
280+ therefore means absorbing whole call subtrees, not porting leaf bodies.
281+
282+ What each gain level over the no-extension baseline requires:
283+
284+ - ** 30%** (−5.5s) — reachable with targeted ports and known PHP-side fixes:
285+ a native ` ExpressionResultStorage ` (the fiber bridge's per-expression
286+ before-scope table; its ` SplObjectStorage ` copies and inserts allocate
287+ ~ 3GB per run), the ` CachedParser ` content-key re-read fix (72K full-file
288+ reads per run just to compute LRU keys), ` getName() ` /return-type memos in
289+ better-reflection (5.3M calls survive), member-lookup pricing
290+ (` ObjectType::getMethod ` + ` getMethodReflection ` + dynamic-extension
291+ registry sweeps, ~ 1.9M calls), and the FileTypeMapper cache hydration
292+ format.
293+ - ** 50%** (−20.9s) — requires the ** native expression engine** : the
294+ ` NodeScopeResolver ` expression walk, ` ExprHandler ` dispatch loop,
295+ ` ExpressionResult ` /holder plumbing and scope-table mutation move into C++,
296+ crossing back to PHP only for ` Type ` -level operations and third-party
297+ extensions. ` MutatingScope::getType ` alone is ~ 22% of the run inclusive.
298+ Estimated 150–250M absorbed frames ≈ 10–15s; a quarter-rewrite, to be
299+ approached one handler chain at a time.
300+ - ** 70%** (−36.4s) — "everything PHPStan-owned is native": on top of the
301+ expression engine, a native ` Type ` kernel (` isSuperTypeOf ` /` accepts ` /
302+ union/intersection graphs operating natively, PHP ` Type ` objects as
303+ views), the statement-level walk, and native reflection-data storage
304+ (extending the arena). The floor left in PHP — rule bodies, vendor
305+ better-reflection, phpdoc-parser, third-party plugins — is an estimated
306+ 15–22s, so this target sits * at* the boundary of what a hybrid can do.
307+ - ** 90%** (−51.9s) — below any architecture that keeps PHP rules, dynamic
308+ extensions and vendor parsers. This is not a port but a ground-up native
309+ analyzer; extension-ecosystem compatibility is the casualty. The realistic
310+ ceiling for the hybrid approach is ~ 60–75%.
311+
312+ (Benchmarks include the ShipMonk dead-code plugin, ~ 8% of the self-analysis
313+ run — third-party PHP that no port removes.)
314+
270315## Testing
271316
272317``` bash
0 commit comments