dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

Omnisharp causing high load and mono whatchdog crashing #3584

Open RononDex opened 4 years ago

RononDex commented 4 years ago

Issue Description

On Linux I am getting a high cpu / resource usage from omnisharp when analysing large solutions (as in ~1.5 million lines of code, 65k files).

Simple tasks like saving a file will take forever. According to my task manager it is mainly mono using up that much of cpu time (the one supplied with the plugin).

After I changed a csproj file omnisharp crashe completly with this message in the log:

Could not exec mono-hang-watchdog, expected on path '/home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/etc/../bin/mono-hang-watchdog' (errno 2)
/home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/run: line 28:  2814 

Full log:

=================================================================
Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

=================================================================
Native stacktrace:
=================================================================
0x4bc043 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x4bc3bc - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x465ae0 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x4bb648 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x7fd237afb800 - /usr/lib/libpthread.so.0 : (null)
0x7fd237611ce5 - /usr/lib/libc.so.6 : gsignal
0x7fd2375fb857 - /usr/lib/libc.so.6 : abort
0x7250c4 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x707c31 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x724fab - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x7253d3 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : monoeg_g_logv
0x72548f - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : monoeg_g_log
0x6d15d5 - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x6fbbaa - /home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/bin/mono : (null)
0x7fd008d18000 - Unknown

=================================================================
Telemetry Dumper:
=================================================================
Pkilling 0x7fcfd9a43700 from 0x7fd1d2cef700
Pkilling 0x7fcf817f9700 from 0x7fd1d2cef700
Pkilling 0x7fcf4db3f700 from 0x7fd1d2cef700
Pkilling 0x7fd04695d700 from 0x7fd1d2cef700
Pkilling 0x7fcf8802d700 from 0x7fd1d2cef700
Pkilling 0x7fcf8e861700 from 0x7fd1d2cef700
Pkilling 0x7fd1b31fc700 from 0x7fd1d2cef700
Pkilling 0x7fcf95095700 from 0x7fd1d2cef700
Pkilling 0x7fcf9b8c9700 from 0x7fd1d2cef700
Pkilling 0x7fcfd6f7b700 from 0x7fd1d2cef700
Pkilling 0x7fcfa20fd700 from 0x7fd1d2cef700
Pkilling 0x7fcfa8931700 from 0x7fd1d2cef700
Pkilling 0x7fcf6f53b700 from 0x7fd1d2cef700
Pkilling 0x7fcfaf165700 from 0x7fd1d2cef700
Pkilling 0x7fcf75d6f700 from 0x7fd1d2cef700
Pkilling 0x7fcfc0811700 from 0x7fd1d2cef700
Pkilling 0x7fcfb5999700 from 0x7fd1d2cef700
Pkilling 0x7fcf7c5a3700 from 0x7fd1d2cef700
Pkilling 0x7fcfc7045700 from 0x7fd1d2cef700
Pkilling 0x7fcfbc1cd700 from 0x7fd1d2cef700
Pkilling 0x7fd0be2ec700 from 0x7fd1d2cef700
Pkilling 0x7fd022cbe700 from 0x7fd1d2cef700
Pkilling 0x7fcfbda0a700 from 0x7fd1d2cef700
Pkilling 0x7fcf5be46700 from 0x7fd1d2cef700
Pkilling 0x7fcffceef700 from 0x7fd1d2cef700
Pkilling 0x7fcfd6369700 from 0x7fd1d2cef700
Pkilling 0x7fcf7d9da700 from 0x7fd1d2cef700
Pkilling 0x7fcf8420e700 from 0x7fd1d2cef700
Pkilling 0x7fce707da700 from 0x7fd1d2cef700
Pkilling 0x7fcf2ae00700 from 0x7fd1d2cef700
Pkilling 0x7fcf8aa42700 from 0x7fd1d2cef700
Pkilling 0x7fd193127700 from 0x7fd1d2cef700
Pkilling 0x7fcf91276700 from 0x7fd1d2cef700
Pkilling 0x7fcf97aaa700 from 0x7fd1d2cef700
Pkilling 0x7fcf9e2de700 from 0x7fd1d2cef700
Pkilling 0x7fcfa4b12700 from 0x7fd1d2cef700
Pkilling 0x7fd0124ab700 from 0x7fd1d2cef700
Pkilling 0x7fcf5d287700 from 0x7fd1d2cef700
Pkilling 0x7fcfab346700 from 0x7fd1d2cef700
Pkilling 0x7fcf71f50700 from 0x7fd1d2cef700
Pkilling 0x7fcfb1b7a700 from 0x7fd1d2cef700
Pkilling 0x7fcf78784700 from 0x7fd1d2cef700
Pkilling 0x7fceb854b700 from 0x7fd1d2cef700
Pkilling 0x7fcfc3226700 from 0x7fd1d2cef700
Pkilling 0x7fcfb83ae700 from 0x7fd1d2cef700
Pkilling 0x7fd01ee9f700 from 0x7fd1d2cef700
Pkilling 0x7fcfc9a5a700 from 0x7fd1d2cef700
Pkilling 0x7fd037256700 from 0x7fd1d2cef700
Pkilling 0x7fcfdc1fe700 from 0x7fd1d2cef700
Pkilling 0x7fcf803ef700 from 0x7fd1d2cef700
Pkilling 0x7fcf4c735700 from 0x7fd1d2cef700
Pkilling 0x7fcf86c23700 from 0x7fd1d2cef700
Pkilling 0x7fcf553c2700 from 0x7fd1d2cef700
Pkilling 0x7fcf8d457700 from 0x7fd1d2cef700
Pkilling 0x7fcf93c8b700 from 0x7fd1d2cef700
Pkilling 0x7fcf9a4bf700 from 0x7fd1d2cef700
Pkilling 0x7fcfa0cf3700 from 0x7fd1d2cef700
Pkilling 0x7fd110ae5700 from 0x7fd1d2cef700
Pkilling 0x7fcfa7527700 from 0x7fd1d2cef700
Pkilling 0x7fcf6e131700 from 0x7fd1d2cef700
Pkilling 0x7fd1d3fff700 from 0x7fd1d2cef700
Pkilling 0x7fcfadd5b700 from 0x7fd1d2cef700
Pkilling 0x7fcf74965700 from 0x7fd1d2cef700
Pkilling 0x7fcfbf407700 from 0x7fd1d2cef700
Pkilling 0x7fcfb458f700 from 0x7fd1d2cef700
Pkilling 0x7fcf7b199700 from 0x7fd1d2cef700
Pkilling 0x7fcfc5c3b700 from 0x7fd1d2cef700
Pkilling 0x7fcfbadc3700 from 0x7fd1d2cef700
Pkilling 0x7fd0218b4700 from 0x7fd1d2cef700
Pkilling 0x7fd0bcee2700 from 0x7fd1d2cef700
Pkilling 0x7fcf57825700 from 0x7fd1d2cef700
Pkilling 0x7fcf5385a700 from 0x7fd1d2cef700
Pkilling 0x7fcfcf27b700 from 0x7fd1d2cef700
Pkilling 0x7fcf82e04700 from 0x7fd1d2cef700
Pkilling 0x7fcf299f6700 from 0x7fd1d2cef700
Pkilling 0x7fcf89638700 from 0x7fd1d2cef700
Pkilling 0x7fcf8fe6c700 from 0x7fd1d2cef700
Pkilling 0x7fcf966a0700 from 0x7fd1d2cef700
Pkilling 0x7fcf9ced4700 from 0x7fd1d2cef700
Pkilling 0x7fcfa3708700 from 0x7fd1d2cef700
Pkilling 0x7fd0110a1700 from 0x7fd1d2cef700
Pkilling 0x7fcfa9f3c700 from 0x7fd1d2cef700
Pkilling 0x7fcf70b46700 from 0x7fd1d2cef700
Pkilling 0x7fcfb0770700 from 0x7fd1d2cef700
Pkilling 0x7fcf7737a700 from 0x7fd1d2cef700
Pkilling 0x7fcffb3af700 from 0x7fd1d2cef700
Pkilling 0x7fcfc1e1c700 from 0x7fd1d2cef700
Pkilling 0x7fcfb6fa4700 from 0x7fd1d2cef700
Pkilling 0x7fd1b90c3700 from 0x7fd1d2cef700
Pkilling 0x7fcfc8650700 from 0x7fd1d2cef700
Pkilling 0x7fd0596ef700 from 0x7fd1d2cef700
Pkilling 0x7fcfcb1ee700 from 0x7fd1d2cef700
Pkilling 0x7fcfec3cf700 from 0x7fd1d2cef700
Pkilling 0x7fcf7efe5700 from 0x7fd1d2cef700
Pkilling 0x7fcf4b32b700 from 0x7fd1d2cef700
Pkilling 0x7fce45ffa700 from 0x7fd1d2cef700
Pkilling 0x7fcf85819700 from 0x7fd1d2cef700
Pkilling 0x7fcf586cd700 from 0x7fd1d2cef700
Pkilling 0x7fce71de5700 from 0x7fd1d2cef700
Pkilling 0x7fcf8c04d700 from 0x7fd1d2cef700
Pkilling 0x7fcf2c40b700 from 0x7fd1d2cef700
Pkilling 0x7fd12f7bf700 from 0x7fd1d2cef700
Pkilling 0x7fcf92881700 from 0x7fd1d2cef700
Pkilling 0x7fcf990b5700 from 0x7fd1d2cef700
Pkilling 0x7fceb536b700 from 0x7fd1d2cef700
Pkilling 0x7fcf9f8e9700 from 0x7fd1d2cef700
Pkilling 0x7fcfa611d700 from 0x7fd1d2cef700
Pkilling 0x7fd013ab6700 from 0x7fd1d2cef700
Pkilling 0x7fcf6cd27700 from 0x7fd1d2cef700
Pkilling 0x7fcfac951700 from 0x7fd1d2cef700
Pkilling 0x7fcf7355b700 from 0x7fd1d2cef700
Pkilling 0x7fcf4efcb700 from 0x7fd1d2cef700
Pkilling 0x7fcfb3185700 from 0x7fd1d2cef700
Pkilling 0x7fcf79d8f700 from 0x7fd1d2cef700
Pkilling 0x7fcfc4831700 from 0x7fd1d2cef700
Pkilling 0x7fcfb99b9700 from 0x7fd1d2cef700
Pkilling 0x7fd0204aa700 from 0x7fd1d2cef700
Pkilling 0x7fcf548a9700 from 0x7fd1d2cef700
Pkilling 0x7fd038861700 from 0x7fd1d2cef700
Pkilling 0x7fd23421d700 from 0x7fd1d2cef700
Pkilling 0x7fcf819fa700 from 0x7fd1d2cef700
Pkilling 0x7fcf4dd40700 from 0x7fd1d2cef700
Pkilling 0x7fd046b5e700 from 0x7fd1d2cef700
Pkilling 0x7fcf8822e700 from 0x7fd1d2cef700
Pkilling 0x7fcf8ea62700 from 0x7fd1d2cef700
Pkilling 0x7fd1b33fd700 from 0x7fd1d2cef700
Pkilling 0x7fcfcc978700 from 0x7fd1d2cef700
Pkilling 0x7fcf95296700 from 0x7fd1d2cef700
Could not exec mono-hang-watchdog, expected on path '/home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/etc/../bin/mono-hang-watchdog' (errno 2)
/home/cobra/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.12/run: line 28:  2814 Aborted                 (core dumped) "${mono_cmd}" "${omnisharp_cmd}" "$@"

Steps to Reproduce

Expected Behavior

Actual Behavior

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.42.1 C# Extension: 1.21.11

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.101 Commit: b377529961 Runtime Environment: OS Name: arch OS Version: OS Platform: Linux RID: linux-x64 Base Path: /usr/share/dotnet/sdk/3.1.101/ Host (useful for support): Version: 3.1.1 Commit: a1388f194c .NET Core SDKs installed: 3.1.101 [/usr/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.App 3.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.1 [/usr/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| |---|---|---| |1987|annliu|0.3.1| |2077-theme|Endormi|1.4.3| |add-reference|adrianwilczynski|1.0.2| |auto-using|Fudge|0.7.9| |better-align|wwm|1.1.6| |Bookmarks|alefragnani|10.7.0| |calmness-vsc-theme|azamuddin|1.1.1| |city-lights-theme|yummygum|1.1.5| |cloudcode|googlecloudtools|1.1.2| |code-settings-sync|Shan|3.4.3| |code-spell-checker|streetsidesoftware|1.7.23| |codesnap|adpyke|1.0.27| |csharp|ms-vscode|1.21.11| |csharp-grammar-extended|dannymcgee|1.1.1| |csharp-model-to-builder|frasercrosbie|0.1.2| |csharpextensions|jchannon|1.3.1| |Cyberpunk|max-SS|1.2.5| |docomment|k--kato|0.1.8| |dotnet|formulahendry|0.0.4| |dotnet-core-essentials|KishoreIthadi|0.0.8| |dotnet-test-explorer|formulahendry|0.7.1| |EditorConfig|EditorConfig|0.14.4| |eva-theme|fisheva|0.7.9| |git-graph|mhutchie|1.21.0| |git-tree-compare|letmaik|1.8.0| |gitlens|eamodio|10.2.1| |graphql-for-vscode|kumar-harsh|1.15.3| |gruvbox|jdinhlife|1.4.0| |horizon-theme-vscode|jolaleye|2.0.2| |ilspy-vscode|icsharpcode|0.7.10| |jinja|wholroyd|0.0.8| |jira-plugin|gioboa|0.19.0| |latex-utilities|tecosaur|0.3.6| |latex-workshop|James-Yu|8.7.2| |material-icon-theme|PKief|3.9.3| |material-theme|zhuangtongfa|3.2.2| |mdx|silvenon|0.1.0| |midnight-city|dillonchanis|0.5.0| |msbuild-project-tools|tintoy|0.3.3| |mssql|ms-mssql|1.8.0| |namespace|adrianwilczynski|1.1.2| |noctis|liviuschera|10.26.0| |output-colorizer|IBM|0.1.2| |prettier-vscode|esbenp|3.20.0| |python|ms-python|2020.2.63072| |python-extension-pack|donjayamanne|1.6.0| |rainbow-brackets|2gua|0.0.6| |slime|smlombardi|3.2.1| |sqltools|mtxr|0.21.6| |supersharp|craigthomas|0.1.4| |synthwave-vscode|RobbOwen|0.1.1| |team|ms-vsts|1.161.0| |theme-onedark|azemoh|0.5.3| |theme-panda|tinkertrain|1.3.0| |todo-tree|Gruntfuggly|0.0.167| |vim|vscodevim|1.12.4| |vscode-csharp-snippets|jorgeserrano|0.3.1| |vscode-custom-css|be5invis|3.0.9| |vscode-django|batisteo|0.19.0| |vscode-docker|ms-azuretools|0.10.0| |vscode-kanban|mkloubert|1.26.2| |vscode-mdx-preview|xyc|0.2.2| |vscode-nxunit-test-adapter|wghats|0.1.3| |vscode-peacock|johnpapa|3.3.1| |vscode-test-explorer|hbenl|2.17.0| |vscode-theme-hydra|juanmnl|3.1.0| |vscode-typescript-tslint-plugin|ms-vscode|1.2.3| |vscode-versionlens|pflannery|0.24.0| |vscode-wakatime|WakaTime|2.3.0| |vscodeilviewer|josephwoodward|0.0.1| |vscodeintellicode|VisualStudioExptTeam|1.2.5| |vsliveshare|ms-vsliveshare|1.0.1615| |xml|DotJoshJohnson|2.5.0|;
JoeRobich commented 4 years ago

@RononDex You could try setting the "csharp.maxProjectFileCountForDiagnosticAnalysis" setting to a low number ( 100 perhaps? ) and see if that helps performance.

RononDex commented 4 years ago

Just tried it, it only reduces the time it takes to analyse the solution, but not the performance while it is analysing.

I think the issue is, that omnisharp gets pretty much all the system resources available on Linux, causing everything else to get slow (while on Windows Omnisharp won't get 100% of the resources)

RononDex commented 4 years ago

Update:

Just working on moving my project to .netcoreapp3.1 (https://github.com/RononDex/Astrobot) and as soon as I put the target to netcoreapp3.1, vscode goes crazy. CPU load is almost all the time at 100% due to omnisharp spawning mono processes (why? its .net core only project) and everything gets incredibly slow (as in saving a file takes up to a minute).

This is with the mentioned project above (which is a very small project really)

RononDex commented 4 years ago

Update2:

It seems the issue does not exist in omnisharp-vim VsCode is currently unusable for me on linux. Will be switching to native vim due to this

RononDex commented 4 years ago

Update3:

Same issue on windows, so its not platform specific and other people seem to have the same issue in my company.

For me vscode is pretty much unusable at the moment because of this

image Save operations can take anywhere from inbetween of 30s to 10minutes

RononDex commented 4 years ago

Update4:

Seems the slow save is caused by

"editor.formatOnSave": true

if I turn that off it saves a lot faster (altough still pretty slow)

vimota commented 4 years ago

I'm having the same issue, something must've changed in the last month or so because it continuously shows the "Running save participants" dialog during save, even though I've always had formatOnSave enabled.

RononDex commented 4 years ago

I keep getting the same even with "formatOnSave" disabled

Editing any non C# file works fine, so it is defintly related to omnisharp

However, I have switched to neovim now, since vscode is just simply unusable

cartermp commented 4 years ago

@RononDex Thanks for filing and sorry you're seeing issues. I tried cloning and building your repo, but it won't build. I also don't see high CPU load on my mac when opening up some files and formatting them. Do you have a buildable repro (e.g., clone -> build -> open specific file -> do something specific -> see high CPU load)? Thanks!

RononDex commented 4 years ago

The repo certainly does build if you have the AwesomeChatBot Framework code locally

It looks for the source code locally if you build with Debug, but uses Nuget packages if you build with Release. So building with Release should certainly work.

However compiling never was an issue

filipw commented 4 years ago

are you sure this is not caused by another extension? there was a similar issue about "Running Save Participants" but it was determined that another extension caused it https://github.com/OmniSharp/omnisharp-vscode/issues/3561#issuecomment-584331672