Hi all,

I’ve completed the benchmarks based on the guidance in the thread.

In short:

Cold-start measurements (fresh PHP process per run) show no meaningful 
difference between direct instantiation and reflection-based autowiring. 
Process startup dominates, and reflection overhead is effectively lost in the 
noise.
Warm-process benchmarks show a consistent ~3-4x overhead for runtime autowiring 
compared to direct instantiation, even with request-scope constructor plan 
caching. This appears to be a model-level cost rather than something easily 
eliminated by implementation details alone.

Based on these results, I don’t see a lazy-proxy-like engine-only win here. 
Userland implementations already seem close to the practical ceiling for 
runtime autowiring, and further gains would likely be incremental.

Given that, I agree this does not currently make a compelling case for a core 
addition, and that runtime autowiring remains better addressed in userland or 
framework-specific solutions.

Thanks to everyone who provided feedback and guidance.

Best regards,

Zoli



eng. ANDRÁS Zoltán-Gyárfás
---------------------------------------
tel: +40 745 797 798
mail: [email protected]

> On 30 Dec 2025, at 20:41, Marco Pivetta <[email protected]> wrote:
> 
> Hey Zoli,
> 
> On Tue, 30 Dec 2025 at 08:17, ANDRÁS Zoltán Gyárfás <[email protected] 
> <mailto:[email protected]>> wrote:
>> If you have any guidance on what you would consider a representative 
>> benchmark or a meaningful performance threshold for “worth moving into 
>> core”, I’d appreciate it.
>> 
> 
> In the grand majority of cases where autowiring is meaningful (at least for 
> PHP), you care about a "cold start" of the application (although that's 
> changing with ReactPHP/FrankenPHP/Roadrunner/etc.).
> 
> You may design a PHPBench or Hyperfine test that:
> 
> * starts a PHP process, autowires something, shuts down. Hyperfine helps a 
> lot here.
> * repeats the above, but within a warm process (classes already loaded, tight 
> loop repeating the operation). PHPBench is a bit more precise here.
> 
> You probably care about these cases:
> 
> * zero-arguments constructor
> * simple concrete class references
> * default constructor arguments
> * resolvers
> * autowiring of a complex multi-level structure
> 
> In all the above cases, you probably care about the usage with autowiring API 
> vs the usage via direct instantiation, so you can see the exact overhead.
> 
> Marco Pivetta 
> 
> https://mastodon.social/@ocramius
> 
> https://ocramius.github.io/
>  

Reply via email to