Skip to content

Conversation

@Thorium
Copy link
Contributor

@Thorium Thorium commented Mar 11, 2025

I noticed that with the current reference loading of TypeProviders, if I had 139 reference assemblies (in a solution memory), I ended up calling the Assembly.Load for 897 times. This is because so many assemblies have the same references like System.Memory, System.Xml, System.Buffers, System.Threading.Tasks.Extensions, ... And the code said "load all reference assemblies". Simple fix: Check already loaded reference assemblies before trying to call the slow Assembly.Load again.

The sourceAssembliesTable_ is a ConcurrentDictionary to ensure thread-safety. However, instead of code using it in thread-safe way, it was used by double-lookup. So that is fixed to actually use it properly. (It's role is to be used as a guard to sourceAssemblies_ array, which is manually lazy-loaded from the queue.)

These changes match the FSharp.TypeProvider.SDK merged PR.

…eady loaded, 2) Use ConcurrentDictionary in thread-safe way
@github-actions
Copy link
Contributor

✅ No release notes required

@T-Gro T-Gro enabled auto-merge (squash) March 12, 2025 10:43
@T-Gro T-Gro merged commit 76b83e6 into dotnet:main Mar 12, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants