Skip to content

Conversation

@jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Aug 6, 2018

Uses XmlReaderSettings to ignore comments and whitespace for all projects. At the moment we read comments but then report the content as just String.Empty. The XmlReader still allocates a string for us which we immediately throw away.

This change adds a setting to ProjectCollection so that all projects loaded in the collection are treated as read-only. For command-line builds, a ProjectCollection is created for the build episode. End-users can create their own ProjectCollection with the setting as well.

Fixes #2576

@AndyGerlicher
Copy link
Contributor

DesignTimeBuild Time (ms) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject yes 36.5845 -> 36.4065 (-0.487%)
DotnetWebProject 👌 no 230.1308 -> 231.1049 (0.423%)
DotnetMvcProject 👌 no 232.7922 -> 233.5048 (0.306%)
Picasso yes 1545.722 -> 1543.1251 (-0.168%)
SmallP2POldCsproj yes 68.8146 -> 68.1377 (-0.984%)
SmallP2PNewCsproj 🔴 yes 649.2819 -> 650.7277 (0.223%)
LargeP2POldCsproj 🔴 yes 11258.4129 -> 11330.2536 (0.638%)
OrchardCore yes 48644.5814 -> 48285.1216 (-0.739%)

DesignTimeBuild Memory (bytes) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject 🔴 yes 6259065 -> 6266238 (0.115%)
DotnetWebProject ::ok_hand: no 22933230 -> 21877163 (-4.605%)
DotnetMvcProject ::ok_hand: no 22259073 -> 21340516 (-4.127%)
Picasso 🔴 yes 182421621 -> 186957517 (2.486%)
SmallP2POldCsproj 🔴 yes 8547276 -> 8570039 (0.266%)
SmallP2PNewCsproj ::ok_hand: no 92122514 -> 90522671 (-1.737%)
LargeP2POldCsproj yes 1082715524 -> 1040219870 (-3.925%)
OrchardCore yes 2777824956 -> 2728487523 (-1.776%)

SerialEvaluationIsolatedContext Time (ms) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject yes 34.5251 -> 34.4331 (-0.266%)
DotnetWebProject 👌 no 48.1357 -> 48.2005 (0.135%)
DotnetMvcProject 🔴 yes 53.8864 -> 54.0912 (0.38%)
Picasso 🔴 yes 297.7509 -> 300.4826 (0.917%)
SmallP2POldCsproj yes 51.6291 -> 51.2593 (-0.716%)
SmallP2PNewCsproj 👌 no 204.3136 -> 204.8061 (0.241%)
LargeP2POldCsproj 🔴 yes 894.2667 -> 902.272 (0.895%)
OrchardCore yes 3204.287 -> 3190.9535 (-0.416%)

SerialEvaluationIsolatedContext Memory (bytes) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject 👌 no 5677492 -> 5678814 (0.023%)
DotnetWebProject 🔴 yes 7652735 -> 7659871 (0.093%)
DotnetMvcProject 🔴 yes 8272610 -> 8281721 (0.11%)
Picasso yes 15995961 -> 12701413 (-20.596%)
SmallP2POldCsproj 🔴 yes 6977223 -> 6996985 (0.283%)
SmallP2PNewCsproj yes 15209780 -> 13595063 (-10.616%)
LargeP2POldCsproj ::ok_hand: no 40159506 -> 38559547 (-3.984%)
OrchardCore 👌 no 64396353 -> 68123853 (5.788%)

SerialEvaluationSharedContextSecondRun Time (ms) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject 👌 no 29.403 -> 29.447 (0.15%)
DotnetWebProject yes 37.0096 -> 36.7551 (-0.688%)
DotnetMvcProject yes 39.4894 -> 39.0219 (-1.184%)
Picasso ::ok_hand: no 235.6743 -> 235.4419 (-0.099%)
SmallP2POldCsproj 🔴 yes 41.0387 -> 41.318 (0.681%)
SmallP2PNewCsproj yes 130.2512 -> 129.9751 (-0.212%)
LargeP2POldCsproj 🔴 yes 654.5544 -> 660.1758 (0.859%)
Generated_100_100_v150 👌 no 1127.381 -> 1128.3378 (0.085%)
OrchardCore ::ok_hand: no 1564.3817 -> 1560.5502 (-0.245%)
Roslyn 🔴 yes 2603.2246 -> 2614.561 (0.435%)
WebLargeCore ::ok_hand: no 1798.2319 -> 1792.2476 (-0.333%)

SerialEvaluationSharedContextSecondRun Memory (bytes) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject 🔴 yes 5542801 -> 5543102 (0.005%)
DotnetWebProject 🔴 yes 6858968 -> 6865315 (0.093%)
DotnetMvcProject 🔴 yes 7285803 -> 7292626 (0.094%)
Picasso 🔴 yes 10854655 -> 11199302 (3.175%)
SmallP2POldCsproj 🔴 yes 6903170 -> 6944082 (0.593%)
SmallP2PNewCsproj 🔴 yes 22974307 -> 23072873 (0.429%)
LargeP2POldCsproj 🔴 yes 35834564 -> 36481812 (1.806%)
Generated_100_100_v150 🔴 yes 44950579 -> 46310017 (3.024%)
OrchardCore 🔴 yes 56299039 -> 58860930 (4.551%)
Roslyn 🔴 yes 82958377 -> 86914021 (4.768%)
WebLargeCore 🔴 yes 69975831 -> 71927428 (2.789%)

SerialEvaluationSharedContext Time (ms) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject yes 33.8715 -> 33.7459 (-0.371%)
DotnetWebProject yes 47.5793 -> 47.3493 (-0.483%)
DotnetMvcProject yes 53.551 -> 53.14 (-0.767%)
Picasso 👌 no 249.5883 -> 250.4032 (0.326%)
SmallP2POldCsproj 🔴 yes 44.904 -> 45.0546 (0.335%)
SmallP2PNewCsproj 👌 no 166.6854 -> 167.3034 (0.371%)
LargeP2POldCsproj 🔴 yes 707.9823 -> 711.6937 (0.524%)
Generated_100_100_v150 👌 no 1145.0907 -> 1145.3251 (0.02%)
OrchardCore 👌 no 2104.8438 -> 2107.7857 (0.14%)
Roslyn 🔴 yes 3130.5376 -> 3142.6218 (0.386%)
WebLargeCore ::ok_hand: no 2254.0711 -> 2253.3607 (-0.032%)

SerialEvaluationSharedContext Memory (bytes) (src\msbuild vs src\msbuild.jeff)

Test Overall Significant δ Value
DotnetConsoleProject 🔴 yes 5747665 -> 5747912 (0.004%)
DotnetWebProject 🔴 yes 7708725 -> 7717609 (0.115%)
DotnetMvcProject 🔴 yes 8318532 -> 8326714 (0.098%)
Picasso yes 12839376 -> 11139145 (-13.242%)
SmallP2POldCsproj 🔴 yes 6968340 -> 7007770 (0.566%)
SmallP2PNewCsproj 👌 no 14677275 -> 14927120 (1.702%)
LargeP2POldCsproj ::ok_hand: no 37030682 -> 36739613 (-0.786%)
Generated_100_100_v150 🔴 yes 45772666 -> 46962536 (2.6%)
OrchardCore 👌 no 64001299 -> 66724946 (4.256%)
Roslyn ::ok_hand: no 85688144 -> 85666085 (-0.026%)
WebLargeCore 👌 no 69069345 -> 70129820 (1.535%)

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting on the breaking(?) change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a breaking change? IIRC optional arguments are compiled into the consumer, so they can't be added without breaking and you have to add an overload instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add trailing comma

@jeffkl
Copy link
Contributor Author

jeffkl commented Aug 14, 2018

@AndyGerlicher do the perf numbers indicate if this change is worth it? I can't decipher them...

@jeffkl
Copy link
Contributor Author

jeffkl commented Aug 15, 2018

@davkean does this look like it'll resolve #2576? Our perf numbers are inconclusive

@jeffkl jeffkl changed the title WIP: Load all projects as read-only in MSBuild.exe Load all projects as read-only in MSBuild.exe Aug 15, 2018
@davkean
Copy link
Member

davkean commented Aug 15, 2018

Really hard to tell - do you trust those numbers at all? It shows a large reduction in design-time build memory, but then regresses SerialEvaluationSharedContextSecondRun memory whatever that's doing.

@AndyGerlicher AndyGerlicher merged commit f7fec59 into dotnet:master Aug 28, 2018
@jeffkl jeffkl deleted the ro branch August 29, 2018 00:07
sidiesen pushed a commit to sidiesen/msbuild that referenced this pull request Oct 4, 2018
Uses XmlReaderSettings to ignore comments and whitespace for all projects. At the moment we read comments but then report the content as just String.Empty. The XmlReader still allocates a string for us which we immediately throw away.

This change adds a setting to ProjectCollection so that all projects loaded in the collection are treated as read-only. For command-line builds, a ProjectCollection is created for the build episode. End-users can create their own ProjectCollection with the setting as well.

Fixes dotnet#2576
ladipro added a commit that referenced this pull request Apr 27, 2021
Fixes #2576

### Context

The code already has support for parsing project files as read-only when we know that we're not going to be asked to write them back to disk. This flag is currently unused because the initial implementation in #3584 introduced a regression related to whitespace in attribute values (#4210).

### Changes Made

Trivially reverted part of #4213 that addressed the regression and added a hack to make `XmlReader` behave the same as `XmlTextReader`.

### Testing

Existing unit tests for correctness and ETW for performance. `XmlDocumentWithLocation.Load()` is ~26% faster with this change compared to baseline when building .NET Core projects. This translates to about 10 ms per one incremental CLI build of a Hello world application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants