vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Extension causes high cpu load

Open nbonacchi opened this issue 7 years ago • 21 comments

  • Issue Type: Performance
  • Extension Name: csharp
  • Extension Version: 1.17.1
  • OS Version: Linux x64 4.18.0-15-generic
  • VSCode version: 1.31.0

ms-vscode.csharp-unresponsive.cpuprofile.txt

Find more details here: https://github.com/Microsoft/vscode/wiki/Explain:-extension-causes-high-cpu-load

nbonacchi avatar Feb 08 '19 19:02 nbonacchi

@nbonacchi Can you try upgrading to the latest mono version as suggested here and checking if the problem still persists. Also, we have a beta release containing major improvements on the code load times. You can install it by following the instructions here. Please let us know if that helps.

akshita31 avatar Feb 08 '19 19:02 akshita31

I have this same issue with Mono 5.18.

JesseTG avatar Feb 10 '19 20:02 JesseTG

I'm also running into similar performance issues. I've installed mono 5.16 64-bit (no GTK#) from the Visual Studio channel here and ensured it's on my path. Here's the version output:

>mono --version
Mono JIT compiler version 5.16.0 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          supported, not enabled.
        GC:            sgen (concurrent by default)

I've also set "omnisharp.useGlobalMono": true to force it to use that version of mono.

Per @akshita31's recommendation above I've also installed the 1.18.0-beta7 version of the csharp extension via these instructions.

Here's the relevant bits about my setup:

  • Extension Name: csharp
  • Extension Version: 1.18.0-beta7
  • OS Version: Windows_NT x64 10.0.17134
  • VSCode version: 1.31.0 (user setup)

Here's my omnisharp configuration from settings.json:

{
  "omnisharp.autoStart": true,
  "omnisharp.disableMSBuildDiagnosticWarning": false,
  "omnisharp.loggingLevel": "information",
  "omnisharp.maxFindSymbolsItems": 1000,
  "omnisharp.maxProjectResults": 250,
  "omnisharp.minFindSymbolsFilterLength": 0,
  "omnisharp.projectLoadTimeout": 180,
  "omnisharp.useEditorFormattingSettings": true,
  "omnisharp.useGlobalMono": "always",
  "omnisharp.waitForDebugger": false,
}

I've also included a CPU profile: joshampton.CPU-20190211T014534.305Z.cpuprofile.txt

joshampton avatar Feb 11 '19 01:02 joshampton

@jrieken I downloaded the profile above that @joshampton uploaded and 96% of the time is consumed by (program). As per https://stackoverflow.com/questions/3847954/what-is-program-in-chrome-debugger-s-profiler this is the program itself. Does that mean it is vscode that is consuming time here ?

akshita31 avatar Feb 13 '19 01:02 akshita31

Hard to say, generally it should be understood as time is spend outside JS-land, eg inside native land. This can be garbage collection or IPC message overflow. If you zoom in a lot you that some calls are interleaved with something I suspect as omnisharp message handling. Would it be possible that the omnisharp server send a lot of data?

screenshot 2019-02-13 at 08 44 27

jrieken avatar Feb 13 '19 07:02 jrieken

@jrieken Yeah omnisharp pushes a lot of messages and that might be the reason for this. I will investigate further into this. Thanks!

akshita31 avatar Feb 13 '19 23:02 akshita31

Does anyone have any recommendations for a workaround? I've got both Windows and Mac users on my team that are experiencing issues.

floyd-may avatar Apr 15 '19 19:04 floyd-may

@floyd-may I suspect the slow down maybe because omnisharp is sending a lot of messages. Could you try setting "omnisharp.loggingLevel" : error and restart vscode. That way it will only log error messages and might be faster

akshita31 avatar Apr 15 '19 19:04 akshita31

After a couple hours (I set it to warning because I have issues with following instructions 🙃 ) it's behaving better. Seems to be a reasonable workaround. I'll report back if I have more issues.

floyd-may avatar Apr 15 '19 21:04 floyd-may

despite setting the logging level to error, I'm still running into the same symptoms. Curiously, I'm running into this on my mac at work. Curiously it looks like mono-sgen64 is eating a ton of CPU. It seems to be triggered by intellisense. If I just type and never hit ctrl+space it seems to be fine.

Screen Shot 2019-04-16 at 1 02 53 PM

joshampton avatar Apr 16 '19 19:04 joshampton

despite setting the logging level to error, I'm still running into the same symptoms. Curiously, I'm running into this on my mac at work. Curiously it looks like mono-sgen64 is eating a ton of CPU. It seems to be triggered by intellisense. If I just type and never hit ctrl+space it seems to be fine.

I am having the same.

michaelstaib avatar Jul 23 '19 14:07 michaelstaib

I get the same with #3336

turowicz avatar Oct 10 '19 12:10 turowicz

I got this horribly with recent versions of VS Code inc. 1.40.2 on Ubuntu 18.04

I installed mono globally and set VS Code's extension to always use it.

OmniSharp server started with Mono 6.4.0.
    Path: /home/xyz/.vscode/extensions/ms-vscode.csharp-1.21.8/.omnisharp/1.34.8/omnisharp/OmniSharp.exe

rhyswat avatar Nov 29 '19 08:11 rhyswat

@rhyswat did it fix things?

michaelstaib avatar Nov 29 '19 08:11 michaelstaib

@michaelstaib yes, so far so good. I've only just done it, but VS Code is now useable again.

rhyswat avatar Nov 29 '19 08:11 rhyswat

@rhyswat thanks for your feedback. Will try it out. It is sometimes strange these CPU peaks come and go. I have some files that I cannot open in VSCode, or if I do then the mono exe goes wild. Really annoying. Will try out if that works.

michaelstaib avatar Nov 29 '19 14:11 michaelstaib

on Ubuntu with Mono JIT compiler version 6.12.0.122 setting the logging level to error seems to help a lot... but i made a few other adjustments as well. Setting the Max Project File Count for Diagnostic Analysis to 100 instead of 1000 and Max Find Symbols Items also changed to 100 from 1000

CrandellWS avatar Mar 10 '21 17:03 CrandellWS

@michaelstaib exactly the same problem, only on some files, the cpu for the mono process goes up incredibly, did you then manage to solve it by putting mono global?

FrancescoValletti avatar Jun 07 '21 17:06 FrancescoValletti

A lot has changed with O# and mono since this issue was opened. If you are still seeing problems, please open a new issue.

JoeRobich avatar Nov 11 '24 23:11 JoeRobich

I have for the most part abandoned O# for JetBrains Rider. However, this is the second issue today that I've seen closed for the same reasons, and it gives me a little bit of hope. If I were to consider switching back, is there a good place to look for advice on how to do that?

floyd-may avatar Nov 12 '24 01:11 floyd-may