Open nwoolls opened 1 week ago
I don't repro the slowdowns - can you do this again and get binlogs for each run? The in every case, the step that took the longest was the BeforeBuildTasks
call of the libman restore
tool - this takes several seconds on every build and is not at all designed in the way a good MSBuild integration should be (i.e. tracking incrementality, inputs and outputs, doing some detection to see if the command needs to be run).
It's my strong suspicion that libman
is the cause of your delays, and any fixes should be referred to the owners of that tool.
@baronfel will do now and post my findings. FWIW that target is not what takes appreciable time for me. Here it's ResolveProjectStaticWebAssets
and ResolveBuildCompressedStaticWebAssets
- each taking seemingly 10s of seconds.
in that case cc @javiercn for static web assets delays
@baronfel also - not disagreeing per se, but if this were a libman
issue I don't see why it wouldn't exist in .NET 8, or why a dotnet clean
first would seem to dramatically decrease build times.
I can only report my findings, I don't know what to tell you otherwise. I am on Windows though which may have different performance characteristics from your macOS host! In any case, binlogs from your repo will be the most accurate thing for us to work from.
@baronfel MSBuild binary log files generated and included w/ the repo - e.g.:
https://github.com/nwoolls/spl-dotnet-9-slow-build/blob/main/advanced/mvc-dotnet-9/msbuild.binlog
Thanks, those really helped! They did confirm that the new static web assets content type handling can be really quite slow:
This is a pretty big slowdown for several hundred assets, I expect this will have very large penalties in real-world applications.
I expect this will have very large penalties in real-world applications.
It does 😆.
I apologize for not reporting sooner — this is what kept me away from earlier preview releases. And why I came back for the RC to see if it was fixed.
We did have a perf fix for DefineStaticWebAssetEndpoints
in https://github.com/dotnet/sdk/pull/43099, which didn't make the cut for RC1. However, I just tried the repro on the latest nightly build and still see the perf issues described in this issue. I collected a trace, and it seems most of the time spent in the static web assets pipeline is on JSON serialization and file system globbing, but @javiercn would know better what the best way to optimize this is.
Describe the bug
Building ASP.NET MVC applications with .NET 9 is 2x slower than .NET 8 for basic applications and 10x slower for applications that utilize several client-side libraries (e.g. with LibMan).
To Reproduce
See the following GitHub repository to reproduce: https://github.com/nwoolls/spl-dotnet-9-slow-build
The applications in this project were created with
dotnet new mvc
. The projects in thesimple
folder stop at that. The projects in theadvanced
folder have a handful of client-side libraries that are installed using the LibMan CLI.Running
benchmark.js
from the repository yields:Benchmark results: Simple MVC .NET 8 (avg. seconds): 1.05 Simple MVC .NET 9 (avg. seconds): 2.08 Advanced MVC .NET 8 (avg. seconds): 3.48 Advanced MVC .NET 9 (avg. seconds): 30.96
Exceptions (if any)
Running
dotnet clean
beforedotnet build
results in dramatically faster build times, even though the client-side libraries are restored by LibMan prior to theBeforeBuild
MSBuild target.Benchmark results: Simple MVC .NET 8 (avg. seconds): 1.15 Simple MVC .NET 9 (avg. seconds): 2.06 Advanced MVC .NET 8 (avg. seconds): 2.21 Advanced MVC .NET 9 (avg. seconds): 2.42
Further technical details
dotnet —info
None