omnisharp-roslyn
omnisharp-roslyn copied to clipboard
Perf: OmniSharp takes several minutes to load projects
OmniSharp is timing out on loading solutions with large files within the default timeout in VS code (60 seconds). The timeout can be increased, but the solution still takes several minutes to load. On some solutions, it takes 3-4 minutes to load the project system.
Repro: git clone https://github.com/aspnet/Blazor-Hackathon dotnet restore Blazor.Core.sln Open VS Code and try to load Blazor.Core.sln
Canonical link: https://github.com/aspnet/Blazor-Hackathon/tree/a8c341fcb5a519fb7c931eaa9ba23bde560433ef
Result The output log shows OmniSharp trying to load the project correctly, but it times out after 60 seconds with an error printed to the Output > Omnisharp Log window in in VS Code.
Workaround Increase project load timeout to 4 minutes
{
"omnisharp.projectLoadTimeout": 240
}
Details VS Code: 1.14.2 C# Extension: 1.12.0-beta3 Mono: 5.2.0.196 OS: macOS 10.12.5 dotnet: 2.0.0-preview2-06497
I'm hitting this too. Larger solutions need more time to load. Can VS code load projects in parallel?
Is there anything that can be done to speed this up locally? It's taking around 2.5 minutes on my project.
This is going to get faster soon. We've just taken newer MSBuild bits, which have some performance enhancements. In addition, you can install the latest Mono MDK and load OmniSharp via that Mono rather than the stripped-down Mono that OmniSharp includes to get a speed boost. If you run OmniSharp on an official Mono install, it will run on native AOT-compiled images rather than JIT.
OK, using official Mono shaves off ~10 seconds for me, I am looking forward to the MSBuild enhancements! For me at least 35 seconds of it is taken between: [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in '*****'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files Is there possibly a way to disable this detection?
Wow! That's pretty significant! I don't know if there's any way to disable it. @mholo65: Do you have any ideas?
you can always disable any project system (msbuild, dotnet, script, cake) using the following syntax in the omnisharp.json file.
{
"{project key}": {
"enabled": false
}
}
So in this case it would be:
{
"cake": {
"enabled": false
}
}
Then to project system wouldn't even get initialized.
@DustinCampbell @Figbash yeah problem is that both csx project system and cake project system searches all files in all directories for csx
or cake
files. This is a known issue and reported here.
ping @filipw
@filipw Thanks, that helped shave off 35 seconds. @DustinCampbell @mholo65 Yes that is definitely the issue, now it's OmniSharp.DotNet.DotNetProjectSystem taking the time I believe, but I assume I need that one. My solution files are all in the same root folder as my workspace, so searching through all the subfolders to find them is fruitless, if that is what it is doing. Perhaps an option to only search 1 level, or to respect VSCode's files.exclude option in the VSCode plugin? It is a Unity project and has ~850K(!) files in the various subfolders. Thanks for looking into it!
@Figbash: You only need the DotNetProejctSystem if you are using legacy project.json projects. If you're doing Unity work, you can safely disable this one too.
I tried to write prototype that loads projects concurrently. Expensive/slow part is project instance build step that takes majority of time during load. However it seems that build cannot be executed concurrently The operation cannot be completed because a build is already in progress
if i try execute var buildResult = projectInstance.Build(...)
in parallel (MSB.Execution.ProjectInstance
).
Is there way to build concurrently in msbuild workspace at all? Steps like updating projects takes only few percent of total time during startup, so this build is the part of optimize if any 🤔
We have about 260 projects, and omnisharp is completely unusable, because of slow loading of projects.
I know that msbuild is slow, and it can takeup to 30 sec to evaluate of all csproj properties (with 1 thread) but with omnisharp ProjectManager
init took 15 min.
Is there an update on this? It takes quite a while for our projects to load with Omnisharp
Unity Development
Just checking in to see if there are any updates on this issue. It is definitely something our team struggles with still.
Yep - Even just opening a file can take several minutes for omnisharp to load, if it loads at all
And before this is written off as a hardware issue on the user's end, here are my hardware specs:
Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz 32 GB RAM 500 GB NVME SSD GPU RTX 2070 Super
And OS is Ubuntu 20.04
So my hardware should be able to load up my projects faster than it does. Other IDEs that I use for the same project load up much faster.
Waiting like 30secs for 30k lines
https://github.com/OmniSharp/omnisharp-roslyn/issues/1074 was marked as a duplicate of this, but in fact they are different. This is talking about large files taking a long time and timing out. 1074 is talking about multi-project solutions.
If you've got a large number of projects in your solution, vscode loads the one by one in a single thread, which takes ages. To solve that issue will be a different change than to solve slow loading of large projects.
I tried to load this solution from AWS SDK in OmniSharp v1.37.16: https://github.com/aws/aws-sdk-net/blob/master/sdk/AWSSDK.NetStandard.sln There are 289 projects.
It took 3min37 to load on my box (using the embedded mono).
sh omnisharp-linux-x64-v1.37.16/run -v DotNet:enablePackageRestore=false --encoding utf-8 -s /home/julien/tmp/aws-sdk-net/sdk/AWSSDK.NetStandard.sln | ts '[%Y-%m-%d %H:%M:%S]' > omnisharp_aws_netstandard_1.37.16.log
Loading most projects is "quick", but loading 3 test projects takes most of the time (1min47):
[2021-10-25 17:41:15] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectSystem","Message":"Detecting projects in '/home/julien/tmp/aws-sdk-net/sdk/AWSSDK.NetStandard.sln'."},"Seq":30,"Type":"event"}
[2021-10-25 17:41:15] {"Event":"log","Body":{"LogLevel":"DEBUG","Name":"OmniSharp.MSBuild.ProjectSystem","Message":"Parsing ProjectConfigurationPlatforms of '/home/julien/tmp/aws-sdk-net/sdk/AWSSDK.NetStandard.sln'."},"Seq":31,"Type":"event"}
[2021-10-25 17:41:15] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Queue project update for '/home/julien/tmp/aws-sdk-net/sdk/src/Core/AWSSDK.Core.NetStandard.csproj'"},"Seq":32,"Type":"event"}
[...] // Loading ~280 projects in ~100s
[2021-10-25 17:42:52] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Loading project: /home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj"},"Seq":1466,"Type":"event"}
[2021-10-25 17:43:26] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Successfully loaded project file '/home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj'."},"Seq":1467,"Type":"event"}
[2021-10-25 17:43:26] {"Event":"MsBuildProjectDiagnostics","Body":{"FileName":"/home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj","Warnings":[],"Errors":[]},"Seq":1468,"Type":"event"}
[2021-10-25 17:43:26] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Adding project '/home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/IntegrationTests/IntegrationTests.NetStandard.csproj'"},"Seq":1469,"Type":"event"}
[2021-10-25 17:43:26] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Loading project: /home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/UnitTests/UnitTests.NetStandard.csproj"},"Seq":1470,"Type":"event"}
[2021-10-25 17:44:02] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Successfully loaded project file '/home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/UnitTests/UnitTests.NetStandard.csproj'."},"Seq":1471,"Type":"event"}
[2021-10-25 17:44:02] {"Event":"MsBuildProjectDiagnostics","Body":{"FileName":"/home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/UnitTests/UnitTests.NetStandard.csproj","Warnings":[],"Errors":[]},"Seq":1472,"Type":"event"}
[2021-10-25 17:44:02] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Adding project '/home/julien/tmp/aws-sdk-net/sdk/test/NetStandard/UnitTests/UnitTests.NetStandard.csproj'"},"Seq":1473,"Type":"event"}
[2021-10-25 17:44:02] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Loading project: /home/julien/tmp/aws-sdk-net/sdk/test/SmokeTests/AWSSDK.SmokeTests.NetStandard.csproj"},"Seq":1474,"Type":"event"}
[2021-10-25 17:44:39] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Successfully loaded project file '/home/julien/tmp/aws-sdk-net/sdk/test/SmokeTests/AWSSDK.SmokeTests.NetStandard.csproj'."},"Seq":1475,"Type":"event"}
[2021-10-25 17:44:39] {"Event":"MsBuildProjectDiagnostics","Body":{"FileName":"/home/julien/tmp/aws-sdk-net/sdk/test/SmokeTests/AWSSDK.SmokeTests.NetStandard.csproj","Warnings":[],"Errors":[]},"Seq":1476,"Type":"event"}
[2021-10-25 17:44:39] {"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.ProjectManager","Message":"Adding project '/home/julien/tmp/aws-sdk-net/sdk/test/SmokeTests/AWSSDK.SmokeTests.NetStandard.csproj'"},"Seq":1477,"Type":"event"}
Then the Adding reference
phase takes 10s.
I'm not sure how I can help, but I would be very interested by a speed boost when loading this kind of solution.