Vscode: Code Helper using almost 100% CPU

Created on 24 Jul 2017  路  29Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.14.2
  • OS Version: macOS Sierra 10.12.6

I touched my mac and I felt it's hot, checked "Activity Monitor" and I saw "Code Helper" was using a lot of CPU (almost 100%). I was using only 1 window. I even killed process and closed VSC, but it was the same. I can close it, kill process and when I open VSC "Code Helper" again will take almost 100% CPU. After start it reaches about 180% CPU and it drops to ~100%.

As I tested, if you open VSC and you don't focus on it everything is OK. But if you open it and you press mouse click on VSC "Code Helper" goes crazy.

I can cook eggs on my mac 馃槃

Extensions:

  • PeterJausovec.vscode-docker
  • arcticicestudio.nord-visual-studio-code
  • dbaeumer.vscode-eslint
  • esbenp.prettier-vscode
  • formulahendry.auto-close-tag
  • formulahendry.auto-rename-tag
  • formulahendry.code-runner
  • joelday.docthis
  • msjsdiag.debugger-for-chrome
  • robertohuertasm.vscode-icons
  • xabikos.JavaScriptSnippets
  • ziyasal.vscode-open-in-github

I tried with and without extensions and it was the same!

7d48_main.cpuprofile.txt
7d48_renderer.cpuprofile.txt

file-watcher needs more info

Most helpful comment

@bpasero @Tyriar I know how to fix it. You need to add folders to the files.watcherExclude or/and enable files.useExperimentalFileWatcher.

EDIT: Seems I need only enable the files.useExperimentalFileWatcher.

All 29 comments

I restarted mac, but it's the same...

Can you please get the full command line arguments of the code helper process by running:

ps aux | grep PID_FROM_ACTIVITY_MONITOR

in the terminal

@mjbvz Right now everything seems okey. I don't know why, but Code Helper isn't using a lot of CPU. When it will be same again I will post it.

@mjbvz Tested, same happens on Insiders.

image

bsvipas 17424 100.0 3.5 3807600 594064 ?? R 3:03PM 2:10.98 /Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper.app/Contents/MacOS/Code - Insiders Helper /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/bootstrap --type=watcherService

@Tyriar Assigning you since I remember you mentioned working the watcher service at one point

@bsvipas Does this happen for any folder you open or just one specifically? Make sure to manually kill the high cpu code helper process before trying to open a new folder

Looks like it's the old watcher service.

@mjbvz I don't know, I tried only on one folder. I killed it I even restarted the mac and it was the same. Right now I'm not using VS Code, because I can't, I'm afraid my mac will burn since I'm programming a lot of time.

Cleaned everything, installed new VS Code and it was the same. Without extensions, default settings, etc.

Right now Code Helper process CPU dropped. I think it happens randomly, I don't know how produce it.

This issue has been ongoing for me with both standard and Insider builds, with or without plugins. I filed a ticket against the Insider build a couple of weeks back including a process sample. I'm happy to do that again if need be. Sadly, I'm not able to run Code with this issue still present, as the impact on battery life is too great. My typical workspaces are 1) a folder containing a dozen small to medium-sized git repos 2) a large git repo with submodules 3) An assortment of random smallish git repos, one per window. One thing I have observed (which may be of no consequence) is that closing one window almost always resolves the issue temporarily, regardless of which window/workspace I close. If I limit myself to a single window, I don't have the issue at all (so far - I wouldn't swear to it) . I hope this is helpful in some way.

Cheers

@hatrabbit could you try adding this setting?

"files.useExperimentalFileWatcher": true

@Tyriar Trying it now.

@Tyriar Sorry, no change. I did restart Code after I added the setting. I'm hovering at ~70%cpu with 3 workspaces open.

@hatrabbit did you do a full restart via cmd+q or File > Exit? Approximately how many files are in the workspaces?

@Tyriar Yes, I did. And my current workspaces have ~3300 and ~19600 files, but I've had the same issue with some that had as few as 200-300 files.

@bpasero any ideas?

Any news on this? Because sometimes everything is good and sometimes it feels my mac will burn...

This is the same issue as has been reported before and closed due to alledged lack of information (#24713). It's always on large repositories, where it needs to watch a helluva lotta files; it's a cross-platform issue too (Linux and Mac at least it seems, across many versions, reported against 1.13.1 through to 1.14.2 and may affect versions prior to that even).

@richardj-bsquare I respectfully disagree for the following reasons:
1) It's a new behavior - I used Code for a good year without seeing this kind of CPU usage. It would have been a deal breaker on day one.
2) The issue seems to crop up far more often with multiple windows/workspaces open. If I open my ~large repos in the same workspace by opening the parent folder, I have no such problem.
3) I can reproduce the problem with small repositories (<300 files)

It's also worth saying I wouldn't report this if I didn't really love VS Code. It's freaking great.

Thanks

I think it was caused by files in node_modules folder. If you delete node_modules , all will be ok.
I have exclude this folder in settings, but it is not work. Any plugin(Or vscode self) will index this folder automatically?
image

@bsvipas which folder are you opening with VS Code, is it a very large folder?

This issue has been closed automatically because it needs more information and has not had recent activity. Please refer to our guidelines for filing issues. Thank you for your contributions.

@bpasero @Tyriar Yes it's large project with a lot of node_modules and bower_components. This issue is still in 1.5 version. If I open small project Code Helper reduces usage till normal, but if I open large project it increases CPU/memory usage.

@bpasero @Tyriar I know how to fix it. You need to add folders to the files.watcherExclude or/and enable files.useExperimentalFileWatcher.

EDIT: Seems I need only enable the files.useExperimentalFileWatcher.

@bsvipas that's good news, the old file watcher will eventually be deprecated/removed in favor of the experimental one, also files.watcherExclude is provided to work around these sorts of performance problems if you don't need to watch a big portion of the files. I think we can leave this closed. 馃憤

@bsvipas Manually exclude node_modules in files.watcherExclude works for me(OSX energy cost from hundreds down to 30). Only enable files.useExperimentalFileWatcher seems nothing changed. 馃槀

@lcx-seima For me files.watcherExclude works really good, but I also exclude some folders just in case.

Using 1.16.1. Still with the same problem.

Modified files.watcherExclude and enabled files.useExperimentalFileWatcher. CPU at constant 25% and 2GB of RAM.

It is unusable.

@jmaister I'm using project with a lot of modules, files and so on and everything is fine for me. Maybe you configured badly files.watcherExclude. Also remember do the same for search.exclude.

This is what worked for me - update the user settings of VSCode-

"files.useExperimentalFileWatcher": true,
"files.exclude": {
"/.git": true,
"
/.DS_Store": true,
"/node_modules": true,
"
/node_modules/": true
},
"search.exclude": {
"
/node_modules": true
},
"files.watcherExclude": {
"/node_modules/": true
},

After above update, restart VSCode, then CPU usage went back to normal:)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

villiv picture villiv  路  3Comments

curtw picture curtw  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

trstringer picture trstringer  路  3Comments

biij5698 picture biij5698  路  3Comments