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

Pylance Very slow and crashing on WSL2

Open 66RED99 opened this issue 9 months ago • 5 comments

Environment data

  • Pylance version: 2025.5.1
  • OS and version: Windows 11 Pro 24H2 (Host machine), Ubuntu (WSL2)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.3

Code Snippet

I won't be able to share the repository due to company policies, but it's a considerably large Django project.

Repro Steps

  1. The moment I start typing code, the autocomplete and syntax highlighting are extremely slow.

This issue also arose suddenly after I opened VS Code on another system (Linux Mint), as the VS Code settings were synced via cloud changes. When I returned to WSL on my Windows system, I encountered this problem.

I also noticed that the files are being analyzed from the beginning each time I type something.

Note: I do not store any of my code in the Windows file system (/mnt/c/...) . I keep it all in \\wsl.localhost\Ubuntu\home\<user>\

Expected behavior

syntax highlighting , autocomplete works as fast as before. pylance not crashing.

Actual behavior

the autocomplete and syntax highlighting are extremely slow.

Logs

2025-06-06 04:58:31.993 [info] (Client) Pylance async client (2025.5.1) started with python extension (2025.6.1)
2025-06-06 04:58:33.558 [info] [Info  - 4:58:33 AM] (839) Server root directory: file:///home/leo/.vscode-server/extensions/ms-python.vscode-pylance-2025.5.1/dist
2025-06-06 04:58:33.558 [info] [Info  - 4:58:33 AM] (839) Pylance language server 2025.5.1 (pyright version 1.1.400, commit b962ffc2) starting
2025-06-06 04:58:33.563 [info] [Info  - 4:58:33 AM] (839) Starting service instance "gts-core" for workspace "/home/leo/AgetWare/gts-core"
2025-06-06 04:58:34.345 [info] [Info  - 4:58:34 AM] (839) Loading pyproject.toml file at /home/leo/AgetWare/gts-core/pyproject.toml
2025-06-06 04:58:34.346 [info] [Info  - 4:58:34 AM] (839) Setting pythonPath for service "gts-core": "/home/leo/.virtualenvs/gt/bin/python"
2025-06-06 04:58:34.369 [info] [Info  - 4:58:34 AM] (839) No include entries specified; assuming /home/leo/AgetWare/gts-core
2025-06-06 04:58:34.370 [info] [Info  - 4:58:34 AM] (839) Auto-excluding **/node_modules
2025-06-06 04:58:34.372 [info] [Info  - 4:58:34 AM] (839) Auto-excluding **/__pycache__
2025-06-06 04:58:34.373 [info] [Info  - 4:58:34 AM] (839) Auto-excluding **/.*
2025-06-06 04:58:34.374 [info] [Info  - 4:58:34 AM] (839) Assuming Python version 3.12.3.final.0
2025-06-06 04:58:34.718 [info] [Info  - 4:58:34 AM] (839) Found 1809 source files
2025-06-06 04:58:34.736 [info] [Info  - 4:58:34 AM] (839) Loading pyproject.toml file at /home/leo/AgetWare/gts-core/pyproject.toml
2025-06-06 04:58:34.737 [info] [Info  - 4:58:34 AM] (839) Setting pythonPath for service "gts-core": "/home/leo/.virtualenvs/gt/bin/python"
2025-06-06 04:58:34.738 [info] [Info  - 4:58:34 AM] (839) No include entries specified; assuming /home/leo/AgetWare/gts-core
2025-06-06 04:58:34.739 [info] [Info  - 4:58:34 AM] (839) Auto-excluding **/node_modules
2025-06-06 04:58:34.740 [info] [Info  - 4:58:34 AM] (839) Auto-excluding **/__pycache__
2025-06-06 04:58:34.741 [info] [Info  - 4:58:34 AM] (839) Auto-excluding **/.*
2025-06-06 04:58:34.764 [info] [Info  - 4:58:34 AM] (839) Assuming Python version 3.12.3.final.0
2025-06-06 04:58:34.960 [info] [Info  - 4:58:34 AM] (839) Found 1809 source files
2025-06-06 04:58:35.736 [info] [Info  - 4:58:35 AM] (839) BG: Priority queue background worker(2) root directory: file:///home/leo/.vscode-server/extensions/ms-python.vscode-pylance-2025.5.1/dist
2025-06-06 04:58:35.736 [info] [Info  - 4:58:35 AM] (839) BG: Priority queue background worker(2) started
2025-06-06 04:58:35.736 [info] [Info  - 4:58:35 AM] (839) BG: Indexer background runner(3) root directory: file:///home/leo/.vscode-server/extensions/ms-python.vscode-pylance-2025.5.1/dist (index)
2025-06-06 04:58:35.736 [info] [Info  - 4:58:35 AM] (839) BG: Indexing(3) started
2025-06-06 04:58:39.698 [info] [Info  - 4:58:39 AM] (839) BG: [BG(1)] Long operation: analyzing: file:///home/leo/AgetWare/gts-core/notebooks/local.ipynb.py#X10sdnNjb2RlLXJlbW90ZQ%3D%3D (2238ms)
2025-06-06 04:58:39.698 [info] [Info  - 4:58:39 AM] (839) BG: scanned(3) 320 files over 1 exec env
2025-06-06 04:58:39.834 [info] [Info  - 4:58:39 AM] (839) BG: indexed(3) 320 files over 1 exec env
2025-06-06 04:58:39.908 [info] [Info  - 4:58:39 AM] (839) BG: Indexing finished(3).
2025-06-06 05:02:26.364 [info] [Info  - 5:02:26 AM] (839) Starting service instance "<default>" for workspace ""
2025-06-06 05:02:26.386 [info] [Info  - 5:02:26 AM] (839) Setting environmentName for service "<default>": "3.12.3 (gt venv)"
2025-06-06 05:02:26.387 [info] [Info  - 5:02:26 AM] (839) Setting pythonPath for service "<default>": "/home/leo/.virtualenvs/gt/bin/python"
2025-06-06 05:02:26.387 [info] [Info  - 5:02:26 AM] (839) No include entries specified; assuming /<default workspace root>
2025-06-06 05:02:26.409 [info] [Info  - 5:02:26 AM] (839) Assuming Python version 3.12.3.final.0
2025-06-06 05:02:26.453 [info] [Error - 5:02:26 AM] (839) File or directory "/<default workspace root>" does not exist.
2025-06-06 05:02:26.453 [info] [Info  - 5:02:26 AM] (839) No source files found.
2025-06-06 05:02:26.825 [info] [Info  - 5:02:26 AM] (839) BG: Priority queue background worker(5) root directory: file:///home/leo/.vscode-server/extensions/ms-python.vscode-pylance-2025.5.1/dist
2025-06-06 05:02:26.826 [info] [Info  - 5:02:26 AM] (839) BG: Priority queue background worker(5) started
2025-06-06 05:11:21.784 [info] 
<--- Last few GCs --->

[839:0x354b0310]   789785 ms: Mark-Compact 3895.9 (4138.4) -> 3882.5 (4142.8) MB, 2117.86 / 0.00 ms  (average mu = 0.069, current mu = 0.017) allocation failure; scavenge might not succeed
[839:0x354b0310]   790572 ms: Mark-Compact 3919.0 (4162.4) -> 3352.6 (4138.9) MB, 688.86 / 0.00 ms  (average mu = 0.087, current mu = 0.125) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----


2025-06-06 05:11:21.788 [info]  1: 0xb8cf03 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.788 [info]  2: 0xf04140 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.789 [info]  3: 0xf04427 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.789 [info]  4: 0x1116075  [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.789 [info]  5: 0x1116604 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.790 [info]  6: 0x112d4f4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.790 [info]  7: 0x112dd0c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.790 [info]  8: 0x1104011 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.791 [info]  9: 0x11051a5 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.791 [info] 10: 0x10e27f6 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.792 [info] 11: 0x153e336 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:21.792 [info] 12: 0x1977ef6  [/home/leo/.vscode-server/bin/258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3/node]

2025-06-06 05:11:47.886 [info] [Error - 5:11:47 AM] Server process exited with signal SIGABRT.
2025-06-06 05:11:47.891 [info] [Info  - 5:11:47 AM] Connection to server got closed. Server will restart.
2025-06-06 05:11:47.891 [info] true
2025-06-06 05:11:47.891 [info] [Error - 5:11:47 AM] Request textDocument/diagnostic failed.
2025-06-06 05:11:47.891 [info] Error: Starting server failed
    at P.$start (/home/leo/.vscode-server/extensions/ms-python.python-2025.6.1-linux-x64/out/client/extension.js:2:2030071)
    at P.sendRequest (/home/leo/.vscode-server/extensions/ms-python.python-2025.6.1-linux-x64/out/client/extension.js:2:2013557)
    at v.pullAsync (/home/leo/.vscode-server/extensions/ms-python.python-2025.6.1-linux-x64/out/client/extension.js:2:2077725)
2025-06-06 05:11:47.891 [info] [Error - 5:11:47 AM] Document pull failed for text document file:///home/leo/AgetWare/gts-core/gts_core/investment/managers.py
2025-06-06 05:11:47.891 [info] Error: Starting server failed
    at P.$start (/home/leo/.vscode-server/extensions/ms-python.python-2025.6.1-linux-x64/out/client/extension.js:2:2030071)
    at P.sendRequest (/home/leo/.vscode-server/extensions/ms-python.python-2025.6.1-linux-x64/out/client/extension.js:2:2013557)
    at v.pullAsync (/home/leo/.vscode-server/extensions/ms-python.python-2025.6.1-linux-x64/out/client/extension.js:2:2077725)

66RED99 avatar Jun 06 '25 05:06 66RED99

Hi @66RED99, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.


Potential Duplicate IssuesThese issues may be duplicates of your report, but may differ in some of the details.

  • New indexer runs on every start and scans all site-packages and workspace files, causing sustained high CPU and slow autocomplete; workaround: exclude large folders or disable library code analysis. https://github.com/microsoft/pylance-release/issues/201
  • Performance degradation when workspace is under WSL home rather than /mnt, leading to repeated re-analysis. https://github.com/microsoft/pylance-release/issues/1443#issuecomment-867863124
  • Slowness due to remote file enumeration in WSL2 and general VS Code remote-WSL performance limitations. https://github.com/microsoft/vscode-remote-release/issues/5000

Potential Workarounds:

  • Open your project from /mnt/... instead of /home/... to leverage faster file system I/O under WSL2.

  • Create a pyrightconfig.json at your workspace root to exclude bulky directories from analysis:

    {
      "exclude": ["**/site-packages", ".pytest_cache", "node_modules"]
    }
    
  • Disable library-code analysis to skip deep inspection of external packages:

    "python.analysis.useLibraryCodeForTypes": false
    

The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!

github-actions[bot] avatar Jun 06 '25 05:06 github-actions[bot]

The crash is an out of memory situation. You could try this to alleviate the memory problem: https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#pylance-is-crashing

You might also try excluding directories that you're not actively working on. That should make Pylance use less memory: https://github.com/microsoft/pylance-release/blob/main/docs/settings/python_analysis_exclude.md

Otherwise, we'd need a reproduction to see if we can do something about running out of memory.

rchiodo avatar Jun 06 '25 16:06 rchiodo

Found 1809 source files...seems large.. whats the name of your venv folder?

bschnurr avatar Jun 06 '25 20:06 bschnurr

Yes, it's large, but it was never this slow, nor was it crashing; this issue suddenly came up.

I use virtualenvwrapper to manage my venvs, store them in my ubuntu home\user directory \\wsl.localhost\Ubuntu\home\leo\.virtualenvs .

The name of this particular venv folder is "gt"; I'm not sure how that will help.

66RED99 avatar Jun 07 '25 05:06 66RED99

i see 'Long operation: analyzing: file:///home/leo/AgetWare/gts-core/notebooks/local.ipynb.py#X10sdnNjb2RlLXJlbW90ZQ%3D%3D (2238ms)'

try adding

  "python.analysis.logTypeEvaluationTime": true,
  "python.analysis.typeEvaluationTimeThreshold": 500,

you might be able to see the call that is taking awhile to type evaluate

bschnurr avatar Jun 07 '25 20:06 bschnurr

I was able to resolve this by reverting to extension version 2025.3.2

rcrogers avatar Jun 17 '25 20:06 rcrogers

I was also having performance issues in WSL2 and going back to 2025.5.1 fixed my issues (or seems like it did). My main issues were while working with jupiter notebooks

jbermejo-ied avatar Jun 19 '25 09:06 jbermejo-ied

one tip is to make sure your files are in WSL2 and not on windows.

bschnurr avatar Jun 19 '25 16:06 bschnurr

one tip is to make sure your files are in WSL2 and not on windows.

All my project is in WSL2

jbermejo-ied avatar Jun 23 '25 05:06 jbermejo-ied