pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Pylance slow to generate diagnostics

Open hunterhogan opened this issue 9 months ago • 9 comments

https://github.com/microsoft/vscode-python/issues/25100

hunterhogan avatar May 28 '25 03:05 hunterhogan

Thanks for the issue but the linked issue doesn't have information other than this:

  • painfully slow Pylance diagnostic
  • syntax highlighting lags by at least 20 seconds and may not update

Unfortunately, this is unactionable without some more information.

Can you include the pylance output log or an example project that reproduces the issue?

rchiodo avatar May 28 '25 16:05 rchiodo

context

Hello, Rich. I am pissed at your employer. I am pissed at people who get paid a lot more money than you are paid but they make stupid decisions. idk you. I'm not angry at you.

from https://github.com/microsoft/vscode-python/issues/25100#issue-3081210365

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: 2025.7.2025052102 VS Code version: Code - Insiders 1.101.0-insider (496ebc4723371f29c9ffa0319dcccb2d7bee7ee0, 2025-05-21T05:04:29.987Z) OS version: Windows_NT x64 10.0.26100 Modes:

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


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"

Installed Extensions
Extension Name Extension Id Version
blocksort 1nV 2.4.2
code-spell-checker str 4.1.0
copilot Git 1.322.1577
copilot-chat Git 0.28.2025052101
datawrangler ms- 1.22.0
debugpy ms- 2025.9.2025052001
indent-rainbow ode 8.3.1
isort ms- 2025.1.11191009
js-debug ms- 1.100.1
js-debug-companion ms- 1.1.3
jupyter ms- 2025.5.2025052103
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.1.2025012901
markdown-all-in-one yzh 3.6.3
markdown-preview-github-styles bie 2.1.0
material-icon-theme PKi 5.23.0
material-product-icons PKi 1.7.1
python ms- 2025.7.2025052102
quicktype qui 23.0.170
ruff cha 2025.22.0
sort-lines Tyr 1.12.0
swift-json-formatter mmo 1.2.1
tombi tom 0.3.43
vscode-copilot-data-analysis ms- 0.2.2
vscode-copilot-vision ms- 0.2.2025032409
vscode-github-actions git 0.27.1
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-markdownlint Dav 0.59.0
vscode-pull-request-github Git 0.111.2025052104
vscode-pylance ms- 2025.5.100
vscode-python-envs ms- 0.3.11411010
vscode-websearchforcopilot ms- 0.1.2025052101
yaml-plus-json hil 1.13.0
z0z_-extensions-for-visual-studio-code hun 0.0.3
System Info
Item Value
CPUs AMD Ryzen 7 5700U with Radeon Graphics (16 x 1797)
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 12.90GB (2.71GB free)
Process Argv --crash-reporter-id c13c7309-b7d9-4f9c-bacf-4e52668033dd
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551:31249597
vscod805cf:30301675
c4g48928:30535728
962ge761:30841072
dsvsc014:30777825
dsvsc015:30821418
h48ei257:31000450
pythontbext0:30879054
cppperfnew:30980852
dwnewjupyter:31046869
pythonrstrctxt:31093868
nativeloc1:31118317
e80f6927:31120813
dwcopilot:31158714
5b1c1929:31184661
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
g012b348:31231168
pythoneinst12:31251391
bgtreat:31252123
c7cif404:31309980
pythonpulldiag:31287486
6gi0g917:31259950
61ibe868:31282443
996jf627:31264550
pythonrdcb7:31268811
usemplatestapi:31297334
e6194696:31309975
747dc170:31275146
pythonfullctx:31296836
6518g693:31302842
pylancecolor:31288664
generatesymbolt:31280541
convertfstringf:31280702
gendocf:31280703
pylancequickfixt:31311477
ajf51753:31312179
923gi514:31310909
b99bg931:31306656
a2ijf515:31307742
convertlamdat:31311571

from https://github.com/microsoft/vscode-python/issues/25100#issuecomment-2899039069

GitHub Actions Language Server.log output.log Ruff Language Server.log

from https://github.com/microsoft/vscode/issues/249463#issue-3080791501

VS Code version: Code - Insiders 1.101.0-insider (496ebc4723371f29c9ffa0319dcccb2d7bee7ee0, 2025-05-21T05:04:29.987Z) OS version: Windows_NT x64 10.0.26100 Modes:

System Info
Item Value
CPUs AMD Ryzen 7 5700U with Radeon Graphics (16 x 1797)
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 12.90GB (3.56GB free)
Process Argv --crash-reporter-id c13c7309-b7d9-4f9c-bacf-4e52668033dd
Screen Reader no
VM 0%
Extensions (33)
Extension Author (truncated) Version
blocksort 1nV 2.4.2
z0z_-extensions-for-visual-studio-code hun 0.0.3
markdown-preview-github-styles bie 2.1.0
ruff cha 2025.22.0
vscode-markdownlint Dav 0.59.0
copilot Git 1.322.1577
copilot-chat Git 0.28.2025052101
vscode-github-actions git 0.27.1
vscode-pull-request-github Git 0.111.2025052104
yaml-plus-json hil 1.13.0
swift-json-formatter mmo 1.2.1
debugpy ms- 2025.9.2025052001
isort ms- 2025.1.11191009
python ms- 2025.7.2025052102
vscode-pylance ms- 2025.5.100
vscode-python-envs ms- 0.3.11411010
datawrangler ms- 1.22.0
jupyter ms- 2025.5.2025052103
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.1.2025012901
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-copilot-data-analysis ms- 0.2.2
vscode-copilot-vision ms- 0.2.2025032409
vscode-websearchforcopilot ms- 0.1.2025052101
indent-rainbow ode 8.3.1
material-icon-theme PKi 5.23.0
material-product-icons PKi 1.7.1
quicktype qui 23.0.170
code-spell-checker str 4.1.0
tombi tom 0.3.43
sort-lines Tyr 1.12.0
markdown-all-in-one yzh 3.6.3
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551:31249597
vscod805cf:30301675
c4g48928:30535728
962ge761:30841072
dsvsc014:30777825
dsvsc015:30821418
h48ei257:31000450
pythontbext0:30879054
cppperfnew:30980852
dwnewjupyter:31046869
pythonrstrctxt:31093868
nativeloc1:31118317
e80f6927:31120813
dwcopilot:31158714
5b1c1929:31184661
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
g012b348:31231168
pythoneinst12:31251391
bgtreat:31252123
c7cif404:31309980
pythonpulldiag:31287486
6gi0g917:31259950
61ibe868:31282443
996jf627:31264550
pythonrdcb7:31268811
usemplatestapi:31297334
e6194696:31309975
747dc170:31275146
pythonfullctx:31296836
6518g693:31302842
pylancecolor:31288664
generatesymbolt:31280541
convertfstringf:31280702
gendocf:31280703
pylancequickfixt:31311477
ajf51753:31312179
923gi514:31310909
b99bg931:31306656
a2ijf515:31307742
convertlamdat:31311571

output.log

some more logs from right now

Version: 1.101.0-insider (user setup) Commit: b4912823f452c08e81283d8fd8dd9e758a00f5f4 Date: 2025-05-28T05:45:00.228Z Electron: 35.4.0 ElectronBuildId: 11602177 Chromium: 134.0.6998.205 Node.js: 22.15.0 V8: 13.4.114.21-electron.0 OS: Windows_NT x64 10.0.26100

Identifier ms-python.vscode-pylance Version 2025.5.100 Last Updated 2025-05-21, 23:04:34

every.log

hunterhogan avatar May 29 '25 01:05 hunterhogan

Is this the repo you're using to cause the problem? https://github.com/hunterhogan/astToolFactory

If so I can try to reproduce locally.

rchiodo avatar May 29 '25 16:05 rchiodo

I can seem to reproduce a problem with semantic colors not updating, but it's intermittent. I was editing datacenter.py.

But the diagnostics don't seem to work. They only update some of the time. Not sure why.

Thanks for the repro. Hopefully we can fix the diagnostic issue.

rchiodo avatar May 29 '25 16:05 rchiodo

Pull diagnostics seems to work, but push doesn't. Not sure why.

This setting here:

"python.analysis.enablePullDiagnostics": true

rchiodo avatar May 29 '25 16:05 rchiodo

I can seem to reproduce a problem with semantic colors not updating, but it's intermittent.

Yes, intermittent. The only pattern I have observed is that the problem is more likely to occur the longer I have had VS Code open without restarting it.

I was editing datacenter.py.

pandas makes me cry.

"python.analysis.enablePullDiagnostics": true

VS Code told me Unknown Configuration Setting, but I found

"python.analysis.usePullDiagnostics": true,

I applied it just now. I'll let you know how it goes.

paths

This block in the log:

2025-05-29 12:58:22.818 [info] (Client) Pylance async client (2025.5.100) started with python extension (2025.7.2025052801)
2025-05-29 12:58:23.524 [info] [Info  - 12:58:23 PM] (22600) Server root directory: file:///c%3A/Users/hunte/.vscode-insiders/extensions/ms-python.vscode-pylance-2025.5.100/dist
2025-05-29 12:58:23.527 [info] [Info  - 12:58:23 PM] (22600) Pylance language server 2025.5.100 (pyright version 1.1.400, commit b962ffc2) starting
2025-05-29 12:58:23.556 [info] [Info  - 12:58:23 PM] (22600) Starting service instance "astToolFactory" for workspace "c:\apps\astToolFactory"
2025-05-29 12:58:23.693 [info] [Info  - 12:58:23 PM] (22600) Loading pyproject.toml file at c:\apps\astToolFactory\pyproject.toml
2025-05-29 12:58:23.697 [info] [Info  - 12:58:23 PM] (22600) Setting environmentName for service "astToolFactory": "3.13.3 (.venv venv)"
2025-05-29 12:58:23.699 [info] [Info  - 12:58:23 PM] (22600) Setting pythonPath for service "astToolFactory": "C:\apps\astToolFactory\.venv\Scripts\python.exe"
2025-05-29 12:58:23.809 [info] [Info  - 12:58:23 PM] (22600) Assuming Python version 3.13.3.final.0
2025-05-29 12:58:23.984 [info] [Info  - 12:58:23 PM] (22600) Found 8 source files

used to say after it read pyproject.toml that it was "assuming" something-something c:\apps\astToolFactory. I thought that was odd because I feel like my pyproject.toml is well-formed and full of information. So, I entered the temple of PyPA and found a detail I hadn't notice before.

https://setuptools.pypa.io/en/latest/userguide/datafiles.html#include-package-data

"Even though we tell you to use pyproject.toml for everything, nothing will work correctly unless you have MANIFEST.in or setuptools-scm or setuptools-svn." (Paraphrased.)

MANIFEST.in is anti-SSOT, so I installed setuptools-scm. That particular "assumption" by Pylance went away. Is it related? idk. I still think this smells like a path issue at heart and that the symptoms arise because of time-outs before switching to a fallback source or continuing without the desired data. Especially after you told me in a different thread that it's a linux build and I'm on windows, I think some of the problem is a change in the VS Code platform. If I am right, Microsoft needs to compensate me.

To preempt a common thought: Windows can often, but not always, use POSIX-style paths. To preempt the thought that usually comes after that: switches are not always the culprit. And to preempt the next thought in the series: not all delimiters fix it, especially if the coder is a linuxhead.

Play around with pushd subOne/subdirTwo and double quotes and single quotes. I guestimate there is a 3% chance of this highly specific issue: the VS Code engine recently changed some path-handling code but the code sometimes doesn't play well with paths when the path is applied in Windows and it's because the syntax look correct to a linuxhead but it's not properly sanitized. And like I said earlier, the problem is probably obfuscated by various time-outs (the delay makes it harder to connect cause and effect) and mitigated by various fallback options. fml. I'm homeless but giving free advice to Microsoft.

gl, Rich.

hunterhogan avatar May 29 '25 19:05 hunterhogan

Still slow

