NuGet.Client
NuGet.Client copied to clipboard
Pack ContentItem with fields
Bug
Fixes: https://github.com/NuGet/Home/issues/12728
Description
This saves us about 40MB.
Before:
Name Inc % Inc
nuget.packaging!NuGet.ContentModel.Infrastructure.PatternExpression+TokenSegment.TryMatch(class NuGet.ContentModel.ContentItem&,class System.String,class System.Collections.Generic.IReadOnlyDictionary`2,int32,int32&) 0.9 76,216,336
+ mscorlib.ni!System.Collections.Generic.Dictionary`2[System.__Canon,System.__Canon].Insert(System.__Canon, System.__Canon, Boolean) 0.4 34,115,800
+ nuget.packaging!NuGet.ContentModel.ContentItem.get_Properties() 0.2 18,992,256
+ nuget.packaging!ContentPropertyDefinition.TryLookup 0.1 12,430,096
+ clr!JIT_New 0.1 10,678,184
After:
Name Inc % Inc
nuget.packaging!NuGet.ContentModel.Infrastructure.PatternExpression+TokenSegment.TryMatch(class NuGet.ContentModel.ContentItem&,class System.String,class System.Collections.Generic.IReadOnlyDictionary`2,int32,int32&) 0.5 36,278,392
+ clr!JIT_New 0.3 25,499,680
|+ clr!WKS::GCHeap::Alloc 0.3 25,499,680
| + clr!WKS::gc_heap::try_allocate_more_space 0.3 25,499,680
| + clr!GCToCLREventSink::FireGCAllocationTick_V3 0.3 25,499,680
| + clr!CoTemplate_qqhxpzqp 0.3 25,499,680
| + clr!EtwCallout 0.3 25,499,680
| + clr!ETW::SamplingLog::SendStackTrace 0.3 25,499,680
| + Type NuGet.ContentModel.ContentItem 0.3 25,499,680
+ nuget.packaging!ContentPropertyDefinition.TryLookup 0.1 10,778,712
Some micro benchmarks:
Before:
Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
---|---|---|---|---|---|---|
NJ | 40.24 us | 0.353 us | 0.331 us | 3.2959 | 0.1221 | 56.5 KB |
MicrosoftBuildRuntime | 62.62 us | 0.822 us | 0.686 us | 8.1787 | 0.6104 | 138.23 KB |
AllPackages | 152,979.21 us | 804.331 us | 713.019 us | 14250.0000 | 2000.0000 | 240733.08 KB |
After:
Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
---|---|---|---|---|---|---|
NJ | 34.69 us | 0.257 us | 0.228 us | 2.3193 | 0.0610 | 39.92 KB |
MicrosoftBuildRuntime | 58.17 us | 0.680 us | 0.636 us | 7.3853 | 0.4883 | 125.22 KB |
AllPackages | 133,135.56 us | 669.977 us | 626.697 us | 11000.0000 | 1000.0000 | 185389.49 KB |
PR Checklist
- [ ] Meaningful title, helpful description and a linked NuGet/Home issue
- [ ] Added tests
- [ ] Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.