-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
so unbelievably slow #6658
Comments
sorry to hear that. if you provide us some profile data described in https://github.com/microsoft/pylance-release/wiki/Collecting-data-for-an-investigation.#collecting-cpuprofiles we might be able to dig in to find out what is going on. also, you could look at https://github.com/microsoft/pylance-release/wiki/Opening-Large-Workspaces-in-VS-Code to see whether pylance is properly set up for your code base. if all you want is some notepad with completion, you can try this https://github.com/microsoft/pylance-release/blob/main/docs/settings/python_analysis_languageServerMode.md |
Thank you, I very much appreciate the help. Does pylance ignore symbolic links? This may be an issue for us. I see there is an open issue for this, so I am guessing it does not yet #5158. We may be able to work around this, but I am wondering if that would also break some of the features. Specifically, we have a common directory that, via symbolic links, is in multiple places in our code base. (The reason for this is how we need to deploy code). If this directory is ignored, when it is a symbolic link, then I am guess pylance would also not be able to do things like 'go to definition' for imports from the common directory? |
are you saying symbolic link is causing the perf issue? or are you talking about something else? |
I am wondering if it might be causing the issue. We have the same files symbolicly linked in many places in our workspaces. If pylance is indexing all of these, I could see it potentially causing and perf issue. |
try disabling indexing '"python.analysis.indexing": false,' |
I am also having the same issue. Just commenting a line makes me wait like 5 seconds before this "1 file and 0 cells to analyze" is finished and linter updates. Same with auto-suggestion box. Can't work with my project. This issue just started recently since last two days. I have tried old versions of Pylance but having same issue which was not there earlier. Can't figure out where is the problem. The Pylance itself takes like 25 seconds to start where earlier it was 4-5 seconds. |
my guess is some configuration mess up? probably log would give us something to look at. but that said, links I shared above would be good point of start.
symbolic link can change as I said above, profile data would be best for us to pinpoint exact problem. otherwise, at least log as stated in the link above. otherwise, it is hard for us to dig in. |
Thanks for quick response. Here are log files for when I reload the VS Code and comment out a line in it. In local system the Pylance is fast and takes about 300ms to start, however in SSH remote server its very slow since last 3-4 days. It takes a long time start and then this "1 file and 0 cells to analyze" shows up after every keystroke including spaces. The linter doesn't update, or IntelliSense suggestion box doesn't appear until it's done which takes about 5-6 seconds. Don't know if the problem is from "Python" and/or "Python Debugger" extensions as they too take a long time to start in SSH server compared to local system. Appreciate the help. |
fwiw I am also working on remote docker container |
@willjhenry without any actual log or profile data, there is not much we can help from our side. @RanitBehera in your case, it looks like
if you do this and share log with us, we might be able to see what cause this slowness on analysis. basically, you do that same thing/steps as you collected the provided logs, but with these settings on
|
@heejaechang Here are the logs. Thanks. |
so, this is the interesting part in the log.
one thing I noticed is that total took that said, it shows some of parts in your code where
what this means is that at the it is same for most of time, there are few offenders and once you explicitly add type annotations for them, perf issue will go away. you might be able to identify the common offenders once you lower the threshold to ... That said, if you can provide us with the actual code, we might be able to identify patterns that need improvement. This could allow us to enhance performance without requiring users to explicitly add type annotations. If you're able to share your code, please let us know. |
ok, here are my cpuprofile files. One is quite large, ~125mb. Is that expected? This was pretty short example, just deleted a variable definition, and then adding it back. Here is a link to a google drive folder with the files: cpuprofile files |
@heejaechang I have tested the same codes on local system and Pylance is incredibly fast. It's only slow in my university server which used to be fast one week back. I will talk with university system admin if they changed some configurations recently. I will update if issue is not from there side. Thanks for the suggestions on type annotations. |
@RanitBehera I was wondering why some of parsing was so slow such as these
I guess slow access to the server might have been the reason why the parsing was so slow. That said, once the file is read and parsed, it is cached in memory, so the slowness should only occur once (until the cache is dumped). However, the type evaluation performance should remain consistent since we need to re-evaluate after changes (such as typing). Adding type annotations should improve type eval performance. |
@willjhenry I looked at your profile. most of slowness was coming from type eval. as you can see here so, the same things I said (#6658 (comment) and #6658 (comment)) to Ranit should apply to you as well if you can provide me the log with the setting on, I can help you pin point location in your code that would help pylance by having explicit type annotation, or if we can get hand on your code, we could improve our type evaluator to better handle your case/code pattern. |
got it, I will try that, Also, to be clear, you are saying explicit type hinting, in function signatures, would speed up pylance? e.g:
|
Yes. When they are missing, pylance will try to figure it out by analyzing the code, such as the function body. For example, if add_numbers was missing type hints, for add_numbers(10, 20). (after the dot here), pylance will look at the function body and arguments, determine that the return type is int, and show suggestions for int. Most of the time, it is fast, but the function body/expressions could be quite complex, or the pattern might be something we can optimize further. In such cases, adding type hints explicitly will help pylance analyze the code more effectively. |
I have these settings on, and will collect more logs: set python.analysis.logTypeEvaluationTime to true |
I also note that I am getting a lot of these messages "Emptying type cache to avoid heap overflow", example: 2024-11-24 19:01:15.001 [info] [Error - 7:01:15 PM] Request workspace/symbol failed. |
I apologize if this is the wrong thread, but often I am stuck on this message, when trying to save a file. "Saving 'create_oregon_people_competition_surveys.py': Getting code actions from ''Python', 'Ruff', 'ESLint', 'Jupyter', 'cursor-retrieval." Could this be pylance? I did attempt to cpuprofile, but after stopping, I did not the popup that indicates where the file is. I will try again |
I reloaded the window, and was able to profile the save command. It ran much quicker this time, so it may not show the problem, and may not even be a Pylance inssue. pylance_2024.8.1_bg_1_id_0.cpuprofile |
@heejaechang https://drive.google.com/file/d/1u2b4cPuJKKem7-UvDmh61-JtyH19R5R_/view?usp=drive_link |
20% of my dev time is now waiting for pylance to finish "3 files and 0 cells to analyze".
The text was updated successfully, but these errors were encountered: