Reduce collections resizing and yield allocations #5952
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: NuGet/Home#13677
Related: NuGet/Home#12728
Description
The improvements for an orchardcore restore total about ~50MB.
Micro benchmarks for part of the changes.
Default
|---------------------- |--------------:|-----------:|-----------:|-----------:|----------:|-------------:|
| NJ | 43.30 us | 0.078 us | 0.073 us | 4.0283 | 0.1221 | 68.77 KB |
| MicrosoftBuildRuntime | 66.20 us | 0.142 us | 0.125 us | 8.4229 | 0.7324 | 142.8 KB |
| AllPackages | 150,817.69 us | 668.471 us | 625.289 us | 14000.0000 | 1250.0000 | 238558.01 KB |
The gains from this are harder to prove since I refactored the methods quite a bit, but I estimated as ~3MB.
The gains from the yield changes are about 47MB.
Before:
After:
Note that
PR Checklist
Added testsTests exist.