msbuild
msbuild copied to clipboard
BuildIncludeOperation optimizations
Working on AB#1827820
Context
BuildIncludeOperation is allocate-y. davkean found a case in which it was allocating over 900 MB/s. This tries to make it a bit better.
Changes Made
Please review commit-by-commit. I'm not 100% confident in all of them, but I tried to separate them into disjoint pieces so we can accept or reject them as relevant.
Testing
I tried building OrchardCore before and after these changes, and MSBuild as a whole allocated about 0.5% less. When not everyone is on break, I may try to get help with finding a percent change within BuildIncludeOperation specifically, since that was my target 🙂
Notes
ImmutableArray outperforms ImmutableList if either the number of items in the array/list is small, or adding to it is very rare. As far as I know, the ones I changed are never modified after they're created, so I changed them to arrays.
I have measured it carefully for both CPU and allocation but have not detected good significant improvements. It allocates about 2% (5MB less) in scope of BuildIncludeOperation and CPU diff is not measurable.
Is there any particular use case which can leverage these changes?