-
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
dotnet run of hello world takes way too long #8697
Comments
I believe |
@livarcocc do we know the cause? if no i'd like to do some performance profile for this case |
If you want to run your application after it's already been compiled, do this: This is much quicker than using dotnet run, with or without --no-build, because dotnet doesn't need to spending time figuring out which file contains the startup object. |
I understand that, I'm suggesting that perhaps dotnet run should do something closer to that, since it seems to be the expectation. Anyone know what other frameworks CLI's do here? |
Hmm, there may be something wrong with your machine. Here's what I am seeing on mine with
NOTE: I've already done a build.
I think the expectation of Either way, 3 seconds is too long. Can you post a dump of the MSBuild Performance Summary of an incremental build? For example:
|
That's on the same order of magnitude that I'm seeing, things slow down a bit when I procmon it, but measuring build and run gives me similar numbers. I would call that too much time for a command called run on a hello world that's already built. I would expect something closer to the --no-build time for an already built project. |
Which one is too much? |
|
Can the undocumented |
Not if user expects Furthermore, the console spew is so minimal that the user doesn't even realize they are getting an incremental build + run. Even fixing that could make it feel a bit more natural. As it is now it just looks like we're incredibly slow to |
One thing that came in for
So 33% of the Of the remaining time to just build, the biggest culprit is ResolveAssemblyReferences (tracked by dotnet/msbuild#2015):
I assume the rest of the time is just overhead of spinning up processes and loading assemblies. |
On a separate note, I am pushing for https://github.com/dotnet/cli/issues/2960 to get implemented in Then it is just a matter of picking the default/unconfigured option and letting users change it if the default isn't what they want. |
If I'm writing a console application, I like that something like |
This was reported some months ago with the switch to the msbuild project system: https://github.com/dotnet/cli/issues/5918. |
Strange, but
|
To give a new user's perspective: I just downloaded .net core today on my arch machine. Got here for the same reason as OP - Edit: I don't mean to infer my use-case should be supported or that my expectation speaks for everyone. |
I'm here for the same reason as olsonpm.
|
@karlmayer which version of the .NET Core SDK ( The current Preview 1 for .NET Core 2.1 (SDK Version https://www.hanselman.com/blog/MajorBuildSpeedImprovementsTryNETCore21Preview1Today.aspx |
@dasMulli, I'm on .NET Core 2.1.100. Preview 1 looks promising -- thanks for the heads up! If I didn't have to upgrade Visual Studio to Preview as well, I'd switch over. |
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/. I'll let the graph speak for itself: |
@davkean That's nice stuff indeed! The graph speaks about "incremental build" though; does it really have to build anything if "last modified of **/*.cs" < "last modified of output.dll"? (Note: I know absolutely nothing about how the underlying implementation looks in this case, merely scratching the surface as an innocent bystander.) (What I mean to say: checking the file dates of all affected files and comparing with the target file should be much less than 10s on any reasonably-sized project on a normal SSD disk.) |
In effect that's what it's doing, there's just overhead in:
Lots of above improvements is just being smart around trying to get to the "are they are up-to-date" as quick as possible. |
@perlun That's pretty much how the underlying build framework (MSBuild) works. "Incremental Build" refers to additional builds started after an initial build. The recent efforts of the team included both "classic perf work" on existing code (e.g. a community PR made MSbuild's directory scanning much faster) as well as reducing duplicated work in incremental builds - loading cached outputs if the inputs didn't change. This also makes incremental builds much faster even if C# code needs to be recompiled, but maybe your referenced NuGet packages and other projects didn't change and MSBuild doesn't need to resolve potential conflicts of same assemblies in different versions again, or search for additional dependencies it found in the first build. |
I think the interesting thing here, is that if MSBuild was a closed system, I'm pretty damn confident we could make this blazingly fast. It's not. By design, it's an open extensible system and any package, SDK, project can and do supplement the build process. We have to be able to identify performance issues and fix each individual step in the process and do it in a way that makes sure you projects still build in the same ways. It's challenging but its really rewarding to see the 10s of devs involved in this pipeline to all rally around a single goal to make builds as fast as possible. |
With the latest 2.1 update and VS update the debugging got super slow. |
@Looooooka Can you please Help -> Send Feedback -> Report a Problem from and record the "slow" debugging? This will give us traces/data underneath that will help us identify the cause. |
It is quite slow when I just run the |
I was using core 3.0.100-preview9-014004 today on a Windows 10 machine and it's still slow to compile it in powershell. 1.7 seconds to run the simple hello-world project and 0.5 seconds with no-build. If I just run the dll it runs like I'd expect at 0.1 seconds. |
I'd just like to add some timings here... i think it speaks for itself.
real 0m0.184s
real 0m6.336s dotnet --version Ubuntu on Win10... I also see near identical timings with dotnet run on windows command line. |
The two times above are non-comparable. They are not meant to be equivalent.
Meanwhile, While it could, potentially be faster, it will never have the same perf as |
Yeap, totally understood that there's more going on, but you hit the nail on the head with regards to "similar to F5"... hitting F5 I'm sub 1 second and that's including an attached debugger, so 4-5 seconds without the debugger makes for a frustrating dev experience (incidentally, no build and no restore options didn't help). Anyway, just adding weight as it's putting me off that particular dev experience. |
Just started learning C#, i'm on a low end machine atm, and i´m already here. One thing that i noticed is that build and run the exe is faster than just the run command, which is odd:
I´m very confused. |
Find myself in the same boat here. Used C# with VS back in the 2006 era or so and loved the rapid development experience coupled with the IDE. I suspect VS was background compiling files as I changed them. Now I find myself enjoying C# + dotnet while using MonoGame, but the dev experience is definitely hindered by the slow compile + launch even on very recent hardware. |
I'm in the exact same position as you and had the same thought! Can this issue be resolved, or is it just something we must get used to? |
here command test run:
2nd run
3rd run
Code using Java before, I consider this as a slow run. |
Especially when whole windows start in ~20 seconds, and cold run of winword taking 3 seconds. That 4seconds to start the empty app is... a little bit too much... |
We're investigating CLI performance for the commands frequently used during development as part of .NET 6 and we definitely expect to get improvements to this very common scenario of running a simple app via As it stands today, using a nightly build of .NET 6.0-preview.3, a Progress on this work can be followed at dotnet/msbuild#5876 |
Same problem here. I just started using Core after using Framework for years. Imagine a new developer, evaluating which language to use and looking up a "Hello, World!" tutorial for each. DotNet Core 5.0 is extremely noticeably slow compared than any other language. What does that new developer likely do? |
Original poster here. Just sharing my opinion in why I originally opened this. Dotnet run does a full incremental build and I didn’t expect that. I wanted something faster, if even just a hueristic like “has any build been done” rather than a full incremental. I expect a full incremental build to take time, and I think the time it takes is reasonable. I also think the time for a direct run of the output is reasonable. AOT is great, and did exist before .NETCore did (UWP: .NETNative) but that’s not really going to have an impact here. The bottle neck is not JIT it’s IO for the incremental build. If folks don’t feel like changing dotnet run to use a lighter weight hueristic is something we want to do then I suggest closing this issue and opening other issues more focused on specific perf issues they are facing. |
Worth pointing out there's already |
As stated by @ericstj I think this issue is best closed now and specific issues can be opened to track specific perf issues or ask for specific features. |
Reported by @migueldeicaza
Steps to reproduce
Expected behavior
dotnet run
executes fast, nearly the same as callingdotnet <pathToDll>
Actual behavior
dotnet run
is slow, about 3 seconds on my machine. It's consistently this slow, even when it doesn't need to rebuild.It appears that run is calling msbuild twice before actually running the app:

Can't we have a fast-path here that bypasses MSBuild? It seems like we've optimized for incremental build via the run command which I'm not sure is really the primary workflow for run (but I may be wrong).
The text was updated successfully, but these errors were encountered: