pylance-release
pylance-release copied to clipboard
High CPU usage
Environment data
- Language Server version: 2022.9.20
- OS and version: Debian Bullseye
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.2
Code Snippet
from sqlalchemy import SQLAlchemy
s = SQLAlchemy.
Repro Steps
- Create a new project and enable the pylance extension.
- Create a new Python file, which contains the above code. Note that the package sqlalchemy is not installed in this python environment, so there is no type information available for the code.
(The real-life example for the above setup is that I am using flask-sqlalchemy, and vscode can't get the type information for the package, due to its dynamical features, as explained in this issue #3256)
Expected behavior
There is no code completion available, and nothing bad should happen either.
Actual behavior
There is no completion, as expected. But after a while, vscode start using 100% of the CPU, and further editing is lagged.
Logs
The log file is attached since it's pretty big.
The abnormal behaviors I noticed from the log are:
- The extension is analyzing all the stub files, even if they are not related to the current python code (for example, type stubs for pandas)
- The stub files are analyzed repeatedly.
The following is the result of grepping an example file name "timedelta" that demonstrates the above observations.
(173388) [BG(1)] parsing: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi [fs read 0ms] (2ms)
(173388) [BG(1)] binding: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi (1ms)
(173388) [BG(1)] parsing: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/core/indexes/timedeltas.pyi [fs read 0ms] (3ms)
(173388) [BG(1)] binding: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/core/indexes/timedeltas.pyi (1ms)
(173388) [BG(1)] parsing: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/core/tools/timedeltas.pyi [fs read 0ms] (5ms)
(173388) [BG(1)] binding: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/core/tools/timedeltas.pyi (1ms)
(173388) [BG(1)] parsing: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi [fs read 0ms] (4ms)
(173388) [BG(1)] binding: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi (1ms)
(173388) [BG(1)] parsing: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi (2ms)
(173388) [BG(1)] binding: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi (1ms)
(173388) [BG(1)] getSemanticTokens full at /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi ...
(173388) [BG(1)] getSemanticTokens full at /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi (5ms)
(173388) [BG(1)] parsing: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi [fs read 0ms] (1ms)
(173388) [BG(1)] binding: /home/zhenlei/.vscode/extensions/ms-python.vscode-pylance-2022.9.20/dist/bundled/stubs/pandas/_libs/tslibs/timedeltas.pyi (0ms)
...