You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I avoid pyright opening /opt/homebrew as a workspace? (aka: Pyright becomes unresponsive eating CPU and memory after going to standard library definition.)
#7888
I was going to submit this as a bug, but I think it's likely a config issue. I hope it's still ok to post what I've spent the day investigating - the questions are down at the end. ... update, I've half answered the questions.
Describe the bug
I have this problem where after going to a definition in the standard library pyright starts consuming 100% CPU and chewing through memory.
~ % ps aux 15445 | cat
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
xxxxxx 15445 99.9 9.9 413306080 1660912 ?? R 9:35am 0:50.49 /opt/homebrew/Cellar/node/21.7.3/bin/node --max-old-space-size=3072 /Users/xxxxxx/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/langserver.index.js --node-ipc --clientProcessId=14971
importsignalsignal.signal() # not correct code, but just something for goto-definition## ^## Place cursor here and use the "go to definition" functionality of the edititor
If left long enough, the node process seems to die and restart.
VS Code extension or command-line
OS: macOS 14.4.1 arm64
I'm using neovim, and have been using coc-pyright. But I'm able to repro the same issue when using just plain neovim with nvim-lspconfig to configure the lsp server.
I'm able to repro with all the versions of python that I tried: 3.9.19, 3.10.14, 3.11.9, 3.12.3 - all installed via Homebrew.
~/tmp/pyright-issue/repro % cat package.json
{
"dependencies": {
"pyright": "^1.1.362"
}
}
~ % nvim --version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"
Run :checkhealth for more info
If I understand this correctly, it's spending 85% of the time in some C++ code
that I don't have the symbols for... and the remaining time walking through
files and directories and doing something with them.
For vanilla neovim / nvim-lspconfig I guess anyone who knows their way around lua will be able to write themselves a less problematic root_dir function
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was going to submit this as a bug, but I think it's likely a config issue. I hope it's still ok to post what I've spent the day investigating - the questions are down at the end. ... update, I've half answered the questions.
Describe the bug
I have this problem where after going to a definition in the standard library pyright starts consuming 100% CPU and chewing through memory.
i.e.
If left long enough, the node process seems to die and restart.
VS Code extension or command-line
OS: macOS 14.4.1 arm64
I'm using neovim, and have been using coc-pyright. But I'm able to repro the same issue when using just plain neovim with nvim-lspconfig to configure the lsp server.
I'm able to repro with all the versions of python that I tried: 3.9.19, 3.10.14, 3.11.9, 3.12.3 - all installed via Homebrew.
Freeform
I don't really know too much about node...
...
I found node has a simple guide to profile, https://nodejs.org/en/learn/getting-started/profiling , so I gave that a shot.
The paths change a bit because I removed a plugin and configured LSP directly
If I understand this correctly, it's spending 85% of the time in some C++ code
that I don't have the symbols for... and the remaining time walking through
files and directories and doing something with them.
Processed Profile
...
Maybe it's more useful to see the LSP session, so I've recorded it.
LSP Session recorded using:
https://lsp-devtools.readthedocs.io/en/latest/lsp-devtools/guide/record-command.html
Using coc.nvim:
And again but this time with neovim configured using
nvim-lspconfig
After the first goto-definition, subsequent ones no longer work and are
cancelled by the client.
...
Ok, I think can see the problem.
I have a work machine with a python 3.10.9 that's not affected. It turns out
it's a Rosetta install. i.e. an x86_64
This
"Starting service instance \"/opt/homebrew\""
doesn't occur for the x86_64python 3.10.9
The python 3.10.9 is in
/usr/local/Cellar
which is the prescribed locationfor x86_64 binaries.
I guess pyright opens
/opt/homebrew
as a workspace because it finds/opt/homebrew/.git
How can I tell pyright that this is not ever a workspace?
...
Ok... I've now noticed there was also a
workspace/didChangeWorkspaceFolders
call beforehandI think this means that it's the editor configuration
So, with
coc.nvim
, it seems we can change configure ourworkspace.ignoredFolders
setting in~/.config/nvim/coc-settings.json
.For vanilla neovim / nvim-lspconfig I guess anyone who knows their way around lua will be able to write themselves a less problematic
root_dir
function[ ref ]
but I'd have to ask.
PS: when looking through the closed issues, I have a suspicion that #6720 and #6799 may have had similar causes to my troubles.
Beta Was this translation helpful? Give feedback.
All reactions