microsoft / vscode

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

Code Helper high CPU usage on MacBook Pro 15 #11963

Closed pitAlex closed 8 years ago

pitAlex commented 8 years ago

I've notice there are several closed posts related to this issue, but it started to act up again. Before 1.5.2 I was using 1.3 since 1.4 had a problem with syntax highlighting and from time to time I used to get high cpu from "electron helper" even tough I have git disabled and only 3 extensions : "Project Manager", "Run on Save" and "HTML CSS Support". I upgrade to 1.5 and now Code Helper is the one that does it. I can happen 2, 3 times per day. It doesn't matter if you have lots of files opened or not, or if you are doing some had work, it just happens randomly. Once I left it minimize more then half an hour and my fans just started up suddenly as a result of the Code Helper going up to 99.9 CPU usage.

I've attached a screenshot showing the usage :

screen shot 2016-09-13 at 5 11 18 pm
bpasero commented 8 years ago

@pitAlex can you please find out the full arguments of this process to find out which process is causing high CPU load from the ones VS Code spawns as helpers.

cjdell commented 8 years ago

I'm having a similar issue with the Code Helper process. I have disabled all extensions. It appears to be steadily getting worse. It was minor annoyance a few weeks ago, I would occasionally just kill the Code Helper process and be back to normal again. Now the Code Helper just eats 100% of a core almost all of the time now. I even see this happen on occasion now:

image

bpasero commented 8 years ago

@cjdell also please find out the full arguments of the process that goes ballistic: ps aux | grep <pid of process>

cjdell commented 8 years ago

@bpasero Here you go:

/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=searchService

bpasero commented 8 years ago

@pitAlex for you as well?

@chrmarti this points to an issue with search service, moving to you.

Wallethub commented 8 years ago

@bpasero I'll post as soon as it happens again, I didn't look at arguments last time it did.

cjdell commented 8 years ago

May also be relevant, my project directory has 82097 files, though all but about 2000 of those files are excluded in settings.json.

chrmarti commented 8 years ago

We've seen similar reports with many 'find' processes sticking around. So far I assumed these were triggered by #11181 because the user might have opened-closed QuickOpen a few times while 'find' is taking some time due to #11874, yet it seems there is more to it.

Any idea why 'find' might stay around?

@cjdell To confirm this is something else: Could you run time (find -L . -type f | wc -c); echo $? and time (find -L . -type f | wc -l); echo $? in your project folder and paste the output here?

imsky commented 8 years ago

happening to me as well

CPU hog is this command:

/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
jameslaneconkling commented 8 years ago

I'm experiencing something similar to @cjdell: vs code spins up a bunch of 'find' processes that eat up a huge amount of CPU time when searching for files, and searching for files hang. The project I'm running into this with has a huge dependency tree, all of which should be excluded by the files.exclude setting.

Am not experiencing the same issue in smaller projects.

This was not an issue before this morning, when I updated to 1.5.2 (not sure what my previous version was...).

cjdell commented 8 years ago

@chrmarti

Chriss-MBP:ember chrisdell$ time (find -L . -type f | wc -c); echo $?
 89110263

real    0m18.543s
user    0m1.889s
sys 0m13.489s
0
Chriss-MBP:ember chrisdell$ time (find -L . -type f | wc -l); echo $?
  860093

real    0m14.717s
user    0m1.503s
sys 0m11.950s
0
cjdell commented 8 years ago

@bpasero The Code Helper process taking 100% CPU is now the watcherService. So it isn't just the searchService.

bpasero commented 8 years ago

@cjdell then it could be https://github.com/Microsoft/vscode/issues/3998

cjdell commented 8 years ago

@bpasero Thanks, I've added the files.watcherExclude setting, I was previously unaware of this. It appears to have made a difference. The Code Helper now settles down a few minutes after spooling up. This maybe the best solution (for now) for anyone experiencing this problem. I can see this was mentioned in the release notes a while ago but it appears many people still aren't aware of it.

cjdell commented 8 years ago

Whilst the Code Helper isn't hogging the CPU anymore. Still occasionally seeing 10+ find processes suddenly appear when I do a file search within Code. They will hog the CPU for a few minutes then die. The processes have this line: find -L . -type f

chrmarti commented 8 years ago

@cjdell We are using find for speeding up the file search in the file opener (Cmd+P). There is a performance regression with that in 1.5.2 when there are large excluded folders which is fixed with #11874 in the 'insiders' build.

cjdell commented 8 years ago

@chrmarti Just trying the insiders build now. Still has the nasty find bug I'm afraid. I can easily replicate it by using the file opener (Cmd+P) and just constantly typing characters. It's like it's launching find processes for every key press! It will bring my system to its knees very quickly (stuttering mouse cursor). Clearly there needs to be a lock or debounce put in somewhere :-)

chrmarti commented 8 years ago

@cjdell That's an interesting data point, I haven't been able to reproduce that. Could you share your user and workspace settings with us?

cjdell commented 8 years ago

@chrmarti I'm on entirely default settings apart my excludes:

