Skip to content
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

Pylance takes 2+ minutes to analyze every change. #6140

Closed
asparagusbeef opened this issue Jul 15, 2024 · 8 comments
Closed

Pylance takes 2+ minutes to analyze every change. #6140

asparagusbeef opened this issue Jul 15, 2024 · 8 comments
Assignees
Labels
needs repro Issue has not been reproduced yet waiting for user response Requires more information from user

Comments

@asparagusbeef
Copy link

Environment data

  • Language Server version: v2024.7.1
  • OS and version: Windows 11
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.11.5

Code Snippet

Cannot provide a code snippet as this happens in a large project with multiple workspaces.

Repro Steps

My project consists of 11 services that use 6 private packages (installed with pip install --editable)
This happens in two scenarios:

  1. When opening the entire project (multi-root workspace with 17 roots)
  2. When opening just a single package which is widely installed, for example the company-commons package.

Note that scenario 2 doesn't happen when a package is installed with regular pip install.

Expected behavior

I understand this is a large project, but I'm pretty sure my computer should be able to handle it at least an acceptable latency.

Actual behavior

It's excruciatingly slow. Sometimes over 2+ minutes for a small change.

Logs

My process for those logs was:

  1. Open the dispatcher.py in the company-commons workspace, and wait for the logs to stop and analysis to complete.
  2. Make a small change, and wait for the logs to stop and analysis to complete, including hovering my mouse over a function to ensure its resolved.

https://pastebin.com/gRp7x9bd

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jul 15, 2024
@debonte
Copy link
Contributor

debonte commented Jul 15, 2024

Can you provide us with access to your code so we can attempt to reproduce this behavior?

@debonte debonte added the waiting for user response Requires more information from user label Jul 15, 2024
@asparagusbeef
Copy link
Author

I am sorry, I cannot. This is a very large private code base. It does not happen in isolation, only when everything interacts.

@github-actions github-actions bot added user responded Was "waiting for user response" and they responded and removed waiting for user response Requires more information from user labels Jul 15, 2024
@debonte
Copy link
Contributor

debonte commented Jul 15, 2024

I am sorry, I cannot. This is a very large private code base. It does not happen in isolation, only when everything interacts.

In that case, can you please collect a CPU profile of the issue? The profile may contain enough information for us to track down the underlying issue. There are instructions on how to do this here: https://github.com/microsoft/pylance-release/wiki/Collecting-data-for-an-investigation.#collecting-cpuprofiles

@debonte debonte added waiting for user response Requires more information from user and removed user responded Was "waiting for user response" and they responded labels Jul 15, 2024
@asparagusbeef
Copy link
Author

Sure.
I reproduced using the same process:

  1. Open the dispatcher.py in the company-commons workspace, and wait for the logs to stop and analysis to complete.
  2. Make a small change, and wait for the logs to stop and analysis to complete, including hovering my mouse over a function to ensure its resolved.

Note that I waited long minutes at idle parts (I made the change, left the computer for a while, not sure how long, then stopped profilling).

Profiling:

https://file.io/GdDwL3YyadCA

Logs (no tracing)

https://pastebin.com/vQW5z08C

Thanks!

@github-actions github-actions bot added user responded Was "waiting for user response" and they responded and removed waiting for user response Requires more information from user labels Jul 20, 2024
@debonte
Copy link
Contributor

debonte commented Jul 25, 2024

@asparagusbeef, thanks for the CPU profiles. Unfortunately I'm unable to load the ones that are most interesting, and my best guess is that I'm hitting a VS Code bug there. I filed microsoft/vscode#223565. I'm blocked on analyzing your files until I hear back from the VS Code team on this.

@debonte debonte removed the user responded Was "waiting for user response" and they responded label Jul 25, 2024
@debonte
Copy link
Contributor

debonte commented Jul 26, 2024

Note that I waited long minutes at idle parts (I made the change, left the computer for a while, not sure how long, then stopped profilling).

@asparagusbeef, since the size of these files seems to be causing problems for profile viewers, could you try generating a new set of profiles and minimizing the duration of the recording?

@debonte debonte added the waiting for user response Requires more information from user label Jul 26, 2024
@heejaechang
Copy link
Contributor

heejaechang commented Jul 29, 2024

@asparagusbeef I have another idea to figure out the perf cause. since the log shows some files takes long time to analyze, how about you provide us this log (https://github.com/microsoft/pylance-release/wiki/Collecting-data-for-an-investigation.#collecting-type-evaluation-related-data-in-the-log)

if you can do this and provide log for us, that will provide us best chance to find out what is causing perf issue.

...

  1. close all open files
  2. make sure to set python.analysis.diagnosticMode to OpenFileOnly, set python.analysis.typeCheckingMode to off and set python.analysis.indexing to false, and python.analysis.enablePytestSupport to false
  3. set settings following this Collecting type evaluation related data in the log
  4. open a file that repro the issue. make sure you open 1 file.
  5. go to the line you will use to repro the issue.
  6. wait vscode to go idle
  7. clear all log in the python language server output window
  8. type a char that will repo your issue. make sure you type 1 char that will start new analysis.
  9. wait vscode to go idle
  10. copy everything in the python language server output window, and provide them with us.

...

my gut feeling is some of your code require a lot of time for us to infer types. so if you provide type hints at some strategic points, that might improve overall perf.

Copy link
Contributor

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet waiting for user response Requires more information from user
Projects
None yet
Development

No branches or pull requests

3 participants