PY-85638 PY-85893 Use soft-key soft-value map for TypeEvalContext caches

This prevents the caches from blowing up in size when analyzing a lot of files in a row

The most obvious example is running `Analyze code` on the whole project. Previously, all PSI elements from all files would pollute the cache, potentially consuming multiple Gb of memory. See PyDjangoSourcesPerformanceTest as an example. It used to require 16 Gb of heap, and it would still sometimes fail with OOM. Now, it runs smoothly with 2Gb of heap

GitOrigin-RevId: f9854f8abdd7086414df8f610b0f2d611ca0d455
This commit is contained in:
evgeny.bovykin
2025-12-09 17:41:26 +00:00
committed by intellij-monorepo-bot
parent f499dde1ce
commit 6a772de5d5
2 changed files with 20 additions and 4 deletions
@@ -553,6 +553,8 @@
description="Allows narrowing types exhaustively to Never"/>
<registryKey key="python.lsp.tools.enabled" defaultValue="true" restartRequired="true"
description="Enables lsp tools"/>
<registryKey key="python.typing.soft.keys.type.eval.context" defaultValue="true"
description="Enable soft-key caching for TypeEvalContext"/>
<virtualFileCustomDataProvider implementation="com.jetbrains.python.formatter.PyCodeStyleSettingsProvider"/>
</extensions>