[Feature Request] Lazy Loading
Sewer56 opened this issue · comments
Is your feature request related to a problem? Please describe.
Loading a plugin where you only need to extract a small amount of data, such as metadata about the author of the plugin before properly loading it is expensive.
When building an AssemblyLoadContext
, the library attempts to resolve and pre-load dependencies of all shared types as calls to AssemblyLoadContextBuilder.PreferDefaultLoadContextAssembly
are performed. This incurs a considerable I/O bottleneck.
This bottleneck becomes very clear when for example, the user clicks the plugin in a UI application and the plugin needs to be loaded to see if configuration of the plugin is possible. (A developer might implement configuring plugins using a PropertyGrid
on an object returned from the plugin).
The other case is simple.
Not all loaded assemblies might be used in practice, some of the loaded assemblies may never be needed.
Describe the solution you'd like
Lazy loading of dependencies of shared assemblies.
Only load additional assemblies as they are needed.
Describe alternatives you've considered
N/A.
This is strictly a performance measure aimed at improving startup times.
Pull Request
Please see #164
Additional context
This is a copy of my earlier PR #158 , I wanted to rename the branch and am splitting this into an issue and PR as it always should have been.
Marking has help-wanted. Not something I would implement on my own, but I see a proposal #164 has already been made.