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

Jedi on sublimeText3 too slow. #276

Open
onebits opened this issue Nov 10, 2018 · 21 comments
Open

Jedi on sublimeText3 too slow. #276

onebits opened this issue Nov 10, 2018 · 21 comments

Comments

@onebits
Copy link

onebits commented Nov 10, 2018

When I typing code. It's very lagging...
For example:
content = res.content.decode('utf-8')
When I typing these code, on first "c" its lag.. res. its lag..
How to fix it ???
not a large file.
Look when i typing res.
jedi_lag

@onebits
Copy link
Author

onebits commented Nov 10, 2018

I found new info on console:

Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 685, in on_query_completions
res = vel.on_query_completions(prefix, locations)
File "C:\Users\jeeyong\AppData\Roaming\Sublime Text 3\Packages\Jedi - Python autocompletion\sublime_jedi\completion.py", line 154, in on_query_completions
location=locations[0]
File "C:\Users\jeeyong\AppData\Roaming\Sublime Text 3\Packages\Jedi - Python autocompletion\sublime_jedi\daemon.py", line 83, in ask_daemon_with_timeout
return request.result(timeout=timeout)
File "./python3.3/concurrent/futures/_base.py", line 403, in result
concurrent.futures._base.TimeoutError

@srusskih
Copy link
Owner

yeap, I can reproduce it :)

import requests

resp = requests.get('http://google.com')
resp.c

will try to measure/debug what is wrong

@srusskih
Copy link
Owner

PS:

import requests

resp: requests.Response = requests.get('http://google.com')
resp.c

with type hinting it works much faster :) 🏇 😱

@Aero-fish
Copy link

I think there are some bugs with type hinting. Jedi is also not able to autocomplete the following code:

v: List[str] = []
v.   # No autocomplete

@srusskih
Copy link
Owner

@Aero-fish I think you issue related to davidhalter/jedi/issues/1096

@onebits
Copy link
Author

onebits commented Nov 14, 2018

PS:

import requests

resp: requests.Response = requests.get('http://google.com')
resp.c

with type hinting it works much faster :) 🏇 😱

I still think this problem has something to do with this matter:

File "C:\Users\jeeyong\AppData\Roaming\Sublime Text 3\Packages\Jedi - Python autocompletion\sublime_jedi\daemon.py", line 83, in ask_daemon_with_timeout
return request.result(timeout=timeout)
File "./python3.3/concurrent/futures/_base.py", line 403, in result
concurrent.futures._base.TimeoutError

@srusskih
Copy link
Owner

srusskih commented Nov 15, 2018

@onebits can you try measure latency with jedi lib?

@srusskih
Copy link
Owner

srusskih commented Dec 12, 2018

@onebits I have added a extra logging (would be available in master soon) and what I found during checking the case:

2018-12-11 16:37:59,394 INFO   - Jedi - Python autocompletion.sublime_jedi.completion:144 - on_query_completions() - JEDI completion triggered.
2018-12-11 16:37:59,395 INFO   - Jedi - Python autocompletion.sublime_jedi.daemon:168 - request() - Sending request to daemon for "autocomplete"
2018-12-11 16:37:59,395 DEBUG  - Jedi - Python autocompletion.sublime_jedi.daemon:169 - request() - ('autocomplete', {}, '', 3, 3)
2018-12-11 16:37:59,396 DEBUG  - parso.python.diff:128 - update() - diff parser start
2018-12-11 16:37:59,397 DEBUG  - parso.python.diff:139 - update() - diff parser calculated
2018-12-11 16:37:59,397 DEBUG  - parso.python.diff:140 - update() - diff: line_lengths old: 4, new: 4
2018-12-11 16:37:59,397 DEBUG  - parso.python.diff:144 - update() - diff code[equal] old[1:3] new[1:3]
2018-12-11 16:37:59,397 DEBUG  - parso.python.diff:214 - _copy_from_old_parser() - diff actually copy 1 to 3
2018-12-11 16:37:59,397 DEBUG  - parso.python.diff:144 - update() - diff code[replace] old[4:4] new[4:4]
2018-12-11 16:37:59,398 DEBUG  - parso.python.diff:263 - _parse() - parse_part from 4 to 4 (to 3 in part parser)
2018-12-11 16:37:59,398 DEBUG  - parso.python.diff:173 - update() - diff parser end
2018-12-11 16:37:59,565 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/models.py
2018-12-11 16:37:59,681 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/sessions.py
2018-12-11 16:37:59,725 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/hooks.py
2018-12-11 16:37:59,844 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/adapters.py
2018-12-11 16:37:59,865 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/_internal_utils.py
2018-12-11 16:37:59,925 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/auth.py
2018-12-11 16:37:59,928 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/certs.py
2018-12-11 16:38:00,018 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/cookies.py
2018-12-11 16:38:00,032 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/exceptions.py
2018-12-11 16:38:00,194 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/utils.py
2018-12-11 16:38:00,207 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/struct.py
2018-12-11 16:38:00,230 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/compat.py
2018-12-11 16:38:00,239 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/__init__.py
2018-12-11 16:38:00,428 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py
2018-12-11 16:38:00,762 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/collections/__init__.py
2018-12-11 16:38:00,894 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/operator.py
2018-12-11 16:38:01,084 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/os.py
2018-12-11 16:38:01,258 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_collections_abc.py
2018-12-11 16:38:01,478 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/platform.py
2018-12-11 16:38:02,205 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py
2018-12-11 16:38:02,294 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py
2018-12-11 16:38:02,431 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py
2018-12-11 16:38:02,704 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py
2018-12-11 16:38:02,767 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/fnmatch.py
2018-12-11 16:38:02,955 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/status_codes.py
2018-12-11 16:38:02,974 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/requests/structures.py
2018-12-11 16:38:03,165 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py
2018-12-11 16:38:03,195 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_threading_local.py
2018-12-11 16:38:03,271 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/urllib3/__init__.py
2018-12-11 16:38:03,277 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/urllib3/util/__init__.py
2018-12-11 16:38:03,311 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/urllib3/util/url.py
2018-12-11 16:38:03,392 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/idna/__init__.py
2018-12-11 16:38:03,477 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/idna/core.py
2018-12-11 16:38:03,582 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/urllib3/packages/__init__.py
2018-12-11 16:38:03,632 DEBUG  - parso.cache:120 - _load_from_file_system() - pickle loaded: /usr/local/lib/python3.6/site-packages/urllib3/packages/ordered_dict.py
2018-12-11 16:38:03,688 DEBUG  - Jedi - Python autocompletion.sublime_jedi.daemon:182 - request() - Answer: [('close\tfunction', 'close'), ('content\tfunction', 'content'), ('cookies\tstatement', 'cookies')]
2018-12-11 16:38:03,688 INFO   - Jedi - Python autocompletion.sublime_jedi.completion:156 - on_query_completions() - Completion completed.
2018-12-11 16:38:03,689 DEBUG  - Jedi - Python autocompletion.sublime_jedi.completion:159 - on_query_completions() - Completions: [('close\tfunction', 'close'), ('content\tfunction', 'content'), ('cookies\tstatement', 'cookies')]

jedi spend most of it time in parso.cache :(

@srusskih
Copy link
Owner

please check a new release

@walkinrain2008
Copy link

new version still slowly
when code is very large(more than 300 lines)

@mew1033
Copy link

mew1033 commented Mar 6, 2019

I'm still getting the slowdown too. @srusskih: Any ideas?

@JeromeDesseaux
Copy link

Still slow.

@edelvalle
Copy link
Collaborator

@srusskih should we make it async again? but ignore requests that were sent before the last one made?

@JeromeDesseaux
Copy link

@edelvalle if I can say something : I think it might be better async. Here, as soon as you type, the process is triggered after each letter. On the first letters of a word (in a project with some dependencies) you might notice that it takes quite a long time to process and let you type the second letter, then its the same again ... I think it might be interesting using async and a process like using a kind of search tree in which, for each letter, you store all the related nodes like a dictionary. Then the processing time might be reduced and an async called would be fast enough to display the results in time :)

@edelvalle
Copy link
Collaborator

edelvalle commented Oct 28, 2019

A prefix tree?

@srusskih
Copy link
Owner

@JeromeDesseaux sound like a plan, but we do not control "search" (&caching) logic of jedi

async can help to avoid interface freez but it would recover other bug with "completion blinking" because ST3 completion non-sync by it neture.

we can try provide option to enable/disable async for those who need it...

@srusskih
Copy link
Owner

srusskih commented Oct 29, 2019

@JeromeDesseaux what you think about throttling on typing? to reduce a number of completion tries...

@JeromeDesseaux
Copy link

@srusskih to be honest : I never developed a sublime text extension. I admire all the people giving their time to do so! Really.

I have no idea how Sublime works for completion... but is it possible to "clean" the completion box content instead of redrawing it each time ? Like a blackboard or an eraser.

@caph1993
Copy link

In my case, autocompletion works the first two or three times. After that, I get a timeout error and the autocompletion stops working entirely:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 701, in on_query_completions
    res = vel.on_query_completions(prefix, locations)
  File "/home/carlos/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/completion.py", line 162, in on_query_completions
    timeout=settings['completion_timeout']
  File "/home/carlos/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/daemon.py", line 84, in ask_daemon_with_timeout
    return request.result(timeout=timeout)
  File "./python3.3/concurrent/futures/_base.py", line 403, in result
concurrent.futures._base.TimeoutError

Is this due to this issue of speed?

@SAPROYECTOSELECTRICOS
Copy link

Hi, I have the same problem :/ . Have somebody found a solution to it? . I thank you in advance.

@edelvalle
Copy link
Collaborator

Well just made a PR #306 it should solve this problem.

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

No branches or pull requests

9 participants