-
Notifications
You must be signed in to change notification settings - Fork 670
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 origin location by ID to speed up psalm by up to 75% #8054
Conversation
This is ready to be merged :) |
Could you add the psalm report with a before/after on a big enough project so we see the difference in memory consumption please? |
With From:
To:
|
can you make sure to run without cache? I find this suspicious, VariableUseGraph is an object that is kept all along analysis. Caching things in here shoud be visible in the memory usage |
Did some more testing, and it seems this issue arises from the use of psalm plugins where CodeLocation is used. I tried it with the base config (no stubs, no plugins,...) for the codebase I tested above + another bigger code base now. BASE CONFIG
To:
I tried it on my biggest codebase available (11k files), but there psalm has another bug #7863 so it failed. It seems like there is no impact on performance and memory consumption with the default psalm config at all. CUSTOM CONFIG WITH PLUGINS From:
To:
Memory consumption increased by 0.3%, speed increased by ~78% |
IIRC, VariableUseGraph is used for two things: taint detection and unused variable detection. If you base config don't use unused var detection nor taint detection, it may not be called at all. Then, maybe some plugins or some config in your config file enabled one of the two feature and made use of VariableUseGraph |
Yeah, thanks. I don't manage the psalm configs/plugins for our team, just doing devops performance work. While there is an increase in memory consumption that is linear to the number of files analyzed (and to some extent to what is in those files), the increase in performance is completely worth it in my opinion. |
Thanks! |
In some instances with particularly nested/bad code, psalm can spend minutes on a single file (and it's includes) with getOriginLocations being called over and over again on the same thing.
This runtime caches the locations in a private variable, to speed up psalm up to 75% (worst file I tested)
Similar to #8011