Skip to content
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

Perf: OmniSharp takes several minutes to load projects #926

Open
natemcmaster opened this issue Jul 24, 2017 · 21 comments
Open

Perf: OmniSharp takes several minutes to load projects #926

natemcmaster opened this issue Jul 24, 2017 · 21 comments

Comments

@natemcmaster
Copy link
Contributor

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

@davidfowl
Copy link
Member

davidfowl commented Feb 13, 2018

I'm hitting this too. Larger solutions need more time to load. Can VS code load projects in parallel?

@Figbash
Copy link

Figbash commented Apr 10, 2018

Is there anything that can be done to speed this up locally? It's taking around 2.5 minutes on my project.

@DustinCampbell
Copy link
Contributor

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.

@Figbash
Copy link

Figbash commented Apr 10, 2018

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?

@DustinCampbell
Copy link
Contributor

Wow! That's pretty significant! I don't know if there's any way to disable it. @mholo65: Do you have any ideas?

@filipw
Copy link
Member

filipw commented Apr 11, 2018

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.

@bjorkstromm
Copy link
Member

@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

@Figbash
Copy link

Figbash commented Apr 11, 2018

@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!

@DustinCampbell
Copy link
Contributor

@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.

@savpek
Copy link
Contributor

savpek commented Feb 2, 2020

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 🤔

@vchirikov
Copy link

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.

@TCROC
Copy link

TCROC commented Dec 10, 2020

Is there an update on this? It takes quite a while for our projects to load with Omnisharp

@TCROC
Copy link

TCROC commented Dec 10, 2020

Unity Development

@TCROC
Copy link

TCROC commented Jan 27, 2021

Just checking in to see if there are any updates on this issue. It is definitely something our team struggles with still.

@apppppppple
Copy link

Yep - Even just opening a file can take several minutes for omnisharp to load, if it loads at all

@TCROC
Copy link

TCROC commented Feb 22, 2021

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.

@jparadnikas
Copy link

Waiting like 30secs for 30k lines

@gearsetdave
Copy link

#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.

@henryju
Copy link
Contributor

henryju commented Oct 25, 2021

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.

@Thiago-Morais
Copy link

Is there any update on this?

@loeffel-io
Copy link

loeffel-io commented Sep 21, 2024

please 🙏

its so annoying - everything is working but its just so slowwwww

this is my config for unity projects:

                lspconfig["omnisharp"].setup({
                    on_attach = function(client, bufnr)
                        -- Disable highlighting as it can be slow
                        client.server_capabilities.semanticTokensProvider = nil
                        print("Omnisharp done")
                    end,
                    capabilities = capabilities,
                    cmd = { "omnisharp", "--languageserver", "--hostPID", tostring(pid) },
                    root_dir = lspconfig.util.root_pattern("*.csproj", "*.sln"),
                    handlers = {
                        ["textDocument/definition"] = omnisharp_extended.handler,
                        ["textDocument/references"] = omnisharp_extended.handler,
                        ["textDocument/implementation"] = omnisharp_extended.handler,
                        ["textDocument/typeDefinition"] = omnisharp_extended.handler,
                    },
                })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests