Faster AutowiredAttributeServicesExtension->processParameters() by staabm · Pull Request #4489 · phpstan/phpstan-src

@staabm

even after #4482 we still see this method call on the hot path.

grafik


running PHPStan on the PHPStan-PHPUnit extension tests show this path as the slowest part of the run:

grafik

ondrejmirtes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole issue of something called a million times could be avoided by restructuring how vendor/attributes.php looks like, so that we don't have to iterate over so many things so many times.

@staabm

The whole issue of something called a million times could be avoided by restructuring how vendor/attributes.php looks like

I don't want to customize the vendor/attributes.php too much, so we stay as long as possible compatible with the upstream.
(at least not for only 5% gains).

I restructured the loops and the bootleneck no longer exists

grafik

@staabm

before

➜  phpstan-phpunit git:(2.0.x) hyperfine vendor/bin/phpunit                                                                    
Benchmark 1: vendor/bin/phpunit
  Time (mean ± σ):      2.636 s ±  0.066 s    [User: 2.032 s, System: 0.183 s]
  Range (min … max):    2.556 s …  2.739 s    10 runs

with this PR

➜  phpstan-phpunit git:(2.0.x) hyperfine vendor/bin/phpunit
Benchmark 1: vendor/bin/phpunit
  Time (mean ± σ):      2.570 s ±  0.051 s    [User: 1.974 s, System: 0.180 s]
  Range (min … max):    2.451 s …  2.625 s    10 runs

VincentLanglet

@staabm

@ondrejmirtes