Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage from node.mojom.NodeService #213136

Open
petoknm opened this issue May 21, 2024 · 26 comments
Open

High CPU usage from node.mojom.NodeService #213136

petoknm opened this issue May 21, 2024 · 26 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@petoknm
Copy link

petoknm commented May 21, 2024

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 (dc96b83, 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);
Extensions: none
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

@tomaszkapron
Copy link

Having similar issues

@javierjcf
Copy link

Same here

@VSCodeTriageBot VSCodeTriageBot added the stale Issues that have not been triaged in an appropriate amount of time label May 29, 2024
@edithli
Copy link

edithli commented May 30, 2024

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)

image

image

@Tyriar Tyriar assigned deepak1556 and unassigned Tyriar and connor4312 May 30, 2024
@VSCodeTriageBot VSCodeTriageBot removed triage-needed stale Issues that have not been triaged in an appropriate amount of time labels May 30, 2024
@deepak1556
Copy link
Contributor

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.

@deepak1556 deepak1556 added the info-needed Issue requires more information from poster label May 31, 2024
@jvinolas
Copy link

jvinolas commented Jun 3, 2024

Bug also reproduced. It happens to me a the paste from clipboard action, sometimes.

Version: 1.89.1
Commit: dc96b83
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

@xrstf
Copy link

xrstf commented Jun 6, 2024

Same here.

Version: 1.89.1
Commit: dc96b83
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

@petoknm
Copy link
Author

petoknm commented Jun 7, 2024

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 #213136 (comment) instead of just commenting that it happens. We need to give the team more data to debug this issue. Thank you.

@xrstf
Copy link

xrstf commented Jun 11, 2024

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.

@Geczy
Copy link

Geczy commented Jun 13, 2024

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

@petoknm
Copy link
Author

petoknm commented Jun 14, 2024

Please profile according to #213136 (comment)

@Geczy
Copy link

Geczy commented Jun 18, 2024

@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

@petoknm
Copy link
Author

petoknm commented Jun 18, 2024

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)

@Geczy
Copy link

Geczy commented Jun 18, 2024

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:
#213136 (comment)

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

@fuunnx
Copy link

fuunnx commented Jun 20, 2024

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 :

mojom-CPU-20240620T100137.cpuprofile

@3ng7n33r
Copy link

3ng7n33r commented Jun 21, 2024

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.

@ravm

This comment was marked as resolved.

@javierjcf
Copy link

I uninstall gitlens extension. I have long projects with a lot of git repositories inside. gitlens eatc my cpu and ram

@l-miskovsky
Copy link

l-miskovsky commented Jul 30, 2024

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: f1e16e1
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

@petoknm
Copy link
Author

petoknm commented Aug 8, 2024

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 (b1c0a14, 2024-07-31T23:26:45.634Z)
OS version: Linux x64 5.15.0-117-generic snap

@Geczy
Copy link

Geczy commented Aug 8, 2024

@petoknm try disabling extension ms-vscode-remote.remote-containers and run a profile again

@petoknm
Copy link
Author

petoknm commented Aug 8, 2024

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...

@petoknm
Copy link
Author

petoknm commented Aug 8, 2024

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

@petoknm
Copy link
Author

petoknm commented Aug 8, 2024

$ 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:
image

@macksal
Copy link

macksal commented Aug 9, 2024

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.

@aatkin
Copy link

aatkin commented Aug 9, 2024

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.

@petoknm
Copy link
Author

petoknm commented Aug 13, 2024

@deepak1556 let me know if you need any more information, otherwise I believe the label "info-needed" can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests