Item operation perf in _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences
KirillOsenkov opened this issue · comments
I have an unconfirmed hunch that we can speed up some item operations in the _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences
target.
Consider for example this snippet:
msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
Lines 5108 to 5109 in dbf8d12
My understanding is that this can be collapsed in a single line with the condition Always or PreserveNewest.
This pattern is used quite a lot:
msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
Lines 5108 to 5178 in dbf8d12
I'd be curious to measure the performance of a reasonable large build with a lot of project references and copy to output, and see if we can see any difference. You can use this query in the binlog viewer: $target GetCopyToOutputDirectoryItems $time
Is AssignTargetPath called twice for @(_CompileItemsToCopy)? Once for transitive, once for this project? I suppose it's benign and idempotent?
To clarify, out of 15 seconds for that target, 12 seconds is calling the MSBuild task on the project references, so the remaining 3.3 seconds must be the overhead, perhaps partially attributable to item manipulation:
I might be totally wrong though, need to measure, and perhaps in a tight loop in a unit-test using BenchmarkDotNet.