Skip to content

Lazily initialize AggregateSourceLocator to speedup bootstrapping#5577

Merged
staabm merged 3 commits intophpstan:2.1.xfrom
staabm:lazy-loca
May 1, 2026
Merged

Lazily initialize AggregateSourceLocator to speedup bootstrapping#5577
staabm merged 3 commits intophpstan:2.1.xfrom
staabm:lazy-loca

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented May 1, 2026

implement the idea described in #5538 (comment)

refs phpstan/phpstan#14072

=> 25% faster end-to-end analysis


review with whitespaces ignored


with foo.php

<?php

echo "";

before this PR

➜  phpstan-src git:(2.1.x) ✗ hyperfine 'php bin/phpstan analyze foo.php --debug -vvv'
Benchmark 1: php bin/phpstan analyze foo.php --debug -vvv
  Time (mean ± σ):     772.3 ms ±   9.8 ms    [User: 557.5 ms, System: 210.4 ms]
  Range (min … max):   758.7 ms … 787.8 ms    10 runs

after this PR

➜  phpstan-src git:(lazy-loca) ✗ hyperfine 'php bin/phpstan analyze foo.php --debug -vvv'
Benchmark 1: php bin/phpstan analyze foo.php --debug -vvv
  Time (mean ± σ):     552.9 ms ±   6.7 ms    [User: 441.0 ms, System: 109.2 ms]
  Range (min … max):   548.6 ms … 571.3 ms    10 runs

@ondrejmirtes
Copy link
Copy Markdown
Member

/cc @xificurk Look at this 😊

@staabm staabm merged commit 98d015f into phpstan:2.1.x May 1, 2026
655 of 660 checks passed
@staabm staabm deleted the lazy-loca branch May 1, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants