microsoft / vscode

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

Excessive CPU usage while Idling #195487

Closed dani0332 closed 11 months ago

dani0332 commented 1 year ago

Type: Performance Issue

My VS-code suddenly started using too much CPU from few days.

I looked up the internet and it said an extension might be doing that, so I un-installed all the extensions infact, I re-installed the new VS-code but issue remain still presist

I did some digging and it seems like that when I open my .md file (just single file WO any extensions) the CPU usage spikes. And, it remain so even after I close the file & VS-code as well. I had to use killall code to bring the CPU down.

I also ran code --status it shows below

CPU % Mem MB PID Process
12 63 172313 electron-nodejs (/usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/markdown-language-features/server/dist/node/workerMain --node-ipc --clientProcessId=172267)

VS Code version: Code 1.83.1 (f1b07bd25dfad64b0167beb15359ae573aecd2cc, 2023-10-10T23:45:31.402Z) OS version: Linux x64 5.15.0-86-generic Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (8 x 2400)| |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
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 1, 1| |Memory (System)|15.32GB (4.78GB free)| |Process Argv|--unity-launch --crash-reporter-id 670ec1d3-c3be-438a-8764-4b26a3f245d6| |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 157 173907 code main 0 31 173912 zygote 0 110 173945 gpu-process 0 31 173913 zygote 0 0 173915 zygote 0 188 173973 window [1] (Notes - Visual Studio Code) 0 94 175129 window [2] (Issue Reporter) 0 47 173950 utility-network-service 0 110 174198 extensionHost [1] 12 63 174918 electron-nodejs (/usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/markdown-language-features/server/dist/node/workerMain --node-ipc --clientProcessId=174198) 0 78 174208 shared-process 0 0 175147 /bin/sh -c /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 0 175148 /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 63 174209 fileWatcher [1] ```
Workspace Info ``` | Window (Notes - Visual Studio Code) | Folder (Notes): 11 files | File types: md(4) txt(4) json(2) php(1) | Conf files:; ```

Extensions: none

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30856252
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
282f8724:30602487
89544117:30613380
2i9eh265:30646982
showlangstatbar:30737416
0bi6i642:30841073
a2ce3375:30757347
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
copilotsettingc:30839828
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
pythonmpsinfo:30842941
dsvsc015:30845448

mjbvz commented 1 year ago

Can you share an example project which causes this issue

dani0332 commented 1 year ago

In my case, I actually don't use VS-code for project but rather for to edit/manage file formats like md, txt, sql & json.

Among them, like I said when I open my .md file the CPU spikes up & never goes down. (see image)

image

PeepoFrog commented 1 year ago

same issue PopOS 22.04 vscode 1.83 even after closing vscode this process still running in background and using 100% of 1 cpu after opening vscode again it creates new instance of this process that using another core for 100% need to kill those processes manually

same problem on windows

mjbvz commented 1 year ago

@dani0332 Please share some example code which demonstrates the issue so we can investigate

tamuratak commented 1 year ago

@mjbvz See https://github.com/microsoft/vscode/issues/195756#issuecomment-1767608848

Experiencing a similar issue as issue 2 with markdown file that contains

# symbol
[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Originally posted by @penghiang in https://github.com/microsoft/vscode/issues/195756#issuecomment-1767608848

I can reproduce the issue with:

Version: 1.84.0-insider Commit: f1c3b1dcf85e3b6ddb24b7dce0e4b122e8ce6233 Date: 2023-10-17T05:38:23.658Z Electron: 25.8.4 ElectronBuildId: 24154031 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin x64 22.6.0

dani0332 commented 1 year ago

@mjbvz Though, I have mentioned that any markdown file causes this issue. But if you still want the example markdown file, find the attached file. Hopefully that'll suffice

frequent-use-copy.md

OblackatO commented 12 months ago

I have the same problem as @dani0332, using the same OS (Ubuntu).

Like @dani0332 mentioned:

amar-0 commented 11 months ago

I have the same problem as @dani0332, using the same OS (Ubuntu).

Like @dani0332 mentioned:

* Not using any extension at all doesn't solve the problem.

* If visual studio code interface is killed, the process continues to run.

Exactly the same issue my side. Not sure what triggers it.

dkzsys commented 11 months ago

Similar issue here @ https://github.com/microsoft/vscode/issues/195756

My workaround is to downgrade to v1.80.0.

mjbvz commented 11 months ago

Thank you for the repo @tamuratak!

This was caused by a catastrophic backtracking in a regular expression. I believe it should by fixed by https://github.com/microsoft/vscode-markdown-languageservice/pull/157 which will be in the first 1.85 insiders builds once those come out later this week

Let me know if you still see this issue in VS Code 1.85+

marksowell commented 11 months ago

Downgrading from 1.84.2 to 1.82.3 resolved issue on macOS 14.1.1