Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

'Go To Definition' takes many minutes to resolve in a moderately-sized project #492

Closed
rspeer opened this issue Dec 13, 2018 · 10 comments · Fixed by #546
Closed

'Go To Definition' takes many minutes to resolve in a moderately-sized project #492

rspeer opened this issue Dec 13, 2018 · 10 comments · Fixed by #546
Assignees
Milestone

Comments

@rspeer
Copy link

rspeer commented Dec 13, 2018

I tried to switch from Jedi to Python Language Server. DonJayamanne, at microsoft/vscode-python#2790, hinted that Jedi would become unsupported, and suggested creating bugs about why Python Language Server is unusable.

I switched off Jedi, restarted VSCode, opened the project I was working on (which sloccount estimates at about 4000 lines of code), and pressed F12 on a pretty typical local import, which looked like this:

from .sibling_module import function_name

A busy indicator (without an indication of progress) started moving under the tab bar. 15 minutes later, it's still going.

I would like to be able to provide more information, such as debug output from the language server, so I can tell what kind of rabbit hole it's falling down. But I can't locate any more information at the moment.

I am using VS Code 1.30 on Ubuntu 18.04, running Python 3.6.5 in a virtualenv.

@rspeer
Copy link
Author

rspeer commented Dec 13, 2018

At this point "many minutes" is an understatement. I don't think the F12 keypress is ever going to resolve.

I found the suggestion to set "Python > Analysis: Log Level" to Trace.

Now I can see that the Language Server's last output is that it is trying to analyze a file that I have deleted since the time I opened the folder. This may be relevant.

@rspeer
Copy link
Author

rspeer commented Dec 13, 2018

I restarted VS Code, went to the same file and pressed F12 again. This time there's almost no tracing output in the Python output window, only this:

Starting Microsoft Python language server.
##########Linting Output - flake8##########
86,1,E,E302:expected 2 blank lines, found 1
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########

Despite that it's not complaining about a deleted file this time, the spinner is still going and the F12 keypress is not resolving.

@rspeer
Copy link
Author

rspeer commented Dec 13, 2018

Oh! That one finished in about 2 minutes. All the language server tracing output appeared all at once, at the end. It contains hundreds of lines like Waiting for analysis of file:///FILENAME to complete., one for each file of Python code that my project depends on, including in other repositories.

It's good that the analysis includes definitions in other repositories, but it's unfortunate that the language server has to wait for every file to be analyzed before it can go to a definition in any file.

The overall result is still that "Go To Definition" is very slow and has no indication of progress, and also it seems that deleting a file may prevent it from working until you restart VS Code.

@jakebailey
Copy link
Member

Go to definition (and other similar functionality) is limited by the analysis completing in many cases. We are currently working on a number of things which should speed up analysis as well as allow for go to def/find symbol/etc to operate without the rest of the analysis completing.

Most of the logging done by the language server shows up in AnalysisLog.txt, which you can find in the extension directory next to the language server dll/binary.

@yevhen-m
Copy link

yevhen-m commented Dec 14, 2018

I have the same issue. When language server engine is selected, I can't get autocomplete or goto (basically anything) even for a moderately small project. Vscode just shows a "loading" spinner that never ends.
How can I troubleshoot?

Parsing complete. Waiting for analysis entries to enqueue.
Enqueue complete. Waiting for analysis to complete.

I have lots of these in vscode -> output -> python.

@JeffHanna
Copy link

JeffHanna commented Dec 15, 2018

I am encountering the same problems. The Python Language Server in VS Code is unsuitable for production work in a large codebase. The analysis never finishes, the outline view never populates, and the peek/go-to definition commands do nothing as they have no information on which to act. My options are to use Jedi, which is a resource hog, but mostly works, or to switch to a Python related IDE such as Wing or PyCharm that doesn't have these issues.

@qubitron qubitron added the GA label Dec 19, 2018
@ghost
Copy link

ghost commented Jan 10, 2019

Agreed. I use VSCode as my editor of choice for work but PLS is completely unusable because it takes a ridiculously long time to start up and eats up 100% of my CPU usage in a reasonably large project. I've had to rely on Jedi which is pretty slow for tasks like Go to Symbol in Workspace but at least functions.

(simple repro - clone the pandas repo and try to do a symbol search).

@jakebailey
Copy link
Member

Finding symbols (+outline) and goto def are slightly different in practice. The former is slated to be handled by #521 (once I clean it up), which moves symbol indexing in parallel with the other analysis. Goto def is tied to the analysis (since we need to gather references), but may be improved with the new analysis.

@MikhailArkhipov
Copy link

#567
Looks like general analysis performance.

@MikhailArkhipov
Copy link

0.2.16 is now available on beta channel.

"python.analysis.downloadChannel": "beta"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants