Skip to content
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

Store baseline and neon configs as php code #8870

Closed
thbley opened this issue Feb 9, 2023 · 10 comments
Closed

Store baseline and neon configs as php code #8870

thbley opened this issue Feb 9, 2023 · 10 comments

Comments

@thbley
Copy link

thbley commented Feb 9, 2023

Feature request

I'm requesting to store the baseline file in php code instead of neon format.
Using php code, we could also use opcache in cli with file_cache_only.
Our baseline is 167k loc with 8M in size.
When analyzing an empty php file, it takes 11s with the baseline.neon and 2s without the baseline.neon, so parsing the baseline takes about 8s on an amd 5825U.

Same for the rules.neon files. We use a couple of neon files in the "includes". When I include all configs, parsing an empty php file takes 11s, when I disable all in the include section, it takes 2s.

Did PHPStan help you today? Did it make you happy in any way?

Yes, PHPStan is helping us every day, great tool!

@ondrejmirtes
Copy link
Member

Sorry, I don't think we can do anything to improve working with such a huge baseline. The documentation (https://phpstan.org/user-guide/baseline) states:

It works best when you want to get rid of a few dozen to a few hundred reported errors that you don’t have time or energy to deal with right now. It’s not the best tool when you have 15,000 errors — you should probably spend more time configuring PHPStan or run it with a lower rule level.

I recommend you to trim down the baseline.

Even if you keep such a big baseline, taking 11s isn't that bad.

@thbley
Copy link
Author

thbley commented Feb 9, 2023

This is the output from xdebug using kcachegrind:
Screenshot_20230209_194828

When analyzing an empty php file and it takes >20s, I guess there is room for improvement.

@ondrejmirtes
Copy link
Member

Good news:

@thbley
Copy link
Author

thbley commented Feb 23, 2023

Thanks!

@gnutix
Copy link

gnutix commented Feb 28, 2023

@ondrejmirtes Thanks for this new feature! I've just tried it out, and the performance improvement is great. 🎉

I do have some smalls suggestions for improvements regarding the "code style" of the generated file :

  1. Replace tabs by spaces before the 3 keys (message, count, path), so that there's only spaces in the file
  2. Trim the 3 spaces before each $ignoreErrors[] = [ (probably caused by the HereDoc syntax)
  3. Add a new line at the end of file (to prevent warnings / automatic fixing on git and some IDEs)

@herndlm
Copy link
Contributor

herndlm commented Feb 28, 2023

@gnutix you might want to follow phpstan/phpstan-src#2266 :)

@ruudk
Copy link
Contributor

ruudk commented Mar 1, 2023

  1. Replace tabs by spaces before the 3 keys (message, count, path), so that there's only spaces in the file

Fixed in phpstan/phpstan-src#2269

  1. Trim the 3 spaces before each $ignoreErrors[] = [ (probably caused by the HereDoc syntax)

Fixed in phpstan/phpstan-src@144da80 (pending release)

  1. Add a new line at the end of file (to prevent warnings / automatic fixing on git and some IDEs)

Fixed in phpstan/phpstan-src@c9b5060 (pending release)

@gnutix
Copy link

gnutix commented Mar 1, 2023

Thanks @ruudk for your work! I like the "one line per error" idea too. Will make things was more compact, and even git stats (line removed) will match errors count somewhat. :)

@ruudk
Copy link
Contributor

ruudk commented Mar 1, 2023

@gnutix Please respond in that PR, seems it's not going to be merged 😊

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants