microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.18k stars 29.28k forks source link

Code Helper is overloading CPU #11096

Closed johanbove closed 8 years ago

johanbove commented 8 years ago

Steps to Reproduce:

  1. Open Visual Studio Code
  2. Open a project
  3. Open activity monitor and check that % CPU is over 100

ActivityMonitor analysis .txt file: https://www.dropbox.com/s/0zrsjo7c1aas4qs/ActivityMonitorCodeHelperAnalysis.txt?dl=0

johanbove commented 8 years ago

Seems like a duplicate of #9572

dbaeumer commented 8 years ago

@bpasero assigning to you. I saw that you had similar issues as well.

@johanbove could you please provide the command line of the Code Helper process causing the high CPU usage. And can you reproduce this without having any extension installed.

johanbove commented 8 years ago

Thanks for the follow up @dbaeumer ! The tip from gerhardcit to add the bower_components folder to files.watcherExclude list helped.

Perhaps this folder should be added per default?

bpasero commented 8 years ago

@johanbove is there something in that folder that you would need to be notified about? Disabling file events has consequences, e.g. the explorer not updating if something changes within. Do bower developers typically hide this folder from the explorer?

bpasero commented 8 years ago

@johanbove actually is bower_components comparable to node_modules for node.js?

johanbove commented 8 years ago

@bpasero Yes, in a way the _bowercomponents is similar as when used in a project it contains third-party tools and libraries which are "imported" into a project. Bower is also a package manager: https://bower.io/

I'm not sure what Code Helper actually does, so unless a developer is working on a particular bower_component itself, I assume VSCode should not watch this folder for changes.

johanbove commented 8 years ago

Update: I'm having the issue with the high CPU load again even-though so it looks like excluding the "bower_components" folder does not resolve the issue. How can Code Helper be analyzed to get details on what is it crunching on so intensively?

bildschirmfoto 2016-08-31 um 12 45 19

I have these extensions installed ($ code --list-extensions):

bpasero commented 8 years ago

@johanbove first thing is to find out the arguments of this process, e.g. is this really the file watcher or not. Can you provide this details?

johanbove commented 8 years ago

@bpasero How do I get the arguments of the running process through Activity Monitor?

bpasero commented 8 years ago

@johanbove from the command line "ps aux | grep <pid>" taking the PID from the activity monitor.

johanbove commented 8 years ago

OK, started VSCode without extensions active with code --disable-extensions . and it seems to be running a lot "cooler" now. So it's probably an extension misbehaving. Will start again with all extensions active and when the Code Helper process goes berserk again I will execute the command to get to the arguments and will post back here.

johanbove commented 8 years ago

Output for the arguments command; Code Helper PID 5205 raises CPU % over 100;

ps aux | grep 5205
johanbove        5205 100,1  3,6  3741216 598876   ??  R    12:57pm   1:02.72 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap --type=watcherService
johanbove        5260   0,0  0,0  2444056    824 s001  S+   12:58pm   0:00.00 grep 5205
johanbove commented 8 years ago

But it went down again now... :-) Will keep an eye out for a Code Helper process which stays over 100% for longer periods and will report back here. Now that I know how to report this it'll be more helpful for sure.

bpasero commented 8 years ago

@johanbove it is actually pretty easy: if you open VS Code on a large workspace, the file watcher has to walk each and every folder and file within. This causes high CPU spikes right on startup, independent from extensions. The only way to get this down is to set the files.watcherExclude on large folders that you do not look at.

Eventually though the CPU spike goes down and stays low. If you see this NOT happening, it defnitley is unexpected.

johanbove commented 8 years ago

I pinpointed the CPU load issue to the extension: "glen-84.sass-lint-0.0.1"; Will contact the author of the plugin.

ps aux | grep 9566
johanbove        9566 161,8  3,1  3755952 516588   ??  S     8:13am  23:18.99 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Users/johanbove/.vscode/extensions/glen-84.sass-lint-0.0.1/node_modules/vscode-languageclient/lib/utils/electronForkStart /Users/johanbove/.vscode/extensions/glen-84.sass-lint-0.0.1/server/server.js
johanbove        9848   0,0  0,0  2464536    880 s001  S+    8:27am   0:00.00 grep 9566
johanbove commented 8 years ago

For future reference: here is the issue posted in the "sass-lint" project: https://github.com/glen-84/vscode-sass-lint/issues/2

bpasero commented 8 years ago

Thanks 👍

hhstore commented 7 years ago

+1.

kmturley commented 7 years ago

Excluding bower/node/jspm folders could help:

Code -> Preferences -> User Settings

"files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/.DS_Store": true,
    "**/bower_components": true,
    "**/jspm_packages": true,
    "**/node_modules": true
}

Otherwise can try using a different extension, this one seems to work: https://marketplace.visualstudio.com/items?itemName=adamwalzer.scss-lint

See difference between them in performance:

screen shot 2017-01-24 at 1 00 20 pm screen shot 2017-01-24 at 1 01 17 pm
glen-84 commented 7 years ago

The issue with the sass-lint extension should be fixed in v0.0.4.

Apologies for the inconvenience.

johanbove commented 7 years ago

Thanks for fixing this! 👍

besquared commented 7 years ago

I started experiencing this as well after installing the recent "Angular Language Service" extension. Removed it for now and things seem to be back to normal.

gbezyuk commented 7 years ago

The same issue happens using vetour now, see https://github.com/vuejs/vetur/issues/216

nickytonline commented 7 years ago

I'm seeing this issue as well with the latest VS Code. Here's what I have for extensions: Bookmarks - Version :0.15.2 code-settings-sync - Version :2.8.2 debugger-for-chrome - Version :3.1.6 debugger-for-edge - Version :0.4.1 debugger-for-ios-web - Version :0.1.2 docthis - Version :0.4.7 EditorConfig - Version :0.9.4 gitblame - Version :2.0.2 gitflow - Version :1.1.1 githistory - Version :0.2.2 Go - Version :0.6.62 html-css-class-completion - Version :1.8.0 html-snippets - Version :0.1.0 javascript-unit-test-snippet - Version :1.0.0 JavaScriptSnippets - Version :1.4.1 jenkinsfile-support - Version :0.1.0 Material-theme - Version :2.9.8 nodejs-extension-pack - Version :0.1.9 npm-intellisense - Version :1.3.0 path-intellisense - Version :1.4.2 PowerShell - Version :1.4.1 prettier-vscode - Version :0.21.0 prettify-json - Version :0.0.3 project-manager - Version :0.18.1 quokka-vscode - Version :1.0.44 react-native-react-redux - Version :1.0.1 react-redux-es6-snippets - Version :2.1.0 rest-client - Version :0.14.6 Ruby - Version :0.12.1 sass-indented - Version :1.4.1 search-node-modules - Version :1.1.1 slack - Version :0.0.13 theme-dracula - Version :2.1.3 tslint - Version :0.17.0 typelens - Version :1.4.1 view-in-browser - Version :0.0.5 vscode-babel-coloring - Version :0.0.4 vscode-color - Version :0.4.1 vscode-docker - Version :0.0.16 vscode-eslint - Version :1.2.11 vscode-gutter-preview - Version :0.10.0 vscode-html-css - Version :0.1.7 vscode-jest - Version :2.2.0 vscode-markdownlint - Version :0.10.0 vscode-npm-script - Version :0.2.0 vscode-svgviewer - Version :1.4.2

Does anyone know if any of these extensions cause the CPU to make Code Helper spike to 100%?

shikkaba commented 7 years ago

I'm still seeing this.

cklanac commented 7 years ago

Just experience the same problem.

Comparing my extensions to @nickytonline list I had two extensions in common:

altintx commented 7 years ago

I experience this problem most days. At this point all my extensions are disabled. 4 are installed but all are disabled:

cklanac commented 7 years ago

Update, I tracked my issue down to Code Spell Checker and a really large seed-data JSON file. Disabling Code Spell Checker solved my issues. To be fair to Code Spell Checker and @Jason-Rev, CSpell is a great extension. So the next step is to disable spell checking for targeted files.

Jason3S commented 7 years ago

@cklanac Thank you! That gives me a place to start looking. But it does not see to be the same issue as others.

Jason3S commented 7 years ago

@cklanac can you open a new issue here: https://github.com/Jason-Rev/vscode-spell-checker/issues/ with some details about your setup.

Can you include things:

Thank you.

Moulde commented 7 years ago

I don't have vs code open, and code helper is still eating my battery. Shouldn't this process close when i close vs code?

drcmda commented 7 years ago

Running VSC beta its constantly up 100% cpu until the computer becomes so slow that i can't type and click any longer.