Please let me know if I missed something or if you need more information.

Settings

{
    "python.analysis.diagnosticSeverityOverrides": {
        "reportInvalidTypeVarUse": false,
        "reportPrivateUsage": false,
        "reportUnnecessaryIsInstance": false,
        "reportUnusedFunction": "information",
        "reportUnusedImport": false,
        "reportUnusedVariable": "information"
    },
    "python.analysis.enablePullDiagnostics": true,
    "python.analysis.exclude": [
        "**/__pycache__",
        "**/.*",
        "**/typings",
        "**\\Python*\\Lib\\**",
        "**/typeshed-fallback",
        "${workspaceRoot}/typings"
    ],
    "python.analysis.include": [
        "."
    ],
    "python.analysis.inlayHints.functionReturnTypes": true,
    "python.analysis.inlayHints.pytestParameters": true,
    "python.analysis.inlayHints.variableTypes": true,
    "python.analysis.packageIndexDepths": [
        {
            "depth": 200,
            "includeAllSymbols": true,
            "name": "matplotlib"
        },
        {
            "depth": 200,
            "includeAllSymbols": true,
            "name": "numpy"
        },
        {
            "depth": 200,
            "includeAllSymbols": true,
            "name": "pandas"
        },
        {
            "depth": 200,
            "includeAllSymbols": true,
            "name": "scipy"
        },
        {
            "depth": 2,
            "name": "sklearn"
        },
    ],
    "python.analysis.typeCheckingMode": "strict",
    "python.analysis.typeEvaluation.deprecateTypingAliases": true,
    "python.analysis.typeEvaluation.disableBytesTypePromotions": true,
    "python.analysis.typeEvaluation.enableTypeIgnoreComments": false,
    "python.analysis.typeEvaluation.strictListInference": true,
    "python.analysis.typeEvaluation.strictSetInference": true,
    "python.analysis.typeshedPaths": [
        "${workspaceRoot}/typings"
    ],
    "python.analysis.usePullDiagnostics": true,
    "python.analysis.userFileIndexingLimit": -1,
}

Environment

Version: 1.101.0-insider (user setup) Commit: f832c6b59a2ed11890f4988a29e85658b092a69a Date: 2025-06-06T20:43:03.362Z Electron: 35.5.1 ElectronBuildId: 11708675 Chromium: 134.0.6998.205 Node.js: 22.15.1 V8: 13.4.114.21-electron.0 OS: Windows_NT x64 10.0.26100

Identifier ms-python.vscode-pylance Version 2025.5.101 Last Updated 2025-06-03, 18:52:16

(.venv) C:\apps\astToolFactory>py -V
Python 3.13.4

hunterhogan avatar Jun 07 '25 22:06 hunterhogan

Sorry but this isn't being actively looked at. It's just at the 'reproduced' stage. There was a bug we fixed with semantic tokens, but I haven't tried to see if it addressed the problem here either. (Semantic tokens and diagnostics happen on the same bg thread, so it might have impacted analysis).

Hopefully the semantic fix will ship today.

rchiodo avatar Jun 09 '25 16:06 rchiodo

No worries. From my perspective, the ball was in my court as I evaluated whether the other changes helped.

If the semantic fix is in

Details

Identifier ms-python.vscode-pylance Version 2025.5.103 Last Updated 2025-06-09, 20:34:33

Version: 1.101.0-insider (user setup) Commit: 8a0f4124363d4f22e072c0ee8158a3845099ef0e Date: 2025-06-10T00:22:34.804Z Electron: 35.5.1 ElectronBuildId: 11708675 Chromium: 134.0.6998.205 Node.js: 22.15.1 V8: 13.4.114.21-electron.0 OS: Windows_NT x64 10.0.26100

then the early results are extremely promising. I mean, I haven't had any time to curse and complain while waiting to see exactly how crappy my code is. I'll let you know more in a few days.

hunterhogan avatar Jun 10 '25 03:06 hunterhogan

The problem has not returned. 😄

hunterhogan avatar Jun 17 '25 13:06 hunterhogan