-
Notifications
You must be signed in to change notification settings - Fork 767
Collecting data for an investigation.
- Enable trace logging by adding
"python.analysis.logLevel": "Trace"
to your settings.json configuration file. - Select
"View: Toggle Output"
from the command palette (Ctrl+Shift+P on Windows/Linux, Command+Shift+P on macOS), then select"Python Language Server"
in the dropdown on the right. - Copy the entire log starting with
"Pylance language server XXX (pyright xxx) starting"
The output will be substantial, but having the full log will help people investigating what is happening
- You can confirm you have the correct log by checking for entries such as the one below.
Search paths for file:///c%3A/repo/test
c:\repo\test
c:\repo\test\src
c:\repo\test\.venv
c:\repo\test\.venv\Lib\site-packages
Adding fs watcher for library directories:
file:///c%3A/repo/test/.venv
file:///c%3A/repo/test/.venv/Lib/site-packages
Adding fs watcher for directories:
file:///c%3A/repo/test
You can also save the log by using the Pylance: Start Logging
and Pylance: Stop Logging
commands. Simply start logging
, perform your repro, stop logging
, and then share the saved log file with us.
- set
python.analysis.logLeve
toTrace
- set
python.analysis.logTypeEvaluationTime
totrue
- set
python.analysis.typeEvaluationTimeThreshold
to500
this will include type evaluation related data to the log. this data is quite large so it should be only included when needed.
[available in 2024.3.100
and after]
- Load the
Pylance extension
by either creating/opening a Python file or folder. - Select
"View: Toggle Output"
from the command palette (Ctrl+Shift+P on Windows/Linux, Command+Shift+P on macOS), and wait for the"Python Language Server"
output pane to be created, logging the state"Pylance language server XXX (pyright xxx) starting"
.
- Wait for
VS Code
togo idle
(no CPU time on VS Code). - Select
"Pylance: Start profiling"
from the command palette. - Reproduce the performance issue.
- when reproducing, please ensure it's as short as possible, containing only the performance issue observed, to avoid unnecessary noise and make identifying issues easier, if not impossible.
- Wait for
VS Code
togo idle
(no CPU time on VS Code). - Select
"Pylance: Stop profiling"
from the command palette. - Go to the folder the message box showed.
- Select all
*.cpuprofile
files in the folder. - Provide those files to Pylance, such as attaching them to an issue.
- If you believe it is an indexing issue, one should:
- Start
pylance extension
with"python.analysis.indexing": false
and - Then perform
steps 1~4
, change"python.analysis.indexing": true
insettings.json
and save. - Then perform
steps 6~10
.
-
"Pylance: Stop profiling"
will generatecpuprofile
files for eachworker thread
. Having all of them will help those investigating the performance issue. -
If you encounter an
Out of Memory (OOM)
error because the reproduction step is too large, use"python.analysis.nodeExecutable"
to allocate more memory to thePylance extension
.