microsoft / vscode

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

VSCode becomes laggy after using it for some time (macOS Ventura) #165016

Open franktzheng opened 2 years ago

franktzheng commented 2 years ago

Type: Performance Issue

Hi! I upgraded to the macOS Ventura beta a few months ago (which was probably a mistake), and I've had problems with VSCode being laggy ever since. I primarily use VSCode to compile LaTeX, but I've run into this issue while using it with TypeScript before (so it doesn't seem to be related to a particular extension). The problem I'm experiencing is similar to what might happen if there is a memory leak. When I first open the app, everything is fine, and I experience no lag whatsoever. However, after writing code for maybe 15-30 minutes, I typing and highlighting code becomes pretty laggy. If I restart the application (quit and reopen), things return to normal. I'm sorry I can't provide much more information, and I doubt I'd be able to reproduce this problem on someone else's computer.

VS Code version: Code 1.72.2 (d045a5eda657f4d7b676dedbfa7aab8207f8a075, 2022-10-12T22:16:30.254Z) OS version: Darwin x64 22.2.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (1.50GB free)| |Process Argv|--crash-reporter-id 919a54c2-c935-41b4-956b-39224562195e| |Screen Reader|no| |VM|0%|
Process Info ``` CPU % Mem MB PID Process 102 164 21312 code main 2 66 21316 gpu-process 0 16 21318 utility-network-service 0 295 21319 window (hw2.tex — math-215a) 0 98 21326 extensionHost 0 82 21337 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Users/frankzheng/.vscode/extensions/james-yu.latex-workshop-8.29.0/out/src/components/parser/syntax_worker.js 0 33 21338 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Users/frankzheng/.vscode/extensions/james-yu.latex-workshop-8.29.0/out/src/providers/preview/mathjaxpool_worker.js 0 115 21328 shared-process 0 33 21329 ptyHost 0 0 21349 /bin/zsh -il 0 33 21339 fileWatcher 0 0 29166 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 49 21342 window (undefined) 0 213 21345 window (undefined) 10 66 29163 issue-reporter ```
Workspace Info ``` | Window (hw2.tex — math-215a) | Folder (math-215a): 20 files | File types: aux(2) fdb_latexmk(2) fls(2) log(2) out(2) pdf(2) gz(2) | tex(2) sty(2) DS_Store(1) | Conf files:; ```
Extensions (15) Extension|Author (truncated)|Version ---|---|--- vsc-material-theme|Equ|33.5.0 vsc-material-theme-icons|equ|2.4.0 prettier-vscode|esb|9.9.0 reasonml|fre|1.0.38 latex-workshop|Jam|8.29.0 python|ms-|2022.16.1 vscode-pylance|ms-|2022.10.40 vscode-jupyter-cell-tags|ms-|0.1.6 vscode-jupyter-slideshow|ms-|0.1.5 remote-ssh|ms-|0.90.1 remote-ssh-edit|ms-|0.84.0 cpptools|ms-|1.12.4 material-icon-theme|PKi|4.21.0 intellicode-api-usage-examples|Vis|0.2.6 material-theme|zhu|3.15.6 (3 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 azure-dev_surveyone:30548225 pyindex848:30577860 nodejswelcome1cf:30587006 fc301958:30595537 2e4cg342:30596373 ```
JBarboss commented 7 months ago

Anyone found a solution for this?

RhetTbull commented 7 months ago

Anyone found a solution for this?

@JBarboss I've been trying to switch to zed editor. It is so much faster. There are many features I miss from VSCode and I still switch back and forth a bit but I'm trying to find a way to move off VSCode as it just becomes unusably slow in macOS.

JBarboss commented 7 months ago

@RhetTbull You're right. Thank you for the recommendation tho! I will give it a try. How are you managing your workflow switching between the two?

RhetTbull commented 7 months ago

@JBarboss I don't have much of a process other than "try to use Zed as much as possible". When I get stuck or frustrated, I open the same repo in VS Code but first try to find a solution in Zed. It's still a bit rough (especially with Python workflow which I use) but it is so fast and is continually improving.

kirilsvoloshins commented 7 months ago

Anyone found a solution for this?

zed or neovim, I guess

danLeBrown commented 6 months ago

Anyone found a solution for this?

@JBarboss I've been trying to switch to zed editor. It is so much faster. There are many features I miss from VSCode and I still switch back and forth a bit but I'm trying to find a way to move off VSCode as it just becomes unusably slow in macOS.

Oh my, @JBarboss! That makes two of us. I've been switching between Zed and Vs code since last week as well.

Also looking into Neovim, since Zed lacks a lot of features that make Vs Code enjoyable/intuitive to use.

bramiozo commented 6 months ago

Back to Jetbrains for me personally. In the mean time, I hope VSCode can get a "streamline" option to turn off EVERYTHING except the most basic code suggestions and syntax highlighting.

danLeBrown commented 6 months ago

@bramiozo, try using the bisect extension. It turns off all your extensions to find the culprit. There's a YT video that explains how to get started with it

rzhao271 commented 6 months ago

Hi all, to help us have a better understanding of the issue,

  1. Run the workbench.action.openProcessExplorer command to show the process explorer. Are there any processes that take up a lot of CPU or Memory?
  2. Does extension bisect identify any slow extensions?
enginocal commented 6 months ago

Thanks @danLeBrown, bisect solved my performance problem.

phamvant commented 5 months ago

I'm using Brave Browser and every time VSCode feel laggy then my localhost page also frozen. I wonder if it's also browser problem

blagoySimandov commented 5 months ago

I've been having this exact problem for a few weeks. VSCode becomes laggy and the CPU usage jumps up to 90/95 % after a few hours of work.

szagi3891 commented 5 months ago

I, on the other hand, have a problem switching tabs. If I switch tabs with the mouse, the response time is more than a second. if I use the keyboard to switch the active tab, the tab switches instantly. Very strangely in my case VSC behaves

szagi3891 commented 5 months ago

I just upgraded my macos system to version 13.6.7 and VSC started working like gold.

AzizOzenir commented 4 months ago

Increasing VS Code's Memory Limit fixed for me "typescript.tsserver.maxTsServerMemory": 5120,
"typescript.tsserver.nodePath": "/path/to/your/node"

wuguishifu commented 3 months ago

This is still happening to me even after trying all the solutions in this thread. In fact, VS Code becomes so slow that it's actually slower than just using Webstorm or IntelliJ. I've checked all my plugins, and I have nothing that should be causing VS Code to be slower than an actual IDE.

jessicagohh commented 3 months ago

VS Code gets so slow for me that I can barely scroll on files. I don't have the same issue on other open windows and tabs, just VS Code and Chrome-with-video-call. Some details that I think may have an impact?

  1. The Battery menu always describes VS Code as "Using Significant Energy".
  2. I'm on M3 Pro Sonoma.
  3. The lag disappears when I'm not connected to my Dell D6000 DisplayLink dock.
  4. The lag is still there even when only 1 external monitor is connected to the D6000.
  5. I have the Snowflake official extension on VS Code on this laptop.
  6. I never had this lag issue with my M2 Pro Sonoma Mac, even when connected to the D6000 + 3 external monitors, but without the Snowflake extension.
PrajwalCRao commented 2 months ago

@jessicagohh I have a similar configuration which exhibited the same symptoms. Setting my 144 Hz capable external monitors to 60Hz resolved the issue for me.

Artin-GH commented 2 months ago

Opening using the command code --disable-gpu solves for me. Running in M1 Macbook Air 2019. Macos Sonoma. code --version:

1.92.2
fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
arm64

Secondly, in my case the problem is there since I open it and not after minutes of working as some of you said. VSCode is so laggy when I'm scrolling anywhere in the app and a process named Code Helper is using about 50 percent cpu and 400MB memory

Jervx commented 2 months ago

Damn, I disabled almost every extension I have, but still even writing classes in className in tsx react lags too much 😞, I even disable the suggestions but still no effect. the lightweight IDE we loved before was gone. Gonna go back with nvim or zed. I'll be back if this problem is fixed.

ExLineP commented 2 months ago

Same issue, after stopping every CodeHelper (with 40% CPU utilization) from the system and running VSCode again fixes the issue but don't know how long will it last.

ZohaibAfridi565 commented 1 month ago

I just switched off all the auto updates options in system settings, now everything’s working smoothly... That’s hilarious 😂

maxpatiiuk commented 1 month ago

Same issue. Detailed analysis:

VS Code is very fast after closing all instances but gradually gets slower and slower. Especially bad after leaving VS Code open overnight with laptop in sleep mode. VS Code CPU usage is 0.3% when it's in the background but gets too 99% when I am doing something as simple as scrolling or typing. VS Code process explorer shows 99% CPU usage is coming from code main RAM usage is at 370mb with peak at 490mb.

What doesn't help:

Possible culprits:

Using integrated devtools to run a performance profiler:

Issue has been happening for a while.

`code --status` while actively scrolling (98% CPU on `code main`) ```yaml Version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS Version: Darwin arm64 23.6.0 CPUs: Apple M1 Pro (10 x 2400) Memory (System): 32.00GB (9.55GB free) Load (avg): 3, 3, 3 VM: 0% Screen Reader: no Process Argv: /Users/mak13180/site/esri/arcgis-web-components --crash-reporter-id eb79c588-0746-4857-a17b-b971547fd81f GPU Status: 2d_canvas: enabled canvas_oop_rasterization: enabled_on 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: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off CPU % Mem MB PID Process 98 360 77595 code main 0 131 77598 gpu-process 0 33 77599 utility-network-service 0 164 77602 shared-process 0 66 77620 ptyHost 0 0 7937 /bin/zsh -l 0 0 8547 /bin/zsh -l Workspace Stats: | Window (includes.scss — calcite-design-system) | Folder (calcite-design-system): more than 22039 files | File types: json(8704) svg(3606) ts(3520) js(2959) md(162) tsx(131) | scss(130) html(113) yml(26) css(22) | Conf files: package.json(18) github-actions(17) tsconfig.json(9) | settings.json(8) launch.json(2) tasks.json(1) | webpack.config.js(1) | Launch Configs: node(4) chrome ``` Right after restarting VS Code, the CPU usage while scrolling doesn't get above 10%.
`code --status` right after I stop scrolling (1% CPU on `code main`) ```yaml Version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS Version: Darwin arm64 23.6.0 CPUs: Apple M1 Pro (10 x 2400) Memory (System): 32.00GB (9.50GB free) Load (avg): 4, 3, 3 VM: 0% Screen Reader: no Process Argv: /Users/mak13180/site/esri/arcgis-web-components --crash-reporter-id eb79c588-0746-4857-a17b-b971547fd81f GPU Status: 2d_canvas: enabled canvas_oop_rasterization: enabled_on 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: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off CPU % Mem MB PID Process 1 360 77595 code main 0 131 77598 gpu-process 0 33 77599 utility-network-service 0 164 77602 shared-process 0 66 77620 ptyHost 0 0 7937 /bin/zsh -l 0 0 8547 /bin/zsh -l Workspace Stats: | Window (includes.scss — calcite-design-system) | Folder (calcite-design-system): more than 22039 files | File types: json(8704) svg(3606) ts(3520) js(2959) md(162) tsx(131) | scss(130) html(113) yml(26) css(22) | Conf files: package.json(18) github-actions(17) tsconfig.json(9) | settings.json(8) launch.json(2) tasks.json(1) | webpack.config.js(1) | Launch Configs: node(4) chrome ```
6f5 commented 1 month ago

Here's my solution:

  1. Open settings.json
  2. Fix any invalid values shown by the editor (warnings)
  3. Add the following to settings.json
    "files.watcherExclude": {
    "**/node_modules/**": true,
    "**/dist/**": true,
    "**/.git/**": true
    },
    "editor.cursorBlinking": "solid",
    "editor.smoothScrolling": false,
    "editor.renderWhitespace": "none",
    "editor.minimap.enabled": false,
    "editor.codeLens": false
  4. Save Changes and open activity monitor and quit the VSCode main process
  5. Open Terminal and Delete Cache Directories
    rm -rf ~/Library/Application\ Support/Code/Cache
    rm -rf ~/Library/Application\ Support/Code/CachedData
    rm -rf ~/Library/Application\ Support/Code/GPUCache
    rm -rf ~/Library/Application\ Support/Code/Code\ Cache
    rm -rf ~/Library/Application\ Support/Code/Service\ Worker
    rm -rf ~/Library/Application\ Support/Code/DawnWebGPUCache
    rm -rf ~/Library/Application\ Support/Code/DawnGraphiteCache
  6. Open VSCode and enjoy your life again
AzizOzenir commented 1 month ago

You need a solid additonal 16gb ram with high frequency.