vscode-csharp: C# plugin hangs and cause high CPU usage while opening a big project

Issue Description

Since C# plugin 1.21.13, the C# plugin seems to hang when I open a project with more than 700 files. There is also a side effect that causes extensionHosts to max out a single CPU core. It can be reproduced 100% of the time and I have not experience the hang to finish at any point.

**EDIT: ** My project is a Unity project

1.21.12 was the last version that was working properly for me.

Steps to Reproduce

  1. Open my project with C# plugin 1.21.13 or 1.21.14 installed
  2. Observe OmniSharp log to stop at a point
  3. Observe extensionHosts using nearly 100 unit of CPU image

Expected Behavior

Project loads properly (Omnisharp prints “solution initialized”) in about a minute, Code Lens and jump to declaration works properly.

Actual Behavior

Project does not finish loading, Reference Code Lens does not appear and jump to declaration does not work.

Logs

OmniSharp log

The log contains file names to an already-live project, so I am hesitant to share. In summary, the log stops at the same line of text every time when the issue occurs.

C# log

None

Environment information

VSCode version: 1.43.0 C# Extension: 1.21.13

Mono Information OmniSharp using global mono :6.8.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.0.101 Commit: bc5f8df0f5

Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.0.101/

Host (useful for support): Version: 3.0.1 Commit: 32085cbc72

.NET Core SDKs installed: 2.1.103 [/usr/local/share/dotnet/sdk] 2.1.505 [/usr/local/share/dotnet/sdk] 3.0.101 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.0-rc2-3002702 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
cpptools ms-vscode 0.26.3
csharp ms-dotnettools 1.21.13
FlatUI lkytal 1.4.9
theme-bluloco-light uloco 3.0.1
theme-flatui danibram 3.1.0
theme-karyfoundation-themes karyfoundation 20.0.3
vscode-antlr4 mike-lischke 2.2.3
vscode-clang mitaki28 0.2.3
vscode-icons vscode-icons-team 10.0.0
xcode-default-theme smockle 2.0.21

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@NTaylorMullen I believe this glob is chewing up the CPU for users with large node_modules. https://github.com/OmniSharp/omnisharp-vscode/pull/3593/files#diff-8c9691b11e7b8efdf4865f5653a295c5R175

Oh goodness! Wow that’s awful, i’ll absolutely take a stab at making that code more targeted instead of diving the whole directory.

@mdowais Thank you so much for your investigation. I was looking through the changes in 1.21.13 and I think you hit on it being the node_modules folder.

@NTaylorMullen I believe this glob is chewing up the CPU for users with large node_modules. https://github.com/OmniSharp/omnisharp-vscode/pull/3593/files#diff-8c9691b11e7b8efdf4865f5653a295c5R175

We’ve had several users share .cpuprofiles which showed a large amount of time in the glob package, but I didn’t give it much weight since I know the heavy lifting is done in .NET.

Please try the v1.21.15 prerelease and let us know if it resolves your performance issue.

This version resolves my issue.

Please try the v1.21.15 prerelease and let us know if it resolves your performance issue.

I am facing this issue, and so far i have noted a few things.

My Project is of ASP.NET CORE + Angular, everything was working fine before an Auto Update screwed it up.

My Findings :

  1. Revo Uninstalled VSCode, No Fix
  2. VsCode Insider also faces this isssue.
  3. No issue with a blank MVC or webapi template
  4. Not causing issue when creating a new dotnet core + angular project dotnet new angular node_modules installed, and all is well

Notable Findings: 5) Removed node_modules folder inside the angular client folder in my project, works 6) Ran npm i, restarted IDE SCREWED UP Again (Note: yes my project depends on alot of npm which should not be related to omnisharp correct?) 7) It takes sometime like maybe 30-40 seconds, and it works normally.

So node_modules maybe causing trouble, and i don’t have much idea about Unity Engine, but does it use node_modules?

and is there a hack to make omnisharp completely ignore the node_modules or angular client folder which may make it work??

@JoeRobich