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
Slow analysis when working with multiple big const arrays #8215
Comments
This bug report is missing a link to reproduction at phpstan.org/try. It will most likely be closed after manual review. |
@ondrejmirtes what do you think about counting the number of elements in a constant array with a NodeVisitor and turn it into a doing so early and preventing the building up of all these |
@staabm You don't need to ask me, you can just try out the solution and see if it works. Myself I tried several things in the last few days and none of them worked. Ideally I'd like a solution that solves this problem for more than just one example. For example this one https://github.com/phpstan/phpstan-src/blob/aa7b1eabd197ef6b7fb2c8eebbb7876aebc0ba6a/tests/PHPStan/Analyser/data/bug-8146.php is really hard. 95% of time is spent in |
@dpeukert this should be pretty fast now starting with 1.9.5 |
@staabm Thanks for the fix, can confirm that analysis of both the test case and our codebase sped up massively: ./vendor/bin/phpstan analyse -c phpstan.neon --debug -vvv test.php
# PHPStan v1.9.6
# --- consumed 88 MB, total 126 MB, took 0.51 s |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Getting a value from a big (6500 values in the snippet) const array and using it to access a different similarly sized const array causes PHPStan to take about 70 seconds to analyze the file. I'm fairly sure the affected file in our codebase used to take no significant time to analyse before, but there were some changes to it around the time we updated PHPStan, so I'll check with some older versions of PHPStan to see if it is a regression and update the issue.
EDIT: Doesn't seem like a regression, see times below.
Code snippet that reproduces the problem
The snippet causes the https://api.phpstan.org/analyse endpoint to return a 502, presumably because of the size, so here's a gist: https://gist.github.com/dpeukert/eadf816dc5cde760c1aa295fc065815e
Expected output
I would expect the analysis to be quicker.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan rocks!
The text was updated successfully, but these errors were encountered: