-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make noop restore faster - speed up evaluations by calling MSBuild Static Graph apis #8791
Comments
Just a check, I had the impression that although the MSBuild static graph api is public/stable now, the implementation is still ongoing (looking at the MSBuild static graph related issue list). Is the MSBuild implementation now sufficiently stable that static graph is working on all types of solutions and projects? (Or has this the potential to accidentally break nuget restore operations for certain solution/projects?) |
@cdmihai can you comment to the above message? |
So far static graph is used to successfully build (i.e. call the msbuild That being said, these are some caveats that spring in mind:
|
I know there is a command line MSBuild switch for using static graph/isolation projects. Related to nuget support, that is implemented through some Microsoft common targets mechanism and nuget restore is “technically” available in c++ projects too (e.g. nuget MSBuild tools packages can be consumed in c++ projects, although the VS UI doesn’t handle it) FYI we have mixed project type solutions (c# old/new style, sqldb, c++, powershell, Azure, SSIS, etc) incl. some customizations like using the Microsoft CentralPackageVersioning MSBuild Sdk. |
It depends if VS wants to explore this or not.
As long as projects use |
@jeffkl is this in a state where we could test it now or soon (e.g. with a preview .net core sdk)? Very excited for this. |
@zarenner we'll need to do a VS insertion and then it'll be available in internal previews. I expect to find some issues and fix them before the next release, 16.5 Preview 3. |
Did this land in Preview 3? We still see pretty poor restore times for ~1300 C# Projects in 16.5 Preview 3. (Approximately 30-60 seconds). What do you need to help debug this? |
@aolszowka - this requires an opt-in property, i believe. @jeffkl? Do we have a doc page for this yet? |
Yes you need to set the <PropertyGroup>
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
</PropertyGroup> Or for one time use: msbuild /t:Restore /p:RestoreUseStaticGraphEvaluation=true |
Awesome; Big Wins for us on some solutions (largest win was 30 seconds -> 10 seconds for a ~1,000 C# Only Solution).
|
Pinging the thread; any documentation that answers the questions?
|
I'll defer to @jeffkl here, but you should see end to end build times go down if you have super long restores.
While fast restore does use static graph, it doesn't require the users to use |
@jeffkl @rrelyea Finally gave this a try, and it shaved at least 10 seconds off for us 🎉 We're still at ~6 seconds for ~500 projects / ~200 centrally managed packages, but I'm hoping that's small enough to convince my team to get rid of our ugly broken hacks for skipping restore entirely. Do you know which 3.1 dotnet SDK this will make it into and when? Looks like it doesn't work in 3.1.201 as |
@zarenner I think its only available in 5.0 preview 2. The insertion was made here: |
Is there anything programmatic that we can gather to give higher quality evidence to show speed ups on the restore? |
The best way to measure it is to install MSBuild 16.5+ and restore from the root 3 times: msbuild /t:restore
msbuild /t:restore
msbuild /t:Restore /p:RestoreUseStaticGraphEvaluation=true The first restore might pull packages and isn't considered a no-op. The second and third restores are no-op restores without my optimization on and then with it on. In a large repo with ~740 projects it used to take around 30 seconds and now it takes 7. |
Looking at it, I don't think 3.1.300 ever happened :( |
That's a bit disappointing. When's the earliest non-preview release you think we might be able to use it? |
@zarenner |
The NuGet.Build.Tasks.Console side change has been ported to 3.1.400. |
Created & closed #9644 for release notes purposes. |
is this in the .NET 5.0.102 SDK too? |
yes, but it's still opt-in: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restoring-with-msbuild-static-graph-evaluation |
@zivkan thanks, been trying to fix an issue where Too bad I cant just cache the things that |
Details about Problem
In MSBuild 16.0, a new Static Graph API was added for parsing project trees in a more efficient way. This new API also can express dependencies so that callers can build a graph that represents the tree. NuGet should adopt this new API to replace the way projects are being evaluated via target execution which would reduce command-line restores dramatically.
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): Any
NuGet version (x.x.x.xxx): Any
dotnet.exe --version (if appropriate): Any
VS version (if appropriate): Any
OS version (i.e. win10 v1607 (14393.321)): Any
Worked before? If so, with which NuGet version:
Detailed repro steps so we can see the same problem
The restore takes around 30 seconds for 700 projects. With Static Graph and other perf improvements, it takes less than 6 seconds.
Other suggested things
Verbose Logs
Please include verbose logs (NuGet.exe -verbosity detailed | dotnet.exe --verbosity diag | etc...)
Sample Project
Very helpful if you can zip a project and paste into this issue!
The text was updated successfully, but these errors were encountered: