microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.69k stars 769 forks source link

language server analyse files with extremely high delay #6134

Closed ChristLBUPT closed 2 weeks ago

ChristLBUPT commented 1 month ago

Environment data

Code Snippet

from transformers import LlamaTokenizer, LlamaForCausalLM
import deepspeed
import torch
import sys

model_llama: LlamaForCausalLM = LlamaForCausalLM.from_pretrained('/raid_sde/home/user/Downloads/huggingface/pretrained-models/open_llama_3b_v2', torch_dtype=torch.bfloat16, device_map="cuda:0")
tok_llama: LlamaTokenizer = LlamaTokenizer.from_pretrained('/raid_sde/home/user/Dowloads/huggingface/pretrained-models/open_llama_3b_v2')

for name, params in model_llama.named_modules():
    print(name)

with torch.no_grad():
    res = model_llama(**tok_llama('The quick brown fox jumps over the lazy dog', return_tensors='pt').to('cuda:0'))

Repro Steps

  1. This will happen

Expected behavior

The language server properties like linting and autocomplete should follow up as long as I type anything new.

Actual behavior

vscode-pylance-slow1

As shown in the gif above, the language server seems to be a little "torpid" about what I'm typing. After typing new contents, the notification of '1 file to analyse' keeps popping up on the bottom-left corner of the panel, and the linting underlines 'gradually' came up, even if I have stopped typing and waiting for linting suggestions. The autocomplete suggestings, which should have occurred as soon as I stopped typing the torch., came up very slowly, after a great many '1 file to analyse' notifications.

I doubt that those 'gradual' analysing procedures are about the 'outdated file contents', such as the file content just after I type the first character. It seems as if the request to the language server was 'queued' and the language server should 'deal with the earlier file contents' before actually analysing the file content that is present.

Logs

It seems that there isn't anything special about linting and language servers. But I'll still paste the outputs below:

Experiment 'pythonaacf' is active
Experiment 'pythonRecommendTensorboardExt' is active
Experiment 'pythonSurveyNotification' is active
Experiment 'pythonTerminalEnvVarActivation' is active
Experiment 'pythonTestAdapter' is active
LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
> conda info --json
Python interpreter path: ~/miniconda3/envs/lhx-OpenPrompt/bin/python
> conda run -n lhx-OpenPrompt --no-capture-output python ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/printEnvVariables.py
> /usr/bin/python3 -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
> ~/miniconda3/bin/python -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/OpenPrompt/bin/python -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/Web/bin/python -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/lhx-OpenPrompt/bin/python -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/pytorch-transformers/bin/python -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
> /raid_sde/~/conda_envs/pytorch-transformers/bin/python -I ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/get_output_via_markers.py ~/.local/share/code-server/extensions/ms-python.python-2023.4.1-universal/pythonFiles/interpreterInfo.py
Starting Pylance language server.
debonte commented 1 month ago

Language Server version: 2023.4.11 ms-python.python-2023.4.1

The versions of the Python and Pylance extensions that you are using are more than a year old. Can you please upgrade to the latest versions of both and see if this behavior still happens?

github-actions[bot] commented 2 weeks ago

This issue has been closed automatically because it needs more information and has not had recent activity. If the issue still persists, please reopen with the information requested. Thanks.