-
Notifications
You must be signed in to change notification settings - Fork 285
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
Slow completion (maybe jedi cache) #823
Comments
I don't have "proof" (or done a systematic investigation) but I subjectively also noticed a noticeable slowdown of either pyls or jedi recently. I found that python-language-server==0.31.10 doesn't have those slowdowns. Maybe you can see if you find the same and compare profiles with those versions? |
It doesn't work for a script consists of |
I also noticed that when using jedi for completion directly its
whereas pyls just stays slow even after the first completion. |
True, true. As I wrote in the PR that shows bottlenecks the issue is related to a lot of "unnecessary" information. It fetches from Jedi documentation and reference of symbols (methods, fields etc) which could be reasonable. For example if you show it within a completion as VSCode does. Anyway the fetching is much slower than fetching of symbols only. May there is a better way to use Jedi API but I don't know it. |
is it possible to utilize this settings of jedi - |
Here is some additional profiling using modified def test_numpy_completions(config, workspace):
doc_numpy = "import numpy as np; np."
com_position = {'line': 0, 'character': len(doc_numpy)}
doc = Document(DOC_URI, workspace, doc_numpy)
import cProfile
import jedi
cProfile.runctx(
'pyls_jedi_completions(config, doc, com_position)', globals(), locals(),
f'pyls_jedi_{jedi.__version__}_numpy_completions_1.prof'
)
cProfile.runctx(
'pyls_jedi_completions(config, doc, com_position)', globals(), locals(),
f'pyls_jedi_{jedi.__version__}_numpy_completions_2.prof'
)
items = pyls_jedi_completions(config, doc, com_position)
assert items
assert any(['array' in i['label'] for i in items]) The very first (zeroth) run after installation can take as long as 25 seconds (!) on a machine with 12 cores, huge RAM and a fast SSD drive. Then it comes down to quite predictable ~12 seconds on first run and ~6 seconds on the consecutive runs (thanks to Jedi cache). I also run it with jedi 0.18 (currently pyls is not compatible with it but it is possible to run this test case after changing version requirements) and there might be an improvement, but not a huge one:
Without going into the details the conclusion is in agreement with what @ANtlord described in #826: The upstream slowness is being tracked in davidhalter/jedi#1059 I believe. Iciclesjedi 0.17.2 - first runjedi 0.17.2 - second runjedi 0.18.0 - first runjedi 0.18.0 - second run |
Hello!
I have a weird issue of completion. In a simple script
import os; os.
completion takes about a second or second and half. It happens only if I use the language. Other language servers for other languages work fine.First I've done is checking speed of Jedi. It shows quite fine results. The first completion takes 0.69s the second one takes 0.12s. When I try to get completion in my editor (Neovim) it takes about every time. It looks like that cache jedi is ignored somehow or the language does something else.
The second thing I've tried is tracing of system call with
strace
. I get such statistics of system calls when a cursor stands after the dot in the end of the stringimport os; os.
Total time is 0.000725s which is quite good too. The only thing I care about is number of
openat
. Some process tries to open a lot ofpyi
files which don't exist but I'm not sure if it the cause of the problem.The third what I've tried is using VSCode but unfortunately I can't get how to install the language server for the editor.
Unfortunately I don't know the protocol and I can't measure response of the language server and I don't know what else I can check to find the bottle neck.
Tech info:
Python 3.8.3
Linux kernel 5.6.19-300.fc32.x86_64
OS: Fedora 32
Editor: Neovim 0.4.3
Language client: https://github.com/autozimu/LanguageClient-neovim
Jedi benchmark
The text was updated successfully, but these errors were encountered: