-
Notifications
You must be signed in to change notification settings - Fork 351
Description
.NET Framework Docker Performance Issue Resolved
Multiple people have reported that .NET Framework performance in Docker images is poor. In the cases reported, performance was an order of magnitude slower than expected.
This issue has now been resolved for microsoft/dotnet-framework images. It was due to incorrectly generated NGEN images. They are now correctly generated and expected performance has been restored.
Details
The .NET Framework uses NGEN as a primary mechanism for startup performance. .NET Framework assemblies are compiled to native code with the NGEN tool as part of the .NET Framework setup process. The benefit of these files is that they can be loaded and executed without any additional significant extra work required by the Common Language Runtime (CLR). The lack of additional work means that performance is very good.
NGEN image generation interacts with a Windows subsystem that is not correctly supported in Windows containers. NGEN images are generated in Windows containers, but they are not valid. Fortunately, the CLR can still run in the presence of invalid images, but code execution is much slower.
We are in the process of fixing Windows containers so that NGEN will work correctly. In the interim, we have updated the dotnet-framework/ images to correctly generate NGEN images. The microsoft/windowsservercore/ images still have the performance problem that was initially reported. We are working on updating Windows containers so that NGEN works as expected. You are recommended to use the dotnet-framework/ base image if you can, so that you can get better performance.
One of the developers that reported the performance issue shared basic performance results. The first two rows are the before state. The last row is the dotnet-framework image after the fix. The improvement is quite significant.
Runing
powershell -command (measure-command { powershell -command exit }).TotalSecondsin various images on our CI server produced this table of timings:
| time (s) | image |
|---|---|
| 10.7212372 | microsoft/windowsservercore |
| 8.3278793 | microsoft/dotnet-framework:4.7 |
| 0.6426073 | microsoft/dotnet-framework:4.7 (after fix) |
| 0.1642161 | microsoft/dotnet-framework:4.7.1-windowsservercore-1709 |