Skip to content

perf: make all static extensions use TSRMG_STATIC (+~10% tokenizer performance in phpstan)#22277

Open
henderkes wants to merge 3 commits into
php:masterfrom
henderkes:perf/tsrmg-static
Open

perf: make all static extensions use TSRMG_STATIC (+~10% tokenizer performance in phpstan)#22277
henderkes wants to merge 3 commits into
php:masterfrom
henderkes:perf/tsrmg-static

Conversation

@henderkes

@henderkes henderkes commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

idea from shivammathur/homebrew-php#5161 (comment)
refs #22231 (comment)

phpstan ran on laravel codebase, aarch64-linux-gnu cloud machine:

buildPHPStan instructionstokenizer instructionstokenizer wall
gcc796.2313 B74.2240 B13.11s
gcc patch795.9697 B (−0.033%)61.8538 B (−16.67%)11.40s (−13.0%)
clang808.8653 B81.3917 B14.25s
clang patch808.6469 B (−0.027%)69.0139 B (−15.21%)12.64s (−11.3%)

affects x86_64 by ~11% on a smaller phpstan run:

buildPHPStan instructionstokenizer instructionswall
gcc5.1616 B350.76 M87.27s
gcc patch5.1590 B (−0.050%)311.98 M (−11.05%)85.43s (−2.1%)
clang5.7485 B380.05 M87.57s
clang patch5.7442 B (−0.075%)336.05 M (−11.58%)86.26s (−1.5%)

The performance change in phpstan comes from tokenizer previously not getting the definition. in order to prevent other extensions from accidentally forgetting to define it, just do it for all of them

@staabm

staabm commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

just a side-note from a PHPStan maintainer: we really love that someone is looking into php-src which results in faster PHPStan executions.

thank you! :-)


is the walltime really in ms? or should it read seconds?

@henderkes

Copy link
Copy Markdown
Contributor Author

just a side-note from a PHPStan maintainer: we really love that someone is looking into php-src which results in faster PHPStan executions.

thank you! :-)

is the walltime really in ms? or should it read seconds?

Most definitely not, I'll update the table.

@henderkes henderkes changed the title perf: make all static extensions use TSRMG_STATIC (+~8% performance in phpstan) perf: make all static extensions use TSRMG_STATIC (+~8% tokenizer performance in phpstan) Jun 11, 2026
@henderkes henderkes changed the title perf: make all static extensions use TSRMG_STATIC (+~8% tokenizer performance in phpstan) perf: make all static extensions use TSRMG_STATIC (+~10% tokenizer performance in phpstan) Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants