high cpu comsumption when pyright enabled
- pyright version:
1.0.28 - vscode version:
1.34.0 - os version:
windows 7
CPU % Memory (MB) pid Name 1 124 26596 code main 0 66 20076 shared-process 0 152 20560 window 0 207 23940 window (Running Extensions - Visual Studio Code [Administrator]) 0 109 5740 extensionHost 13 125 23256 electron_node server.js 0 116 25884 gpu-process 0 57 27148 window (Process Explorer)
I'll need more information to diagnose what you're seeing.
- Does the high CPU consumption continue for a long time (more than 30 sec after opening a project)?
- Do you see the progress spinner at the bottom of the VS Code status window? It should show how many files are left to analyze. Does this file count decrease, or does it appear to be "stuck"?
- How many python source files are in your project?
- If you install and run the command-line version of pyright, you can specify a "--verbose" option which will print detailed timing stats. Installation instructions for the command-line version can be found on the pyright GitHub site. Thanks for the additional information.
- Yes. CPU's single core starts to run at 100% all day long when I open single .py file, even empty one.
- No.

- One.
- I tried command-line version. I think the command-line version runs without any problem.
Thanks for the additional information. This is the first I've heard of this behavior, and I'd like to figure out the cause.
Could you go to the OUTPUT tab and choose the Pyright output view, and see what logged information is shown? It should start with something like "Pyright language server starting".
- OUTPUT tab:

- ugh while running some 'problems' appeared.
It looks like pyright is processing some files background?
The
\HashiCorp\Vagrant\embedded\mingw\bin\libis located atC:\HashiCorp\Vagrant\embedded\mingw\bin\lib. I have never opened that directory/files. I have no idea why the files are being processed...
OUTPUT tab -> pyright log is attahced. output_pyright.txt
Pyright normally scans for python files anywhere beneath the root directory of your project (the folder you opened in VS Code). I suspect that it's somehow using the root of your drive instead. That would explain the high CPU utilization and why you're seeing errors in files that you don't expect.
This could be Windows-specific behavior. I'll dust off my Windows machine and see if I can repro the problem.
Here's a possible workaround. Try adding a "pyrightconfig.json" file to the root of your project.
I added a "pyrightconfig.json" file and it looks like the problem is solved, thanks!
OK, that's a great clue. I should have enough to repro the problem now.
I tried out a few cases (open as folder/single file, or pyrightconfig.json exists/not exists)...
I think the problem occurs only when the .py is opened as single file (not as an entry of opened folder), regardless of whether the pyrightconfig.json file exists or not.
Thanks for the bug report. This is now fixed in 1.0.29, which I just published. If you still see a problem, please re-open the bug.
I just experiences the same same issue running with 100% CPU and total lock of nvim in my case. pyright 1.1.189 NVIM v0.6.0-dev+493-g035d82e0d
Workaround with adding an empty pyrightconfig.json worked for me.
I have similar problems. @kaar can I ask you about the content of pyrightconfig.json ?
Update:
In the docs there's a sample pyrightconfig.json file.
I have similar problems. @kaar can I ask you about the content of
pyrightconfig.json?Update:
In the docs there's a sample
pyrightconfig.jsonfile.
I had no content at all. Just put an empty file. I've not ran into the issue in a while now. Had this issue with neovim 0.6 and lsp pyright but has after this also upgraded nvim to 0.7 so no longer sure I can reproduce the issue.
Same here, using pyright with neovim LSP. Adding pyrightconfig.json fixes the problem, otherwise I got one core at 100%.
I have 100% CPU. Neovim LSP. Neovim version 0.7.0 build 1319. I have always had a pyrightconfig.json. I can't say if the issue was present before, I just noticed today. Lucky I've got 12 cores. It might be because we've got ~3200 python files in the repo.
Emptying my pyrightconfig.json doesn't reduce CPU usage.
Emptying my pyrightconfig.json doesn't reduce CPU usage.
To clarify it was the existence of the file that made a difference for me and not its content.
Thanks kaar, acknowledged.
For people using pyright with neovim LSP, setting diagnosticMode = "openFilesOnly" in the server setup solved the issue for me. Of course, that if you just want feedback in open files.
Had 100% CPU when opening a file within venvs outside of my project root.
Solution: cd $HOME; touch pyrightconfig.json (i.e. an empty pyright config file in the home folder)
I have 100% CPU. Neovim LSP. Neovim version 0.7.0 build 1319. I have always had a pyrightconfig.json. I can't say if the issue was present before, I just noticed today. Lucky I've got 12 cores. It might be because we've got ~3200 python files in the repo.
Emptying my pyrightconfig.json doesn't reduce CPU usage.
Did you manage to find a fix? I am facing the same issue.