{
  "files.exclude": {
    "**/tmp/**": true,
    "**/node_modules/**": true,
    "**/bower_components/**": true
  },
  "files.watcherExclude": {
    "**/tmp/**": true,
    "**/node_modules/**": true,
    "**/bower_components/**": true
  }
}

My project is pretty large though (not enormous) so I'm sure that's a contributing factor. I posted the stats earlier on this issue. It's an Ember project that I'm working on.

chrmarti commented 8 years ago

@cjdell You might hit a limitation of our glob optimizations. Could you remove the trailing '/**' from the files.exclude patterns and retry? That should make my fix from yesterday actually work.

cjdell commented 8 years ago

@chrmarti Changed to this:

{
  "files.exclude": {
    "tmp/**": true,
    "node_modules/**": true,
    "bower_components/**": true
  },
  "files.watcherExclude": {
    "tmp/**": true,
    "node_modules/**": true,
    "bower_components/**": true
  }
}

I can see find is being optimised now:

find -L . -not ( ( -name .git -o -name .svn -o -name .hg -o -name .DS_Store -o -name node_modules -o -name bower_components ) -prune ) -type f

It's excluding what I told it to apart from tmp for some reason.

chrmarti commented 8 years ago

@cjdell I meant to say:

{
  "files.exclude": {
    "**/tmp": true,
    "**/node_modules": true,
    "**/bower_components": true
  },
  "files.watcherExclude": {
    "**/tmp/**": true,
    "**/node_modules/**": true,
    "**/bower_components/**": true
  }
}

We should make this automatically, but it would be great to understand if this helps in your case.

cjdell commented 8 years ago

@chrmarti My bad, you did trailing :-) That has made a massive difference. It's soooo much faster. Thanks for helping me with this!

chrmarti commented 8 years ago

@cjdell Thanks for helping with tracking this down!

Others: Let us know if you get a chance to try the insiders build and if that fixes the issue you see.

jameslaneconkling commented 8 years ago

the fix on Insider works for me. thanks!

pitAlex commented 8 years ago

Guys it looks like it stopped happening for me after adding "files.watcherExclude" with the same paths set to "files.exclude". But shouldn't setting "files.exclude" automatically make the watcher also exclude those paths/files?

pitAlex commented 8 years ago

It happen again to me, this is what was logged in the "Opened files and ports" tab:

/ /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework /Applications/Visual Studio Code.app/Contents/Frameworks/Squirrel.framework/Versions/A/Squirrel /Applications/Visual Studio Code.app/Contents/Frameworks/ReactiveCocoa.framework/Versions/A/ReactiveCocoa /Applications/Visual Studio Code.app/Contents/Frameworks/Mantle.framework/Versions/A/Mantle /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libnode.dylib /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI /usr/lib/libexpat.1.dylib /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/snapshot_blob.bin /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/natives_blob.bin /usr/share/icu/icudt55l.dat /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/icudtl.dat /usr/lib/dyld /private/var/db/dyld/dyld_shared_cache_x86_64h /dev/null /dev/null /dev/null ->(none) count=2, state=0x12 /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/icudtl.dat ->0x87230fe14c9f00ab ->0x87230fe1579d076b count=1, state=0x8 ->0x87230fe1579d06ab ->0x87230fe1579d1f6b ->0x87230fe1579d052b ->0x87230fe1579d202b /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/icudtl.dat /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/snapshot_blob.bin /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/natives_blob.bin /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/en.lproj/locale.pak /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/content_shell.pak /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/snapshot_blob.bin ->0x87230fe14c9f02eb ->0x87230fe1579d082b ->(none) /dev/urandom ->0x87230fe157ae233b /Applications/Visual Studio Code.app/Contents/Resources/electron.asar /Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/natives_blob.bin /dev/urandom /dev/null ->0x87230fe147336eeb /var/folders/p1/kjsc4k4x2klcmnwdl6cs62yc0000gn/T/vscode-acd5c7b0e7bca56473b136169ecfae6f96390c5c.sock ->0x87230fe157ae0c93 /var/folders/p1/kjsc4k4x2klcmnwdl6cs62yc0000gn/T/vscode-765d96c7193cf6e96297bfdee6a309b5e72cd811.sock ->0x87230fe157ae07e3 /var/folders/p1/kjsc4k4x2klcmnwdl6cs62yc0000gn/T/vscode-9ed9b7650ac59680318e751268f60fee43a682f6.sock ->0x87230fe157ae0333 ->0x87230fe157ae00db ->0x87230fe157ae2593 /var/folders/p1/kjsc4k4x2klcmnwdl6cs62yc0000gn/T/vscode-acd5c7b0e7bca56473b136169ecfae6f96390c5c.sock ->0x87230fe157ae2723 ->0x87230fe15b431aa3 ->0x87230fe157ae28b3 /var/folders/p1/kjsc4k4x2klcmnwdl6cs62yc0000gn/T/vscode-9ed9b7650ac59680318e751268f60fee43a682f6.sock ->0x87230fe157ae2a43 /var/folders/p1/kjsc4k4x2klcmnwdl6cs62yc0000gn/T/vscode-765d96c7193cf6e96297bfdee6a309b5e72cd811.sock ->0x87230fe15b431c33

