Skip to content

High CPU usage #23921

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

Closed
nickpetrovic opened this issue Aug 7, 2024 · 5 comments
Closed

High CPU usage #23921

nickpetrovic opened this issue Aug 7, 2024 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@nickpetrovic
Copy link

nickpetrovic commented Aug 7, 2024

Type: Performance Issue

Behaviour

CPU usage should be minimal. Ideally less than 5%.

These pyenv-which and pyenv-exec processes are spawned as soon as VSCode is opened. Takes a few minutes before they start hitting 100%. They also never terminate when you completely close VSCode. Manually terminating the processes then restarting VSCode will do the same thing over again.

Steps to reproduce:

  1. Open VSCode
  2. Open a Python project or two
  3. Make sure the Python extension is enabled
  4. Wait about 5 minutes for your CPU to be pegged
  5. Kill VSCode, observe the pyenv-exec processes with ms-python.vscode-pylance in the -I argument
  6. Reopen VSCode and now more of the same processes are running, but CPU is completely pegged

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Extension version: 2024.13.2024080701
VS Code version: Code 1.92.0 (b1c0a14de1414fcdaa400695b4db1c0799bc3124, 2024-07-31T23:26:45.634Z)
OS version: Darwin arm64 23.6.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.19
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

experiments
• enabled: false

Installed Extensions
Extension Name Extension Id Version
autoDocstring - Python Docstring Generator njpwerner.autodocstring 0.6.1
Better Jinja samuelcolvin.jinjahtml 0.20.0
Django Support almahdi.code-django 0.5.4
ES7+ React/Redux/React-Native snippets dsznajder.es7-react-js-snippets 4.4.3
Even Better TOML tamasfe.even-better-toml 0.19.2
GitHub Actions github.vscode-github-actions 0.26.3
GitHub Copilot GitHub.copilot 1.220.1035
GitHub Copilot Chat GitHub.copilot-chat 0.18.1
GitHub Pull Requests GitHub.vscode-pull-request-github 0.95.2024080708
GitHub Theme GitHub.github-vscode-theme 6.3.4
GitLens — Git supercharged eamodio.gitlens 15.2.3
Go golang.go 0.42.0
Go Template Support jinliming2.vscode-go-template 0.2.1
HashiCorp HCL hashicorp.hcl 0.5.0
HashiCorp Terraform hashicorp.terraform 2.33.2024073012
IntelliCode VisualStudioExptTeam.vscodeintellicode 1.3.1
JavaScript Debugger ms-vscode.js-debug 1.92.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Kubernetes ms-kubernetes-tools.vscode-kubernetes-tools 1.3.16
Live Share ms-vsliveshare.vsliveshare 1.0.5936
Markdown Preview Mermaid Support bierner.markdown-mermaid 1.23.1
Material Icon Theme PKief.material-icon-theme 5.8.0
Modelines chrislajoie.vscode-modelines 2.0.6
Moonlight atomiks.moonlight 0.11.1
One Dark Pro zhuangtongfa.material-theme 3.17.2
Packer 4ops.packer 0.3.0
Prettier - Code formatter esbenp.prettier-vscode 10.4.0
Pylance ms-python.vscode-pylance 2024.8.1
Python ms-python.python 2024.13.2024080701
Python Debugger ms-python.debugpy 2024.10.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
Tailwind CSS IntelliSense bradlc.vscode-tailwindcss 0.12.5
vscode-proto3 zxh404.vscode-proto3 0.5.5
vscode-styled-components styled-components.vscode-styled-components 1.7.8
YAML redhat.vscode-yaml 1.15.0
System Info
Item Value
CPUs Apple M1 Max (10 x 2400)
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
Load (avg) 10, 9, 9
Memory (System) 32.00GB (0.20GB free)
Process Argv
Screen Reader no
VM 0%
Process Info
CPU %	Mem MB	   PID	Process
    3	   164	 79220	code main
    0	    66	 79221	   gpu-process
    0	    33	 79222	   utility-network-service
    0	   262	 79223	window [1] (metrics.py — beam-client)
    0	   229	 79224	window [2] (app.py — beta9)
    0	    66	 79348	ptyHost
    0	     0	 79354	     /bin/zsh -il
    0	     0	 79427	     /bin/zsh -i
    0	     0	 79492	     /bin/zsh -i
    1	    98	 79349	shared-process
    0	    66	 79350	fileWatcher [2]
    0	    66	 79351	fileWatcher [1]
    0	   131	 79352	extensionHost [1]
    0	     0	 79417	     /Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080701-darwin-arm64/python-env-tools/bin/pet server
    0	     0	 79444	       bash /Users/npetrovic/.pyenv/libexec/pyenv-exec python -c import json, sys; print('093385e9-59f7-4a16-a604-14bf206256fe');print(json.dumps({'version': '.'.join(str(n) for n in sys.version_info), 'sys_prefix': sys.prefix, 'executable': sys.executable, 'is64_bit': sys.maxsize > 2**32}))
    0	    33	 80132	     /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=79352
    0	    66	 80574	     electron-nodejs (bundle.js )
    0	     0	 81170	       bash /Users/npetrovic/.pyenv/libexec/pyenv-exec python3 -I /Users/npetrovic/.vscode/extensions/ms-python.vscode-pylance-2024.8.1/dist/bundled/files/get_pytest_options.py
    0	     0	 81177	       bash /Users/npetrovic/.pyenv/libexec/pyenv-exec python3 -I /Users/npetrovic/.vscode/extensions/ms-python.vscode-pylance-2024.8.1/dist/bundled/files/get_pytest_options.py
    0	    33	 81061	     electron-nodejs (server-node.js )
    0	    33	 82170	     electron-nodejs (tailwindServer.js )
    0	    98	 79353	extensionHost [2]
    0	     0	 79416	     /Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080701-darwin-arm64/python-env-tools/bin/pet server
    0	     0	 79445	       bash /Users/npetrovic/.pyenv/libexec/pyenv-exec python -c import json, sys; print('093385e9-59f7-4a16-a604-14bf206256fe');print(json.dumps({'version': '.'.join(str(n) for n in sys.version_info), 'sys_prefix': sys.prefix, 'executable': sys.executable, 'is64_bit': sys.maxsize > 2**32}))
    0	    33	 80076	     /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=79353
    0	     0	 80395	     /Users/npetrovic/.vscode/extensions/hashicorp.terraform-2.33.2024073012-darwin-arm64/bin/terraform-ls serve
    0	    66	 80530	     electron-nodejs (bundle.js )
    0	     0	 81185	       bash /Users/npetrovic/.pyenv/libexec/pyenv-exec python3 -I /Users/npetrovic/.vscode/extensions/ms-python.vscode-pylance-2024.8.1/dist/bundled/files/get_pytest_options.py
    0	     0	 81193	       bash /Users/npetrovic/.pyenv/libexec/pyenv-exec python3 -I /Users/npetrovic/.vscode/extensions/ms-python.vscode-pylance-2024.8.1/dist/bundled/files/get_pytest_options.py
    0	    33	 82521	     electron-nodejs (server-node.js )
Screen shots

VSCode running
image

VSCode closed/quit
image

Process explorer capturing the high CPU
image

Things tried
  • Completely removed pyenv and deleted the ~/.pyenv directory.
  • Tried an older version of pyenv (v2.3.21)
  • Wiped out my .venv directories for my projects and reinstalled with poetry
  • Disabled the Python extension in VSCode, resolves the issue, but then there's no Python support
  • Disabled the Python Debugger, isort, and Ruff extensions in VSCode
  • Disabled the Pylance extension, this looks like it resolves it, but after having VSCode open for about 5 minutes, htop shows pyenv-which is still hitting 100% at least every other second, but the process is no where to be found in the process explorer.
  • Confirmed that pyenv-which pyenv-exec processes continue to spawn as long as VSCode is opened.
  • Set the Python: Language Server setting to None, issue still happens
  • This looks identical to this issue on python-environment-tools - High CPU usages python-environment-tools#134
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Aug 7, 2024
@karthiknadig karthiknadig self-assigned this Aug 8, 2024
@karthiknadig
Copy link
Member

@nickpetrovic is this with particular pyenv environment or just anything in general? Could you share the logs from Output > Python?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Aug 9, 2024
@nickpetrovic
Copy link
Author

If I remove pyenv entirely, it goes away. Doesn't matter which python project I open up. (See my "Things tried" section.

In my screenshots section, you can see the parent process of pyenv-which is /Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080901-darwin-arm64/python-env-tools/bin/pet server.

Here are the logs you asked for.

2024-08-09 14:22:33.537 [error] Reading directory to watch failed [Error: ENOENT: no such file or directory, scandir '/Users/npetrovic/Projects/beam-client/.pixi/envs'
	at Object.readdirSync (node:fs:1509:26)
	at t.readdirSync (node:electron/js2c/node_init:2:11418)
	at /Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080901-darwin-arm64/out/client/extension.js:2:583006
	at /Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080901-darwin-arm64/out/client/extension.js:2:583197
	at Array.map (<anonymous>)
	at d.initWatchers (/Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080901-darwin-arm64/out/client/extension.js:2:582915)
	at async d.ensureWatchersReady (/Users/npetrovic/.vscode/extensions/ms-python.python-2024.13.2024080901-darwin-arm64/out/client/extension.js:2:539326)] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '/Users/npetrovic/Projects/beam-client/.pixi/envs'
}
2024-08-09 14:22:33.537 [error] Dir "/Users/npetrovic/Projects/beam-client/.pixi/envs" is not watchable (directory does not exist)
2024-08-09 14:22:33.571 [info] Default formatter is set to charliermarsh.ruff for workspace /Users/npetrovic/Projects/beam-client
2024-08-09 14:22:33.580 [info] Python interpreter path: ./.venv/bin/python
2024-08-09 14:22:33.728 [info] > ~/.pyenv/bin/pyenv which python
2024-08-09 14:22:33.728 [info] cwd: .
2024-08-09 14:22:34.669 [info] Starting Pylance language server.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Aug 9, 2024
@reserschnell
Copy link

I think I have the same issue when I'm working remote with my Raspberry Pi. The CPU overload goes that high, that the SSH connection breaks and I can not reconnect.

@karthiknadig
Copy link
Member

This (specifically the pixi error) should get addressed by #23937 . Try the latest pre-release.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Aug 16, 2024
@karthiknadig
Copy link
Member

Duplicate of #23906

@karthiknadig karthiknadig marked this as a duplicate of #23906 Aug 16, 2024
@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants