[WIP] Trial removing frameworkTcImports #13863
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We noticed that
SplitNonFoundationalTcImportsis causing a spawn ofdotnetto find the installed .NET SDKs, in order to determine which assembly references are "system" assemblies.As a short term fix for that problem I'd say it's sufficient just to look for
"dotnet/packs"ordotnet/packs/Microsoft.NETCore.App.Refin the normalized path of the assembly reference. But these are not good solutions.Instead I wonder if we should just remove this "foundational/framework TcImports" altogether. This thing adds a lot of complexity to the code and loads of edge cases would disappear if we removed it.
As background, the aim of that object is to try to share resources related to common referenced assemblies in projects that have the full set of SDK references in common. For this to work, we must have exactly the same set of "system" references shared between two loaded projects. So it relies heavily on a heuristic about what is a "system" reference.
This seemed useful in the days of .NET 1.0-2.0, when all projects would tend to reference the whole .NET framework from the installed location. Then gradually reference assemblies etc. came in and I suspect it's really rare that two projects share the same foundational imports. I guess we could measure that.
However there are caveats
It may be much less rare that two scripts share the same set of imports - it would almost be normal. So scenarios like having 300 scripts open in the IDE need to be considered. However again we should measure if we're getting any actual important reduction in memory usage - and perhaps we should just rely on the other resource-sharing-and-reduction mechanisms we have in place.
Our tests certainly repeatedly share the same foundational imports. This is probably actually the biggest problem.
Note many of the resources associated with referenced binaries are shared/held-weakly in
ilModuleReaderCache1andilModuleReaderCache2. However this doesn't include the resources associated with converting ILModule --> Ccu, i.e. the TypedTree nodes created on-demand viaImportILAssembly, which are really the only things we're trying to share here.Here I've spiked the total removal of foundational/framework TcImports.