Skip to content

revert conditionalExpression invalidation - #2018

Closed
rajyan wants to merge 1 commit into
phpstan:1.9.xfrom
rajyan:tmp-test-regression
Closed

rajyan wants to merge 1 commit into
phpstan:1.9.xfrom
rajyan:tmp-test-regression

Conversation

@rajyan

@rajyan rajyan commented Nov 21, 2022 •

Copy link
Copy Markdown
Contributor

from phpstan/phpstan#8397

I think my assumption was correct, this commit should be the cause.
cb45b58

I knew that maybe this commit cause a performance regression, but it was needed to make conditional expression invalidation work with all expressions.

The problem is, before #2007 conditionalExpression was only used for variables, so this invalidation was enough.

If conditionalExpressions is used for all expressions, we have to invalidate like how expressionTypes are invalidated.
That is, we have to invalidate conditional expression that is related to $a like returnsBool($a) when $a is invalidated.

The failing test can show what would not work without this


@rajyan
rajyan force-pushed the tmp-test-regression branch 3 times, most recently from beb4b41 to 89f91a2 Compare November 21, 2022 10:27
@rajyan
rajyan force-pushed the tmp-test-regression branch from 89f91a2 to 8ad2c66 Compare November 21, 2022 10:37
@rajyan

rajyan commented Nov 21, 2022 •

Copy link
Copy Markdown
Contributor Author

@ondrejmirtes
Could you confirm that this revert can solve the performance regression?
I would think for a better way for invalidating expressions.

@staabm

staabm commented Nov 21, 2022 •

Copy link
Copy Markdown
Contributor

if relevant, just run phpstan-src@master before and after this PR

before:

mstaab@NB-COMPLEX-45 MINGW64 /c/dvl/Workspace/phpstan-src-staabm (1.9.x)
$ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan
Note: Using configuration file C:\dvl\Workspace\phpstan-src-staabm\phpstan.neon.dist.
 1486/1486 [============================] 100%

 [OK] No errors

real    1m8.740s
user    0m0.000s
sys     0m0.000s

mstaab@NB-COMPLEX-45 MINGW64 /c/dvl/Workspace/phpstan-src-staabm (1.9.x)
$ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan
Note: Using configuration file C:\dvl\Workspace\phpstan-src-staabm\phpstan.neon.dist.
 1486/1486 [============================] 100%

 [OK] No errors

real    1m4.822s
user    0m0.000s
sys     0m0.015s

with this PR:

$ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan
Note: Using configuration file C:\dvl\Workspace\phpstan-src-staabm\phpstan.neon.dist.
 1486/1486 [============================] 100%

 [OK] No errors

real    1m2.631s
user    0m0.000s
sys     0m0.000s

mstaab@NB-COMPLEX-45 MINGW64 /c/dvl/Workspace/phpstan-src-staabm (pr/2018)
$ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan
Note: Using configuration file C:\dvl\Workspace\phpstan-src-staabm\phpstan.neon.dist.
 1486/1486 [============================] 100%

 [OK] No errors

real    1m1.437s
user    0m0.000s
sys     0m0.000s

-> so at least on my 12 core windows machine it seems to be pretty the same as before (or marginal faster)


Edit
1.9.2-stable for reference

$ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan
Note: Using configuration file C:\dvl\Workspace\phpstan-src-staabm\phpstan.neon.dist.
 1486/1486 [============================] 100%

 [OK] No errors

real    0m50.606s
user    0m0.015s
sys     0m0.000s

mstaab@NB-COMPLEX-45 MINGW64 /c/dvl/Workspace/phpstan-src-staabm (1-9-2)
$ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan
Note: Using configuration file C:\dvl\Workspace\phpstan-src-staabm\phpstan.neon.dist.
 1486/1486 [============================] 100%

 [OK] No errors

real    0m48.629s
user    0m0.000s
sys     0m0.000s

@rajyan

rajyan commented Nov 21, 2022

Copy link
Copy Markdown
Contributor Author

@staabm
Thank you for confirming.
Looks like maybe the real problem is in somewhere else?

@rajyan

rajyan commented Nov 21, 2022 •

Copy link
Copy Markdown
Contributor Author
╭─ ~/Contribution/phpstan-src  @85ac37bd *3 ································································································································ ✔  08:43:27 
╰─ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan

 ! [NOTE] The Xdebug PHP extension is active, but "--xdebug" is not used. This may slow down performance and the process
 !        will not halt at breakpoints.                                                                                 

Note: Using configuration file /home/rajyan/Contribution/phpstan-src/phpstan.neon.dist.
 1487/1487 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

make phpstan  137.05s user 1.84s system 565% cpu 24.570 total
╭─ ~/Contribution/phpstan-src  @85ac37bd *3 ························································································································ 2 ✘  25s  08:43:54 
╰─ git switch -                 
Previous HEAD position was 85ac37bd1 Update phpdoc-parser
Switched to branch 'tmp-test-regression'
Your branch is up to date with 'origin/tmp-test-regression'.
╭─ ~/Contribution/phpstan-src  tmp-test-regression *3 ······················································································································ ✔  08:44:10 
╰─ time make phpstan
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan

 ! [NOTE] The Xdebug PHP extension is active, but "--xdebug" is not used. This may slow down performance and the process
 !        will not halt at breakpoints.                                                                                 

Note: Using configuration file /home/rajyan/Contribution/phpstan-src/phpstan.neon.dist.
 1487/1487 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

make phpstan  131.35s user 1.77s system 572% cpu 23.259 total
╭─ ~/Contribution/phpstan-src  tmp-test-regression *3 ·················································································································· 128 ✘  08:44:49 
╰─ git switch --detach 1.9.2
HEAD is now at 582a9cb8b Fix unset on nested array
╭─ ~/Contribution/phpstan-src  #1.9.2 *3 ··································································································································· ✔  08:44:54 
╰─ time make phpstan        
php bin/phpstan clear-result-cache -q && php -d memory_limit=448M bin/phpstan

make phpstan  115.29s user 1.79s system 636% cpu 18.406 total

Oh my god, I have no idea what I have investigated yesterday:thinking: You're right, this revert doesn't seem to fix the bottleneck.

@rajyan rajyan closed this Nov 21, 2022
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.

2 participants