Reduce method calls in ExpressionTypeHolder#3859
Conversation
|
Usually we can achieve a much better optimization by reducing the number of calls, not optimizating how fast it's going to run when it's called 2 million times. Can you please investigate why is it called so often? Usually there's some other optimization to be had because of huge combinatorial explosion in types or something like that. |
|
I am still looking into the case, but I think this method is called so often that the PR is still worth it - even for a lot of other profiles with big unions. its 50-100ms on a single file, so it easily adds up when analying projects with lots of files |
|
Thank you! But we should still investigate why is it called so many times, and avoid that :) |
|
thank you. debugged the there is one union involved with more then 30 elements, which is resolved from the phpdoc the 2nd biggest union has 8 elements and is resolved from this phpdoc -> there is no really huge union involved it seems. we spent most of the time with merging scope objects profile can be seen here: https://blackfire.io/profiles/0293ba31-80fc-403f-9452-bfda15b7c7c7/graph -> I am still investigating |
while looking into phpstan/phpstan#12647 I noticed
ExpressionTypeHolder->andis on a very hot path.lets micro optimize by remove unnecessary method calls in this path
before
after