-
Notifications
You must be signed in to change notification settings - Fork 663
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
Do not invalidate cache during suppression #9936
Conversation
Try rebasing this onto current master. Some failing test should be fixed there. |
@ygottschalk thank you 🙏 |
return !isset($options['no-diff']) | ||
&& !isset($options['set-baseline']) | ||
&& !isset($options['update-baseline']); | ||
return !isset($options['no-diff']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& !isset($options['set-baseline'])
&& !isset($options['update-baseline']);
i cant really rationalize this. i feel like it hacks the caching for whatever purpose. IMHO then --no-diff
should be passed explicitly (ref #7681)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear Psalm may be unable to refresh or recreate the baseline unless it has analyzed your whole codebase. It would make sense at least. So whenever your ask it to do that, it can't just analyze files that changed or were removed and launch the whole analysis.
You may have to choose between having a squeaky clean baseline and a fast analysis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not sure i follow, it seems psalm is able to recreate the baseline from cache just fine 🤔
i can confirm after rm psalm-baseline.xml
psalm regenerates the same baseline file using vendor/bin/psalm --set-baseline=psalm-baseline.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can also confirm after rm psalm-baseline.xml
AND intentionally forcing an error (referenced an unknown class in src/ somewhere), the baseline is updated as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can also confirm after fixing that error i get Baseline for issue "UndefinedClass" has 1 extra entry. (see https://psalm.dev/316)
AND it's removed from the baseline file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's two things that can reduce the time of Psalm's analysis:
- the cache (we store parsed files and also store method/class definitions)
- the diff option (Psalm will only check changed files instead of analyzing everything again)
Both can be controlled through --no-cache and --no-diff (though I think --no-cache implies --no-diff).
I think you may have misinterpreted Psalm using the --no-diff mode when you ask it to regenerate baseline vs Psalm using no cache at all.
Could you make a few tests with --no-diff, --no-cache and --set-baseline to see if it matches your expectations?
@orklah im afraid the matrix is too big to mentally coop for me 😿 (with matrix i mean: local/global install vs phar/src vs v5/master vs no-diff/no-cache)
I think so. Perhaps this PR is about: Do not invalidate diff during suppression :) I still believe the fix looks legit, ppl can opt-in to the previous behaviour by passing I've now updated our global phar installation to master. Our main project runs 2 psalm instances/configs, for non-legacy/legacy respectively. Command running:
Some numbers (all without this PR); global phar psalm v5 no-cache: 7-8m global phar psalm master no-cache: 8-9m At this point im assuming local/global install vs phar/src does not matter (or shouldnt ;)) For comparison, we also have 2 symfony kernels (for frontend/backend respectively) that we compile in 2 envs (prod/test respectively). All wiith APP_DEBUG=1 (so the cache is invalidated based on mtime), and it takes 2m roughly. |
testing on my local machine with a local phar (vendor/bin/psalm.phar) (all this is php7.4 btw) local phar psalm master no-cache: 6-7m at this point ive added then for any commit to develop we just take >10m jobs for granted :) |
🤣 @orklah any chance to get this merged? given --no-diff remains available to opt-in? or do you suggest to not suppress large codebase realtime, but rather eg. daily? |
I went back four years and found this: So yeah, this was definitely by design, there must be something deep that disallow using diff mode while also reseting the baseline |
@orklah, im still wondering about eventually i removed the psalm supression step from our GHA job, allow the psalm step to continue on error, disabled findUnusedBaselineEntry, and added daily psalm suppression to our backlog gonna leave it at this :) |
There's no difference between those two commands. --set-baseline implies --no-diff. We could have kept an error when using --set-baseline without --no-diff but it's noise |
right, i meant so the TLDR here is; patching the baseline based on diff (aka fast) is not (yet) supported |
related to #9884, ive cleaned up all the includes, so they are included once at front controller level adding each function file as stub is still needed (it cannot be put in our composer.json due the non-legacy part of the project) BUT this speeds up psalm suppression, im now seeing stable still slow 🙄 but OK. the side-effect is every function is loaded from stub, which ignores at least |
see #9918 for background
im not aware of psalm internals, but i tried this change first and it reduces runtime practically 100% for us when running
psalm --set-baseline=psalm-baseline.xml
with cacheI also cannot spot any side-effects still this may cause, eg. expected issues are still being written to, and removed from the baseline 😳
Im curious what tests do here with this change, hence a PR.
cc @orklah i must be missing something 😄