When implementing #9889, a discussion about resource usage vs performance pointed me to investigate why Psalm is using as much memory as it is. It seems StatementsVolatileCache is at fault, it can keep a lot of memory in use, making Psalm even unusable in some cases with very very large memory footprint (@orklah claims 8GB+).
It seems there would be a better way to find a tradeoff here, Psalm shouldn't hog all the memory.
Suggested fixes in Symfony Slack:
- @dantleech - add a TTL to the cache entries
- @ciaranmcnulty - Least Recently Used policy (this seems to already be implemented)
- Gzip content of cache (in which case it also needs marshalling)
- write content into php:temp (this seems like the existing cache system)
Maybe we could even consider what happens if we disable this cache fully? It doesn't seem to do that much, but I didn't test that throughly.