Performance of single assembly vs multiple assemblies #96781
-
There is an old MSDN article (2004) that teaches us that we should prefer a single assembly (DLL) over multiple assemblies, for reasons such as:
I wonder if this still holds true for current .NET. Could Also on Stack Overflow |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Each assembly has fixed overhead. It is still the case that fewer bigger assemblies is better that more smaller ones. The per-assembly fixed overhead is relatively significant for very small assemblies (<10kB). It is not a concern for bigger assemblies (>100kB).
Publishing as single file can avoid some of the overhead, but it cannot eliminate. The assembly boundaries are visible through reflection APIs, so they have to be kept in some form to avoid reflection API behavior changes. |
Beta Was this translation helpful? Give feedback.
What would the issue be about?
We do have PublishSingleFile and PublishAot options that create a single file that can be used to address some of the per-assembly overhead.
For advanced users, there are tools like https://github.com/gluck/il-repack. These tools can reduce the overhead even further, but they typically require non-trivial custom settings to make things work in specific situation.
Yes. Many .NET solutions like that load a fraction of the small assemblies during startup. Automatic merging of the small assemblies would be a regression for these solutions. Many small assemblies are fine if they are loaded lazily.