Aspnetcore: Razor Static Web Assets feature is regressing build perf for large solutions

Created on 7 Aug 2019  路  6Comments  路  Source: dotnet/aspnetcore

We are seeing perf regressions for large solutions that target .NET Core 3.0 instead of .NET Core 2.0. We believe that the Razor static web assets feature is contributing to this. The implementation for the static web assets feature calls the GetCurrentProjectStaticWebAssets target in dependent projects with _StaticWebAssetsSkipDependencies=true as a global property:

https://github.com/aspnet/AspNetCore-Tooling/blob/2e70e0cbd7d8b952313d1114cd750befca2b1453/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets#L255-L264

Setting the new global property causes all of the transitively referenced projects to be re-evaluated, which can be expensive. You can see where we had a similar issue here: https://github.com/microsoft/msbuild/issues/1276

@pranavkm @rynowak @mkArtakMSFT @rainersigwald

Done area-blazor bug

All 6 comments

@dsplaisted do you have a binlog of a build that suffers from this? I'd like to take a deeper look.

@rainersigwald I hit it when building the WebLarge30 performance test solution: https://github.com/dotnet/BuildPerformanceTestAssets/tree/master/PerformanceTestProjects/WebLarge30

However, that's quite a big solution (129 projects). You should be able to repro it with a vanilla 3.0 MVC project referencing a class library.

I'm going to be looking at this on Monday. The relevant piece of code is https://github.com/aspnet/AspNetCore-Tooling/blob/master/src/Razor/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets

We are using that property precisely to try and prevent executing on the dependencies :(. I think we need to do a small change in this feature to avoid passing the property. Would that fix it?

I investigated a bit and we'll likely can fix this by capturing the information the first time we compute it and having an additional target that reads it back when needed.

I have a PR out for this, gets it down from 11s to 3s and removes the use of the custom property.

Was this page helpful?
0 / 5 - 0 ratings