Improving Performance of ARM32 Docker Images with .NET Core Package Cache
.NET Core SDK distributions include a compressed copy of NuGet packages for .NET Core, ASP.NET Core and EF Core. These packages are decompressed upon installation of the .NET Core SDK. The packages are not currently included in ARM32 distributions due to the time and space cost to decompress the packages. Instead, they will be added to .NET Core ARM32 Docker images, where these costs can be paid as part of image creation.
These NuGet packages include content for two purposes:
Reference assemblies for .NET Core, for code compilation.
Pre-compiled assemblies (compiled with crossgen) for .NET Core, for use in self-contained applications.
In both cases, the presence of these packages avoid the need to access remote NuGet feeds for .NET Core assemblies as part of package restore.
This file is decompressed to the following location: /usr/share/dotnet/sdk/NuGetFallbackFolder/
A package restore for a .NET Core assembly will restore the assembly from the NuGetFallbackFolder location and copy it to the user NuGet cache. At that point, regular NuGet behavior is used.
Impact of this change
There should be no functional difference in behavior after this change. .NET SDK commands should complete faster and require fewer package restore network requests.
The following examples demonstrates the benefit of this change. The improvement can be observed with package restore. Build times (assuming no restore) are not affected.
.NET Core 2.1 SDK image after this change
The change has already been made in the microsoft/dotnet-nightly repo, as you can see in the example below. In August, this same change will be made available in the microsoft/dotnet repo.
pi@raspberrypi:~ $ docker run -it --rm microsoft/dotnet-nightly:2.1-sdk
root@416731f24915:/# time dotnet new mvc -o mvcapp
Getting ready...
The template "ASP.NET Core Web App (Model-View-Controller)" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore-template-3pn-210 for details.
Processing post-creation actions...
Running 'dotnet restore' on mvcapp/mvcapp.csproj...
Restoring packages for /mvcapp/mvcapp.csproj...
Generating MSBuild file /mvcapp/obj/mvcapp.csproj.nuget.g.props.
Generating MSBuild file /mvcapp/obj/mvcapp.csproj.nuget.g.targets.
Restore completed in 6.68 sec for /mvcapp/mvcapp.csproj.
Restore succeeded.
real 0m32.496s
user 0m35.820s
sys 0m4.280s
root@416731f24915:/# cd mvcapp/
root@416731f24915:/mvcapp# time dotnet build
Microsoft (R) Build Engine version 15.8.138-preview+ge0cd4f1c1f for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 524.78 ms for /mvcapp/mvcapp.csproj.
/usr/share/dotnet/sdk/2.1.401-preview-009081/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(143,5): message NETSDK1057: You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452 [/mvcapp/mvcapp.csproj]
mvcapp -> /mvcapp/bin/Debug/netcoreapp2.1/mvcapp.dll
mvcapp -> /mvcapp/bin/Debug/netcoreapp2.1/mvcapp.Views.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:02:09.15
real 2m13.377s
user 1m25.260s
sys 0m9.420s
root@416731f24915:/mvcapp#
Improving Performance of ARM32 Docker Images with .NET Core Package Cache
.NET Core SDK distributions include a compressed copy of NuGet packages for .NET Core, ASP.NET Core and EF Core. These packages are decompressed upon installation of the .NET Core SDK. The packages are not currently included in ARM32 distributions due to the time and space cost to decompress the packages. Instead, they will be added to .NET Core ARM32 Docker images, where these costs can be paid as part of image creation.
These NuGet packages include content for two purposes:
In both cases, the presence of these packages avoid the need to access remote NuGet feeds for .NET Core assemblies as part of package restore.
This change only affects .NET Core 2.1 SDK ARM32 Docker images. This change will be made in August 2018.
Discussion
Please share your thoughts on this change and see what others are saying at:
.NET Core SDK NugetFallbackFolder
The .NET Core SDK includes a compressed copy of all NuGet package, in LZMA format. It exists at the following version-specific location:
This file is decompressed to the following location:
/usr/share/dotnet/sdk/NuGetFallbackFolder/
A package restore for a .NET Core assembly will restore the assembly from the NuGetFallbackFolder location and copy it to the user NuGet cache. At that point, regular NuGet behavior is used.
Impact of this change
There should be no functional difference in behavior after this change. .NET SDK commands should complete faster and require fewer package restore network requests.
The following examples demonstrates the benefit of this change. The improvement can be observed with package restore. Build times (assuming no restore) are not affected.
.NET Core 2.1 SDK image after this change
.NET Core 2.1 SDK image before this change