vscode
vscode copied to clipboard
High CPU usage from node.mojom.NodeService
Type: Performance Issue
This specific process always takes 100% CPU on machine:
/snap/code/159/usr/share/code/code --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=860961 --enable-crash-reporter=f5630c5d-bec1-43e9-95d6-21d878227126,no_channel --user-data-dir=/home/pmajchrak/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,4729389318826606528,17009332704461783735,262144 --enable-features=kWebSQLAccess --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --variations-seed-version
I looked at the different ways to profile VSCode, but they didn't show this process, so it all looked normal. Even JS profiling doesn't capture this. This process still exists even if I run VSCode with disabled extensions and the process respawns after being killed.
VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:16:23.416Z) OS version: Linux x64 5.15.0-105-generic snap Modes:
System Info
| Item | Value |
|---|---|
| CPUs | AMD Ryzen 9 5950X 16-Core Processor (32 x 4464) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off |
| Load (avg) | 2, 2, 2 |
| Memory (System) | 62.70GB (52.78GB free) |
| Process Argv | --no-sandbox --force-user-env --crash-reporter-id 18e3b18c-bfb2-4aff-9683-a7fc868c85da |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | ubuntu |
| XDG_CURRENT_DESKTOP | Unity |
| XDG_SESSION_DESKTOP | ubuntu |
| XDG_SESSION_TYPE | x11 |
Process Info
CPU % Mem MB PID Process
0 128 860943 code main
0 0 860945 zygote
0 0 860946 zygote
0 193 860993 window [1] (test - Visual Studio Code)
0 321 876526 window
0 0 876605 utility-process
0 64 876682 window [3] (Issue Reporter)
0 257 860973 gpu-process
0 64 860980 utility-network-service
0 64 861272 shared-process
0 0 876715 /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
0 64 861323 ptyHost
3 2183 874163 fileWatcher [1]
0 64 874175 extensionHost [1]
Workspace Info
| Window (test - Visual Studio Code)
| Folder (test): more than 24175 files
| File types: siginfo(4707) ipk(2493) zst(2272) pyc(1408) py(1405)
| pyi(557) json(382) so(226) html(118) test(71)
| Conf files: makefile(3) settings.json(2) dockerfile(2);
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
tftest:31042121
vswsl492cf:30256860
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
chatpanelc:31048052
dsvsc021:30996838
f3je6385:31013174
pythoncenvpt:31049070
a69g1124:31046351
pythonprt:31047983
dwnewjupytercf:31046870
fa862199:31048878
Having similar issues
Same here
similar issues here on Mac
/private/var/folders/rd/pts24m5j6x35m7ytf_q60yn80000gn/T/AppTranslocation/A5742310-7FCA-4A76-9CE4-CA349B49206B/d/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --dns-result-order=ipv4first --inspect-port=0 --user-data-dir=/Users/lss/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files --field-trial-handle=1718379636,r,11998688379030772291,12062321241314744751,262144 --enable-features=kWebSQLAccess --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --variations-seed-version
vs code version:
Version: 1.88.0 (Universal)
Commit: 5c3e652f63e798a5ac2f31ffd0d863669328dc4c
Date: 2024-04-03T13:28:18.899Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0
system info
macOS Sonoma Version 14.4.1 (23E224)
That would be the extension host process, disable extensions will only have effect on installed extensions, builtin ones will be run and seems like an issue from one of them. Please use the following steps to capture a cpu profile of the process,
* Launch vscode like `code --inspect-extensions=9229`
* In chrome browser visit chrome://inspect/ or in edge browser visit edge://inspect
* You should see an entry under Remote Target
* If you don't see the above entry, then
* Under Devices, click open dedicated devtools for node
* Under Connection tab, add localhost:9229
* You should now see the target
* If there are multiple targets pick the one that matches the PID of the process showing high cpu
* Click inspect
* Go to Profiler tab and start the CPU profiler
* Stop the profiler after a few seconds and attach it to this issue.
Bug also reproduced. It happens to me a the paste from clipboard action, sometimes.
Version: 1.89.1 Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:16:23.416Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.8.0-31-generic
Same here.
Version: 1.89.1 Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:16:23.416Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.1.0-21-amd64
The issue stopped happening on my machine, at least for now, so I can't perform the extra profiling at the moment. However, I would really appreciate if people who do experience this issue, performed the profiling according to comment https://github.com/microsoft/vscode/issues/213136#issuecomment-2141179362 instead of just commenting that it happens. We need to give the team more data to debug this issue. Thank you.
Updating to 1.90.1 did not solve the issue. The moment I have a workspace open, the file watcher process continues to use 100% of one CPU core.
have the same issue, did not see anything in vscode process explorer showing an extension that was using high cpu. it just said extension host was high
mgates 94478 138.3 0.1 1594142160 52704 ?? R 5Jun24 8461:12.92 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --dns-result-order=ipv4first --inspect-port=0 --user-data-dir=/Users/mgates/Library/Application Support/Code --standard-schemes=vscode-webview,vscode-file --enable-sandbox --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files --field-trial-handle=1718379636,r,7905944025835438358,16796389049385230011,262144 --enable-features=kWebSQLAccess --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --variations-seed-version
Please profile according to https://github.com/microsoft/vscode/issues/213136#issuecomment-2141179362
@petoknm there is no profiler, but there is a "performance" tab that i can record with. let me know if i did it right. i can try again
200%+ cpu usage @deepak1556
CPU-20240618T061059.cpuprofile
another CPU-20240618T061552.cpuprofile
saw an extension be mentioned in that last one, so i uninstalled live share and live preview extensions here's two new profiles, each a few seconds long CPU-20240618T062133.cpuprofile CPU-20240618T062130.cpuprofile
Thank you @Geczy . I can confirm I am able to open the cpuprofile and see the recording.
I see a lot of callbackTrampoline calls, which suggests async work. Some of the higher CPU usage sections have a lot of readdir calls.
So to me it looks like VSCode is scanning (probably) the project files and therefore this issue could be caused by opening large projects? The project that was causing issues for was indeed quite large (multiple git submodules)
looking at bottom-up i saw more referencing kevinmcgowan.TypeScriptImport so i uninstalled this extension as well. seems like this was the culprit, because I no longer see high CPU usage. the bottom up calls were garbage collecting and globbing and readdir, lke you said
https://marketplace.visualstudio.com/items?itemName=kevinmcgowan.TypeScriptImport
they even have a high cpu issue: https://github.com/microsoft/vscode/issues/213136#issuecomment-2175966016
and this extension hasn't been touched in 7 years
i'm going to consider this solved for me ! thanks for the inspection help
will come back if i notice usage is super high again
Same story here, but different extension. vscode-gitblame is the culprit.
There is a lot of calls to async_hooks that causes a lot of computation (with registerDestroyHook). I guess those extensions were developed in a time before async_hooks were introduced. But now, async_hooks add a lot of overhead.
Here is the CPU profile for the curious :
Same problem here since my last VSCode update to version 1.90.2.
The culprit seems to be the dev-container extension for me. In addition to the CPU load, it also blocks a port that my application needs to function.
Killing the process unblocks the port and makes everything run smooth again until I restart the dev-container. After I kill it, VSCode presents me with an error message:
A shared background process terminated unexpectedly. Please restart the application to recover.
which can be ignored for now as vscode and the container seem to work completely fine.
Same issue here, except the CPU usage will stay at 100% unless I disable all extensions including VSCode's built-in extensions.
I uninstall gitlens extension. I have long projects with a lot of git repositories inside. gitlens eatc my cpu and ram
Edit: seems that in my case it was caused by NuclleaR.vscode-extension-auto-import
Same issue with monorepo lerna project here. Seems that it's triggered by some monorepo + watcher process combination but definitely looks like a VSCode bug. I have to kill the offending process after running a command that includes file watching (next dev), CPU goes back to normal and the process that started this issue keeps running normally.
Version: 1.91.1 Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:08:12.169Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.5.0-45-generic snap
Ok, I was finally able to repro this issue again, and I captured the CPU profile: CPU-20240808T144337.cpuprofile
In my case, I see it being mostly idle, but possibly doing some async stuff, not sure...
I see repeated calls to getConfiguration and createSocket but I have no idea where they are coming from.
VS Code version: Code 1.92.0 (b1c0a14de1414fcdaa400695b4db1c0799bc3124, 2024-07-31T23:26:45.634Z) OS version: Linux x64 5.15.0-117-generic snap
@petoknm try disabling extension ms-vscode-remote.remote-containers and run a profile again
I also see a lot of git errors in the extension host output:
2024-08-08 14:38:28.124 [error] Error: Git error
at ChildProcess.<anonymous> (/snap/code/165/usr/share/code/resources/app/extensions/git/dist/main.js:2:1030937)
at ChildProcess.emit (node:events:531:35)
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
2024-08-08 14:38:28.124 [error] Error: Git error
at ChildProcess.<anonymous> (/snap/code/165/usr/share/code/resources/app/extensions/git/dist/main.js:2:1030937)
at ChildProcess.emit (node:events:531:35)
at ChildProcess._handle.onexit (node:internal/child_process:294:12)
but it doesn't say what the error is, so I have no idea what is going on. But what made me notice the CPU issue was that all git operations through vscode were unusably slow, and I actually still can't commit through vscode... its just showing the little loading line that moves horizontally...
Another profile with remote-containers disabled: CPU-20240808T152153.cpuprofile
Looks totally idle to me from the profile, but top is showing CPU at 100 for process:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1997401 pmajchr+ 20 0 1131.9g 1.0g 70960 S 100.0 0.8 2:48.19 code
and thats the mojom.NodeService thing when I look at the commandline of that process:
$ cat /proc/1997401/cmdline
/snap/code/165/usr/share/code/code --type=utility --utility-sub-type=node.mojom.NodeService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=6034 --enable-crash-reporter=f5630c5d-bec1-43e9-95d6-21d878227126,no_channel --user-data-dir=/home/pmajchrak/.config/Code --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --code-cache-schemes=vscode-webview,vscode-file --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6766153925956273474,8395303390137290370,262144 --enable-features=kWebSQLAccess --disable-features=CalculateNativeWinOcclusion,SpareRendererForSitePerProcess --variations-seed-version
$ time git status
...
real 0m7.303s
user 0m1.669s
sys 0m46.423s
yea, its a large project, but via terminal I can still work with git fine... but through vscode it never shows me the "source control" stuff:
I found the same problem when an XCode build was much slower than usual on a new Macbook.
There were 4-5 VSCode processes each consuming 100-150% CPU: Code Helper, Code Helper (Plugin) etc.
Modern OSX seems to keep the UI more responsive when processes are hogging CPU, so I didn't notice until checking Activity Monitor.
I followed the steps here, disabled many extensions, no change. I then quit VSCode and discovered that the processes did not die, so they were actually zombified. Force quit, restart Code and performance is back to normal.
I also see a lot of git errors in the extension host output:
2024-08-08 14:38:28.124 [error] Error: Git error at ChildProcess.<anonymous> (/snap/code/165/usr/share/code/resources/app/extensions/git/dist/main.js:2:1030937) at ChildProcess.emit (node:events:531:35) at ChildProcess._handle.onexit (node:internal/child_process:294:12) 2024-08-08 14:38:28.124 [error] Error: Git error at ChildProcess.<anonymous> (/snap/code/165/usr/share/code/resources/app/extensions/git/dist/main.js:2:1030937) at ChildProcess.emit (node:events:531:35) at ChildProcess._handle.onexit (node:internal/child_process:294:12)but it doesn't say what the error is, so I have no idea what is going on. But what made me notice the CPU issue was that all git operations through vscode were unusably slow, and I actually still can't commit through vscode... its just showing the little loading line that moves horizontally...
I am also experiencing unusually high CPU usage on MBP 2019 (with Intel chip) related to VSCode git extension. I didn't pick what errors were happening, but profiling showed that the git extension was calling something very often (almost every 20ms or so). Once I turned git extension off in VSCode settings, all the extra CPU usage went down. When I tried turning it back on, CPU usage went back up immediately. I also restarted system multiple times before and after finding out about the profiling results. I'm quite convinced that my issue is related to the git extension, but I don't know what could be the root cause.
@deepak1556 let me know if you need any more information, otherwise I believe the label "info-needed" can be removed.
This is happening when the laptop goes into sleep mode and back out of it. The CPU spikes and stays at 100%. Very annoying issue. Burns through a battery.
Disabling GitLens and restarting vscode has solved it for me. Re-enabling GitLens instantly makes one process use 100% CPU again.
It seems that bad files or directories permissions in your project is the issue. Using chown and or chmod on filesystem let the service to parse the file.
Same story here, but different extension. vscode-gitblame is the culprit.
@fuunnx Hi, I've the same issue, in my case it happens on branch switching of a large python project. Have you found a better git blame extension ?