Skip to content

optimize HasOffsetValueType->isSuperTypeOf() for performance #1565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 28, 2022

the Trinary-construction via ->and() in HasOffsetValueType->isSuperTypeOf() requires php to call into all methods involved to finally combine the results via and(). even if earlier expression resolve to NO other subsequent calls need to be evaluated.

I rewrote the logic to return early instead which improves performance by ~20% when running

blackfire run php vendor/bin/phpunit tests/PHPStan/Analyser/AnalyserIntegrationTest.php --filter testBug5081

before profile

grafik

before/after comparison

grafik

refs phpstan/phpstan#7666 (comment)

@staabm staabm changed the title optimize HasOffsetValueType->isSuperTypeOf() for performance optimize HasOffsetValueType->isSuperTypeOf() for performance Jul 28, 2022
@staabm
Copy link
Contributor Author

staabm commented Jul 28, 2022

based on the idea I am looking into building a IterativeTrinary (name tbd) so we can lazily evaluate and/or and return early. stay tuned.

@staabm
Copy link
Contributor Author

staabm commented Jul 28, 2022

based on the idea I am looking into building a IterativeTrinary (name tbd)

see #1566

@ondrejmirtes
Copy link
Member

My opinion is the same as here: #1563 (comment)

@staabm staabm closed this Jul 31, 2022
@staabm staabm deleted the has-offset-perf branch July 31, 2022 07:15
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