- `LLFirProviderHelper` is guarded by `allowKotlinPackage` and the
symbol names provider should reflect that in the name sets.
- Note that this does not apply to stub-based deserialized symbol
providers, because they do not pass any value to `allowKotlinPackage`.
^KT-57314
- This commit replaces session modification trackers with event-based
session invalidation. The removal of modification trackers should
improve overall performance, because session invalidation events
happen less frequently than sessions are accessed. Getting rid of
modification trackers also allows sessions to refer to other sessions
lazily, which is essential when cyclic dependencies occur.
- The new `LLFirSession` validity tracker has constant complexity and
will not cause the same kind of performance issues as dependency
modification trackers. It is a bridge to support modification trackers
in certain parts of the code (e.g. for `CachedValue`s), while being
backed by event-based invalidation.
- `LLFirSessionInvalidationService` is the bridge between modification
events and `LLFirSessionCache`. It finds out which modules should be
invalidated and instructs the session cache to remove the associated
sessions.
- Session invalidation must always happen in a write action to preserve
consistency between sessions. Otherwise, while a session A is already
removed from the cache, it might still be referenced by a dependent
session B which is in the process of being invalidated. Such a session
must never be returned from `getSession`.
^KT-57515 fixed
- As mentioned in KT-60570, memory consumption in cached symbol names
providers is caused partially by lots of instances of empty mutable
sets. This commit replaces such sets with the `emptySet()` singleton.
- This improvement also makes sense for callable names because the IDE
"package names with top-level callables" set currently contains all
package names in the project.
- In my local tests of the `setUp` Find Usages performance test, the
retained size of `FirDelegatingCachedSymbolNamesProvider` is cut down
from 208MB to 170MB by the empty class name set optimization, and from
170MB to 115MB by the empty callable name set optimization.
Before extra child nodes of classes were visited during declaration by ClassId search.
If some other thread was mutating this tree, CME could happen
this is a fix of one case from ^KTIJ-21791