chrmarti commented 8 years ago

@pitAlex Could you do a ps -p <pid> for the pid that uses much CPU time and post the output here?

pitAlex commented 8 years ago

Here it is

3397 100.0 0.3 3231528 54680 ?? R 9:27PM 32:27.95 /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=extensionHost

chrmarti commented 8 years ago

@pitAlex Looks like one of the extensions you have installed is quite busy. Any idea which one it might be? (Could also be one of the built-in ones.)

pitAlex commented 8 years ago

I don't think the extensions I've installed are causing problems. All I have is:

https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave https://marketplace.visualstudio.com/items?itemName=ecmel.vscode-html-css https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag

How can I find out which extension has issues?

chrmarti commented 8 years ago

The extension host using a lot of CPU was previously reported as #10439. We'll keep tracking that there. I'm closing this one as a duplicate of #11874 since that appears to have fixed all the reported cases of the search process running high on CPU.

dannylevenson commented 7 years ago

I've been seeing this problem lately too. The most recent instance is with this process:

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/danny/Library/Caches/typescript --enableTelemetry

Sometimes it's a different one, but this seems to be the most usual culprit.

dannylevenson commented 7 years ago

This morning, I have two processes each consuming 99-100% of a core. Both have these details:

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/out/utils/electronForkStart /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/node_modules/typescript/lib/tsserver.js --useSingleInferredProject --enableTelemetry

dannylevenson commented 7 years ago

Today, I have these two processes. The first is running the CPU at about 125% (didn't think that was possible). The second is keeping the CPU around 90%:

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/danny/Library/Caches/typescript --enableTelemetry

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/out/utils/electronForkStart /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/node_modules/typescript/lib/tsserver.js --useSingleInferredProject --enableTelemetry

Is anybody still looking at these problems? I might have to consider going back to Sublime Text or giving Atom a try if code keeps pegging my CPUs.

safphoto commented 7 years ago

I experience this same issue with SublimeText and Atom as well on my MacBook Pro.

equinusocio commented 7 years ago

Same issue here

narkowicz commented 7 years ago

x2 Code Helper processes running at 99-100% which in this instance have remained active after quitting VSCode v 1.10.1

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/out/utils/electronForkStart Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/node_modules/typescript/lib/tsserver.js --useSingleInferredProject --enableTelemetry

/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/out/utils/electronForkStart Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript/node_modules/typescript/lib/tsserver.js --useSingleInferredProject --enableTelemetry

jag1989 commented 7 years ago

I've also been seeing very high CPU usage from Code Helper.

screen shot 2017-03-20 at 11 49 18
jag1989 commented 7 years ago

PID 80788: /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=extensionHost

chrmarti commented 7 years ago

@jag1989 That is very likely caused by one of the extensions you have installed. Could you post the output of code --list-extensions and try to disable (or uninstall) the extensions one-by-one to figure out which one causes it? Please then file a bug report with that extension so its authors can investigate.

jag1989 commented 7 years ago

@chrmarti here is the output (I'll report back after I've disabled some and see if I can find the cause)

svodnik commented 7 years ago

Just had this happen for the first time. Of the extensions listed by @jag1989, I have only 2 in common:

Also, in case it helps with debugging, all of my extensions stopped working around the time the Code Helper process started consuming a lot of CPU.

jag1989 commented 7 years ago

@svodnik I've removed ~10 extensions and I'm no longer seeing the issue.

I am indeed still running without issue.

This is a list of removed extensions

dizney commented 7 years ago

I had the same issue, two Codehelper processes at 100%:

/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=extensionHost

I remembered i had installed the ryu1kn.annotator extension installed last, and when i removed that it seems to have stopped the high cpu processes.

AriTheElk commented 7 years ago

Had the same problem

/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=extensionHost

I quit vscode, and the helper is still running at 100% cpu usage. Only way to stop it was to kill the code helper from activity monitor.

chrmarti commented 7 years ago

@garetmckinley Does this also happen when you start with code --disable-extensions?

AriTheElk commented 7 years ago

I'm not sure, since I'm not sure exactly when it happens. It doesn't happen immediately after starting it up, I only notice it after a few hours of working in it. I can try working a full day with no extensions to see if it resolves it. If it matters, this is while working with a fairly large codebase.

equinusocio commented 7 years ago

had same problem after restoring from a sleep session with vsc running.

Il mar 18 apr 2017, 18:26 Garet McKinley notifications@github.com ha scritto:

I'm not sure, since I'm not sure exactly when it happens. It doesn't happen immediately after starting it up, I only notice it after a few hours of working in it. I can try working a full day with no extensions to see if it resolves it. If it matters, this is while working with a fairly large codebase.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode/issues/11963#issuecomment-294900185, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ-G1UKviiijstoFjxaWVqzOCi47LC_Bks5rxOROgaJpZM4J7vVf .

AriTheElk commented 7 years ago

Is there a way to view individual extension's processes in vscode? It would be super helpful if we could monitor which (if any) extensions are using an unusually high amount of cpu.