-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Slow build with msbuild and dotnet cli #7850
Comments
cc @rainersigwald @dsplaisted this is something that should work out of the box. |
Indeed it should--and on my machine with the current build it seems to. Of course, this is on Windows. And naturally my Mac is out of commission today. @NinoFloris can you run
And share the resulting My results (on Windows):
|
Alright sorry for the delay, here is the log https://gist.github.com/NinoFloris/6599e64cd834b2b5e920bdf42467585a I do see a lot of "Skipping target" happening but I also see at least 1800ms spent on resolving package dependencies and assembly references. I guess that is what is happening with my other projects as well, this is unacceptably slow though as a hierarchy of even three dependent packages quickly requires almost 10 seconds in total per build, incremental or not... |
The up to date check in visual studio isn't working. It's a known issue and is being worked on. /cc @davkean |
We should look into this though. /cc @emgarten |
@davidfowl (Mind you this is on OSX with vscode) but yes I do hope for a fix soon, project.json was blazing fast in comparison |
Hmm, if this is VS code then it's likely one of the tasks that's taking a long time 😞. |
From targets:
From tasks:
|
So you're saying this is fast on windows with VS? |
Nope, I'm saying there in VS on windows there is a known feature that is currently missing in the new project system with SDK projects, the "up to date" check. Which effectively avoids even calling back into msbuild if nothing in the project changed. |
Will something like the lock file come back to fix that? Or is there already something like that stored somewhere under the hood? |
There certainly is room optimising incremental builds.
Expected: Much faster builds on subsequent builds. Actual: First time:
Incremental:
|
Note that the lib scenario is much faster with the latest CI 2.0.0 builds targeting |
is there a fix available yet for the missing "up2date" check problem? |
@sepplK that's tracked by dotnet/project-system#62. |
thanks for info. debugging a solution with 20 projects is unusable slow and we have to wait again with the vs17 upgrade ... |
@dasMulli suggested something here dotnet/msbuild#1990 (comment) But there is still the issue that all the So you'd have to know what I currently do this though — which would mesh well with dasmulli's approach — I build the solution then I start the entrypoint assembly via while(!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(500); } @davkean @terrajobst It's getting a bit ridiculous having to evade all the build system pitfalls like it is, are you able to share any priority/timeline info? |
A quick read of above, are you talking about inside Visual Studio or command-line? dotnet/project-system#62 is tracking VS only. We have other bugs tracking incremental build, such as #1116 and dotnet/msbuild#1276. |
For me it's about dotnet cli. Vs and cli both call into shared parts of project system plumbing right? |
dotnet cli and VS basically share the same build infrastructure. In VS, however, due to our live monitoring of the project, we're in a place where we can quickly see if we're already up-to-date and avoid the MSBuild call. There are no current intentions to make the same change to dotnet cli, but we should still make incremental build faster there. |
Yes those issues around package & project reference resolvation you linked are the same for any of us referencing the deep and wide package graphs of (ASP).NET Core |
Is someone looking at speeding this up? |
While it's a lot faster for 2.0 due to the smaller package graphs 🎉 , it's slow again once you add |
:/ @livarcocc will anyone give some TLC to this cross platform story? We xplat users are not able to enjoy all the VS layers on top that make it fast(er) and bearable. The project.json system could do it without all that VS duct-tape on top so there should still be a lot of improvements possible in the current lower level msbuild implementation. |
This is definitely something we want to improve. We develop cross-plat nearly 100% of our time ourselves, so we feel this pain. |
It helped us to use dotnet watch run instead of just dotnet run for faster development cycles. Our project was taking 30s to build each time which was ridiculous. When we used XPROJ it was only 10-15s per build-cyle. Compressing the cycle time is critical for rapid development for our team. Using the watch it's now 2-3s for testing CSPROJ changes. Check out this link for how to add the CSPROJ dependency tool chain. In the CSPROJ, add the following to an <ItemGroup>
<!-- dotnet watch run -->
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup> Also note if you have a debugger attached to the kestrel process you will need to re-attach it. Check out the ReAttach VS IDE extension to make this painless. |
I'm seeing build times over a minute, where previously (project.json) I saw 20ish seconds worst case. A full build of my not-very-large at all project with ZERO changes takes nearly 20 seconds now. So that's all overhead, and poking around it seems to all be due to ResolveAssemblyReferences/ResolveProjectReferences. I think this is the sort of thing that can permanently hurt .net core's reputation. I don't understand why it was acceptable to replace project.json when important regressions like this are present. The decision to switch away from the new project format, which had numerous advantages, was already a contentious one. The argument I heard was frequently that it was just XML vs json, and it wasn't a huge deal. It seems that in reality that much like when DNX went away, cross-platform developers have lost a lot and gained nothing with the shift back to csproj. If cross-platform (i.e. not using Visual Studio) development truly is important to MS, I think they need to consider the impact of these sorts of regressions more carefully, and with more weight. In my opinion, the compile/run/test cycle is one of the most important to get right for developer happiness and productivity. Microsoft doesn't seem to agree, when you consider deeds vs words. |
@tetious Thank you for your well written comment, I could not agree more |
Running dotnet run takes 50 seconds average to start in my Ubuntu testing box. Which runs in the cheapest azure price tier. The website I'm running it's just 4 views, 2 controllers, no logic, just some localization and just one contact form. I had some issues to address (paths are case sensitive in linux, so some resources did not get found) when running in linux and it took me literally one entire day to address. Have another website running in Node and runs like a lighting. |
Just to make sure the feature is known: When using my "testbed" linked above with "lib1, referenced by lib2, which is in turn referenced by lib3, which is in turn" ... up to lib20, changing an implementation detail of lib1 causes the build time to be the same as the initial build. However when adding this to the <PropertyGroup>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup> The build time is only 1-2 seconds higher during incremental builds (using 2.2.0 CI build, but the feature should already be available in 2.0.0+). Only when the public interface of any assembly is changed (e.g. signature of public methods, types) the build time is as long as the initial build again. |
@AndyGerlicher @jaredpar How would you feel about turning that on by default for sdk projects? Failing that, @Pilchie, could we get some nice UI and maybe an info bar to turn it on? |
Also tagging @jcouv and @rainersigwald . I thought we had turned it on for SDK projects. If not, what are the drawbacks? That it takes longer to produce binaries that are not referenced? Could we turn it on by default for libraries, but not programs or tests? |
I think the fast-up-to-date check was the last thing holding back from general usage. I don't remember the details, but I think it couldn't statically be known whether or not to rebuild. So it was either always rebuilding or not in certain cases when it should. If we feel comfortable with the state of that with the SDK projects it should definitely be turned on. |
@Pilchie Beware though, if I turn this on for all projects in a mixed solution (C# + F#) I get errors where it can't find the ref assembly for the F# projects. |
Should this issue be fixed beforehand ? dotnet/msbuild#2431. With VS15.5, incrementally updated assemblies are not picked up the head projects, where the up to date check indeed seems to be too agressive. |
Folks, we're still making some pretty good progress - this change NuGet/NuGet.Client#1866 significantly reduces the overhead of implicit restore. We saw up-to-date |
Is there any info about whether 'dotnet build' performs poorly inside a VM (e.g. a VMWare VM with 6 virtual CPUs) ? I have a large .sln with 47 multitargeting csproj files (targeting .net 4.5.2 and .netstandard2.0) (the projects used by our unit tests, they're all generated). I do in a cmd file:
this needs sometimes 1m22 or 2m23 or thereabout (I don't know why this fluctuates, nothing else is going on on the machine nor VM). Quite slow. When I do on the commandline: This is inside the VM, VMWare, windows 8.1 x64, visual studio 15.5.5, dotnet 2.1.4. msbuild version: Microsoft (R) Build Engine version 15.5.180.51428 for .NET Framework. So I copied literally all files in this solution from the VM to the host running the VM. On it vs 2017 15.5.6 (the VM's vs installer apparently can't see an update, the one on the host os did, that aside), dotnet 2.1.4, msbuild version Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core, and the exact same .cmd file takes 41 seconds. Now, VMWare might be slow at times, but not this slow. Also the massive discrepancy between MSBuild on the guest vs. dotnet build isn't normal IMHO. So my question to you is: what can I do to dig up some information to track down the root cause of this? dotnet build is way slower than msbuild it seems, but even then, it shouldn't be that much of a difference between host and guest on the same hw. TIA |
@FransBouma: We haven't seen significant perf differences between a Hyper-V VM and the host. My first guess would be a difference in disk perf. If you can share your solution, I can measure the perf on a physical machine and a Hyper-V VM to see how they compare. You can also try a daily build of 2.1.300-preview1 which has many performance improvements to .NET Core build. I would expect the relative performance to be the same between the VM and host, but both should be significantly faster. |
@mikeharder I can't share this code sadly (it's not open source), however I've tried the 2.1.300 preview1 and it solved things :) The total build time is now ~22 seconds (retested) on the guest (VM), so I see the problem I had solved, as the upcoming release contains the fix. No further action required :) (On the host, the 2.1.300 preview1 takes 15 seconds, with 8 core parallel build). Nice progress! :) |
have a question about build times that might be related to this... I am working with a large solution with a UI app that delegates Areas (controllers/commands/models/etc.) to a bunch of smaller projects. I was trying to consolidate all the Area projects (an arbitrary partition, dependency/design-wise) into the main UI project. example:
|
When i built the Before state, after making a change to UI.csproj, i hit about 43 second builds (with 68 files). After consolidating, builds now take about 3-4 minutes (with 537 .cs files). I understand why performance would be worse here. Seems like incremental build heuristic can make easier decisions about which src files it doesn't have to re-build if changes are localized to a smaller project that has clearly defined downstream consumer projects. This make sense, but my original expectation is that i'd save time building/walking/comprehending the dependency tree and transitive package/project dependencies. In any event... would it be considered a "best practice" or a "recommendation" to split out slow-building projects into lots of smaller partitions for the sake of taking advantage of incremental builds? |
It's hard to know without seeing where the time is spent. Do a diagnostic builds of both states and share out the performance sections at the bottom of the log. I suspect csc (compile) is probably the bottle neck. |
@davkean any news on reference assembly support for local projects? So we only rebuild full chain on api changes, or too many issues? |
@rainersigwald for this one. |
@NinoFloris You can opt in to reference assembly support today. There are some docs here but the easiest way to enable it is to set <PropertyGroup>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup> in a reads upward Oh, I see you've already tried that and were seeing problems with F#? Is that the problem you're having? |
I'm having problems with this and F# as well. it's like it lost track of all my nuget packages |
@NullVoxPopuli That sounds like a different, more specific issue. Please file it as a new issue and include the steps you take to reproduce the problem. Thanks. |
Closing this issue as we have done a series of perf improvements for SDK 2.1.300 and while we will continue improving on it, we are not planning any other changes in this area for this release. |
As a heads up, more improvements have been made in Preview 2 - https://blogs.msdn.microsoft.com/dotnet/2018/04/11/announcing-net-core-2-1-preview-2/. |
That sounds good. |
Dramatic improvement here. Excellent work 👍 |
Unfortunately it is still slow on some projects. For example on OrchardCore CMS. The main project has internal dependencies which are every time recompiled and it takes like 6 minutes every build. You can check it out here: https://github.com/OrchardCMS/OrchardCore Tested with 2.1.300 on Linux. |
@adamos101 I can't see this behavior locally with Orchard Core. Even on our CI which uses lower end machine it's faster than that. Also I assume the numbers the team is showing is using Orchard Core for the large project test. Do you know which dependencies are triggering the issue you are seeing? |
@adamos101: OrchardCore is actually part of our build perf test suite, though we use a fixed commit SHA (currently https://github.com/OrchardCMS/OrchardCore/tree/21ab3a56d0b93bb5c89285d18faa7b788354c4c0 from Feb 8 2018) rather than the tip of Here are the warm build times we measure on an Azure DS4_v2 (8-core, SSD) VM running Ubuntu 16.04:
If you are seeing significantly different results (like 6 minutes for an incremental build), please let us know how to reproduce it. I will also update the commit SHA we test to the tip of |
@mikeharder sorry for the hassle, forget it. It doesn't rebuild the DLLs, they have the same timestamp. It just takes long time to go thru all the project and it is slow on my machine. I think I will need some faster quad core for that. That's why I was thinking it is rebuilding it because on my machine it took 6 minutes but it wasnt rebuilding at all. False alarm :-) |
@adamos101: We are concerned about slow builds regardless of the root cause. Would you mind sharing the specs of your machine (CPU and disk), the exact command you are running, and how long it takes? I can try to repro on an Azure VM similar to your machine. |
I am seeing a significant increase in OrchardCore incremental build time between Feb 8 and today:
We will investigate this difference, but it might be expected based on the changes to OrchardCore between these dates. |
Ok so we migrated over a few weeks ago but I'm really getting annoyed by the lack of incremental build on rc4.
Debug times take 13 seconds from f5 to debugger start because dotnet build lacks any and all smarts to see that only the top level project changed so it just rebuilds all projects again.
I don't have any experience with msbuild and I'd expect at least this to just work out of the box.
It's even not working for the simplest case
dotnet new mvc
dotnet restore
dotnet build
first time builds nicelydotnet build
changed nothing, starts all over again wasting 3 seconds of my time.The text was updated successfully, but these errors were encountered: