Improving dotnet run file.cs
performance
#48011
Labels
Milestone
dotnet run file.cs
performance
#48011
Issue to capture data, ideas, etc. regarding improving the DX performance of the new
dotnet run file.cs
feature. Specific work item issues can be added as sub-issues to this epic.Some baseline numbers
Windows & WSL2 numbers measured on the same machine. Mac numbers measured on an M4 Mac Mini. Both Windows & Mac machines enrolled in corporate device management.
dotnet --list-sdks
dotnet --list-sdks
dotnet --list-sdks
dotnet run --help
run
command. Basically as fast as an invocation ofdotnet run
can be. Anything we can do to reduce this should improve the DX ofdotnet run file.cs
too.dotnet run --help
dotnet run --help
dotnet exec hello.dll
dotnet exec hello.dll
dotnet exec hello.dll
Windows vs. Linux (WSL)
I did some comparisons of running
dotnet run hello.cs
on various Windows 11 machines (both Intuned and not Intuned, desktops and laptops) vs. running it in a WSL2 Ubuntu instance on those same machines. In each case, the .NET CLI was installed into the Linux instance and the test C# files were in the Linux file system directly rather than accessed via the host.In all cases, running
dotnet run hello.cs
in the WSL instance was significantly faster, usually around 40-50% faster but sometimes even more. On my laptop It usually took around 2-2.5 seconds in Windows, and in WSL it took only 1.1-1.2 seconds. On my desktops the numbers were more like Windows 1.5 seconds, WSL 1.0 seconds.This pattern was consistent whether running with real-time antivirus inspection enabled or disabled (either via directory exclusions or by completely disabling it).
Not sure what action we can take other than profiling to help isolate the differences but the data seemed interesting to record.
Build vs. no-build
The overhead of performing a build (i.e. using MSBuild) during
dotnet run hello.cs
is significant. Directly comparingdotnet run hello.cs
todotnet run hello.cs --no-build
results in times like the following (all measurements taken on the same machine):dotnet run file.cs
dotnet run file.cs --no-build
dotnet run file.cs
dotnet run file.cs --no-build
It seems it will be extremely beneficial to explore ways in which we can speed up the build step, or completely avoid it when possible, given the more scoped set of changes that might occur between runs of a specific C# file, e.g.:
#:sdk
and#:package
) as the set of inputs to the compiler is fixed (e.g. at CLI build time) and could be invoked directlyThe text was updated successfully, but these errors were encountered: