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
Add configuration for maximum size of shaped array #7433
Conversation
Sorry, but I don't like this This kind of limits are frequently calibrated to prevent runaway processing that leads to memory issues, performance issues and prevent stability issues in general. It adds complexity in Psalm and will probably be missused by most users and they'll end up ticketing here bugs that will be pretty hard to find. What is your actual use case for this? |
My actual usecase involves completely disabling this check in my fork, I used this at work to automatically typecheck mongoDB queries (including up to 3-level nested $or, $and, $eq, $gt, $gte, $in, $lt, $lte, $ne, $nen syntax :D). The typechecks worked perfectly, but caused 30-minute psalm scans with up to 20GB of RAM, and were promptly disabled :D Still, I kept the checks disabled, as I imagine they can slightly improve overall type inferring, and that's also the reason why I submitted this MR. |
Ok, I get it, I thought you wanted to go the other way (to have more literals). Well, I have mixed feelings on that. On one hand, I know there are some issues not fixed yet where not having literals in an array created false positives, so this is not just a neutral feature we can just disable. On the other hand, if there are dramatic perf improvements, it would be a shame not to be able to have them when needed... |
Actually, that's exactly what I wanted to do, I wanted to set a huge limit like |
You'll hit hard walls at some point. If you try to use a switch on that, I believe the wall will be very big and with spikes too. The issue is that Psalm checks can be exponential. Luckily, Psalm is pretty quick, but no matter how quick, there is one point where the exponential process will takes years to complete. And it's waaay before PHP_INT_MAX 😄 |
Does this mean we can use a SAT solver to run psalm now? :D |
Btw, at work we run psalm with this config @ PHP_INT_MAX, and (single-threaded, uncached) scans complete in just 5 minutes with 420k lines of code, ~4.7 million lines considering dependencies :) |
@orklah How would you feel about this if documentation were added that warned about potential memory/runtime issues? I've sometimes wanted to increase other limits like this, and it would be nice to be able to do, as long as the documentation makes it very clear that you're playing with fire by increasing it. |
Configs like that
I guess I just don't see the point. Once this one is included, I can think of a handful more exactly like that at different places in Psalm, we won't add config for each and every one... Maybe we should have a much more powerful config tool if we want to consider going at this level of details. I'm thinking of something like about:config in firefox where a lot of configs are available but you have to be sure of what you do before changing one. Maybe something that wouldn't depend on the xsd to add or remove configs... That way we could keep important configs in a visible place and the rest would be available for power users but almost invisible for the rest? You have thoughts on that @weirdan? |
Actually, I added it exactly after another (undocumented) similar config, maxStringLength :D I also didn't document it in a similar manner to maxStringLength: I assumed that the latter was a somewhat internal config, and followed the same approach with this one. |
True, there are a lot of config options available, and more being added.
What do you think about not using attributes on the root element, but on some child element? Something like:
That way they'd be grouped separately from the rest of the options. |
Grouping them is a good idea! I wonder if getting them out of the xml could be interesting. I find the XSD validation to be perfect for issuesHandler because we can autocomplete and validate the user input. However, for simple key/values for configs, I find it pretty heavy. Also the current handling in Config that force us to have a new property for each config is really heavy and create unnecessary BC breaks when we want to remove some. For complex config, maybe a simple json would be enough and stored as an array in some kind of ConfigValue object? Just throwing ideas here :p |
I kinda like what they did in this regard in With that said, there's nothing wrong with using your own fork of Psalm either. |
5d6e259
to
87d9a01
Compare
Can I haz merge||definitive close :3 |
Can you add some documentation on this config? Please add a note about how changing this to low or high values could have unintended effects and that those side effects won't be considered as bugs. |
Done! |
Thanks! |
No description provided.