I have been learning python using VScode. I've noticed recently that as soon as I start VScode my CPUs get maxed out and my whole computer is sluggish. When I run the activity monitor I see as many as 5 rg processes running and up to 4 'Code Helper' processes. These processes use up to 125% of CPUs. When I quit VScode, the Activity Monitor still reports a lot of cpu percentage for 'Code Helper', and continues reporting that for over 20 minutes after I quit VScode. Does anyone have any idea why VScode is using so much cpu time? I'm using the latest VScode on my iMac running High Sierra 10.13.5 and VScode version 1.24.1
High CPU is caused most probably by some VS Code extensions. Try running VS Code with all extensions disabled and check if You still experience such CPU. From my experience the Import Cost extension can cause quite high CPU load..
If the CPU is allright with extensions disabled try enabling it one-by-one (work a little bit between enabling every next one) and try to locate which extension is a real CPU eater.
Here is a very good article about troubleshooting performance issues with VS Code: https://github.com/Microsoft/vscode/wiki/Performance-Issues
For those happy in the terminal, there might be a shortcut to experimenting to see which extension is at fault
Just had to solve it so thought I'd share what I found (yes, this approach ought to work on Linux as well)..
top command had this to say. Note that PID - 22032 - and that Code Helper is the guilty party (note: the issue was fixed before I posted this so I can't re-run top and get its output as text).
However... Code Helper provides shared services around many extensions so that doesn't tell you which one is bad.
Next, step, what's at 22032?
Well, I figured it was searchable by
pgrep so I ran this:
(note that there is specifically an
.vscode/extensions/xxx argument to this Code Helper).
pgrep -lafi 'Visual Studio Code.app' ... other VS Code PIDs ... 👉22032👈 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node 👉/Users/me/.vscode/extensions/ms-python.vscode-❌pylance❌-❌2022.10.30/dist/server.bundle.js 👈--cancellationReceive=file:6fcd56f299db327bd6a77767eb05e4f2ba27254a98 --node-ipc --clientProcessId=19541 ... other VS Code PIDs ...
For some reason pylance had been acting up and wouldn't quit even when VSCode was down. I don't think there was anything particularly wrong with Pylance right now, I think it just got itself caught in an infinite loop somehow.
But if this happens again, I will investigate specifically Pylance.
This killed it btw:
pkill -lafi 'Visual Studio Code.app'
p.s. In fact the 100% CPU has been recurring. So I went to the Extensions page, found Pylance, clicked the ⚙️ (gear) icon and selected
Install another version... and picked one from 2 weeks ago. Nice! (though I'd prefer to have the latest working).