Skip to content

NuGetFallbackFolder adds unnecessary bloat to build containersΒ #237

Closed
@natemcmaster

Description

@natemcmaster

In .NET Core 2.0, the CLI started shipping a feature that adds an offline package feed called the NuGetFallbackFolder. This adds unnecessary bloat to SDK images in the following ways:

  • ~660 MB of xmldocs are stored in ~/.dotnet/NuGetFallbackFolder. xmldocs are unnecessary in build images.
  • first run of dotnet-restore creates about 5,700 duplicate files which adds about 326 MB. This duplication is caused by copying files from ~/.dotnet/NuGetFallbackFolder to ~/.nuget/packages
  • Any users that build inside the image and don't clear out the ~/.nuget/packages folder end up with a bloated image. Here is the resulting duplication between the nuget cache and fallback folders:
    fdupes -r -m ~/.dotnet/NuGetFallbackFolder/ ~/.nuget/packages/
    11439 duplicate files (in 2809 sets), occupying 876.3 megabytes
    

Suggestions

  • Exclude xmldocs from NuGet fallback folder
  • Disable the offline package cache feature altogether.
  • Warmup the NuGet cache by running dotnet-restore as a part of the image creation.

Or some combination of the ideas above.

Details
How I measured the numbers
Using: microsoft/dotnet-nightly:2.0.0-preview1-sdk

  • Measure the effect of a dotnet-restore
    1. Install fdupes tool. apt-get update -qq && apt-get install -y fdupes
    2. mkdir /app && cd /app
    3. ls ~/.nuget/. The ~/.nuget/packages/ folder does not yet exist.
    4. dotnet new web (automatically launches dotnet restore)
    5. fdupes -r -m ~/.dotnet/NuGetFallbackFolder/ ~/.nuget/packages/
    6. Count files added to nuget cache: find ~/.nuget/packages -type f | wc -l
  • Count xmldoc files
    find ~/.dotnet -name "*.xml" -type f | wc -l
  • Count xmldoc filesize:
    find ~/.dotnet/ -name "*.xml" -type f -print0 | du -sb --files0-from=- | awk '{ total += $1} END { print total/1024/1024 }' (number is in MB)

cc @emgarten @rrelyea @dotnet/dotnet-cli @glennc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions