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 freezes ST and causes very high RAM usage. #271

Closed
deathaxe opened this issue Aug 25, 2018 · 27 comments
Closed

Jedi freezes ST and causes very high RAM usage. #271

deathaxe opened this issue Aug 25, 2018 · 27 comments

Comments

@deathaxe
Copy link
Contributor

deathaxe commented Aug 25, 2018

Description

  1. An python file of a Sublime Text package is open.
  2. Enter from collections import S into the first line.

ST suddenly freezes. After a while the console shows some output error. The CPU usage of the plugin_host.exe increases to 100% for one core. The RAM usage increases up to 1.2GB.

I was faced to that issue several times. Sometimes RAM usage even increases and stays at 2.5GB!

Console Output

Traceback (most recent call last):
  File "C:\Apps\Sublime Text 3\sublime_plugin.py", line 685, in on_query_completions
    res = vel.on_query_completions(prefix, locations)
  File "C:\Apps\Sublime Text 3\Data\Packages\Jedi - Python autocompletion\sublime_jedi\completion.py", line 154, in on_query_completions
    location=locations[0]
  File "C:\Apps\Sublime Text 3\Data\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

TaskManager

screenshot

Infos

  • Win10 Pro 1803 x64
  • ST 3176 x64
  • Jedi v0.13.4
  • Running python 3.7
  • jedi-0.12.1
  • parso-0.3.1
'PYTHONPATH': ';C:\\Apps\\Sublime Text 3\\Data\\Lib\\python3.3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\wcwidth\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\sublime_lib\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\tabulate\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\PYTHON~1\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\pyyaml\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\dateutil\\all;C:\\Apps\\Sublime Text 3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\pygments\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\jsonschema\\all;C:\\Apps\\Sublime Text 3\\python3.3.zip;C:\\Apps\\Sublime Text 3\\Data\\Packages\\pyte\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\python-jinja2\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\MARKUP~1\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\backrefs\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\mdpopups\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\lxml\\st3_windows_x64;C:\\Apps\\Sublime Text 3\\Data\\Packages\\Jedi - Python autocompletion\\dependencies;C:\\Apps\\Sublime Text 3\\Data\\Packages;C:\\Apps\\Sublime Text 3\\Data\\Packages\\pymdownx\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\ruamel-yaml\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\coverage\\st3_windows_x64;C:\\Apps\\Sublime Text 3\\Data\\Packages\\pathtools\\all;C:\\Apps\\Sublime Text 3\\Data\\Packages\\pywinpty\\st3_windows_x64;C:\\Apps\\Sublime Text 3\\Data\\Packages\\regex\\st3_windows_x64;C:\\Apps\\Sublime Text 3\\Data\\Packages\\yaml_macros_engine\\st3;C:\\Apps\\Sublime Text 3\\Data\\Packages\\watchdog\\all',
@kylebebak
Copy link
Contributor

I can confirm that some recent release of Jedi caused a big hit to performance. ST now hangs when trying to populate the autocomplete list, often for as long as a second.

I've been using this plugin for about 5 years and this has never been an issue before.

OSX, ST 3176, Jedi 0.13.4.

@srusskih
Copy link
Owner

@deathaxe Sorry, but I can reproduce the issue with this steps.

@deathaxe @kylebebak Sorry for asking, but, could You please make a "fresh installation" of ST3 (no plugins) and install ONLY Jedi to make sure this is Jedi issue ?

Thanks a lot!

@deathaxe
Copy link
Contributor Author

The issue is 100% reproducible with my setup.

Guess it's somehow related with the provided PYTHONPATH and the dependencies being passed to Jedi.
I use the following little script, which adds the ST's sys.path to the environment. This enables Jedi to see all dependencies automatically. I don't need to care about Package Control installing new ones.

import os
import sys


def update_path_list(var_name, path_list):
    paths = os.environ.get(var_name, "").split(os.pathsep)
    paths += path_list
    os.environ[var_name] = os.pathsep.join(paths)


# add ST's python search paths to the local environment
update_path_list("PYTHONPATH", sys.path)

Reading the console error message carefully makes me wonder about the line containing the python3.3. Jedi runs a python deamon, which runs on the external interpreter (3.7) here. Maybe one of the sys.path entries conflicts with the standalone python 3.7?

Maybe I even got the culprit - not sure. ST's sys.path includes python3.3.zip. Looks like the python 3.7 tries to use it rather than its own stdlib and crashes in the concurrent package.

I disabled my script and put all sys.path entries except the python3.3.zip to jedi's "python_package_paths". Seems to work.

@kylebebak
Copy link
Contributor

@srusskih

I haven't tried with a fresh installation, but let me explain what I did.

I removed SublimeJEDI, started typing some characters into a function call, and the autocomplete list appeared instantaneously.

I then reinstalled SublimeJEDI, started typing the same characters into the same function call, and Sublime Text hangs for nearly a second before showing the autocomplete list.

In my opinion, this is convincing evidence that SublimeJEDI is causing the slowdown. I've isolated the variable that causes the slowdown. The variable is whether or not SublimeJEDI is installed. This didn't start happening until a couple of weeks ago, maybe less. What do you think?

@srusskih
Copy link
Owner

@kylebebak first completion is slow - yeap, that's ok. next completion should be much faster.

But, I still can't reproduce editor slowdown to fix the issue. That's why I'm asking to experiment.

@srusskih
Copy link
Owner

@deathaxe thanks. seems like parso (or not) tried to parse to much.

@kylebebak
Copy link
Contributor

kylebebak commented Sep 6, 2018

@srusskih

I made a small video to show the slowdown, where I type "url" as an argument into a function 4 separate times.

Each time I'm typing "u-r-l" as quickly as I can, but ST hangs visibly for more than half a second after "u" appears but before "r" appears.

out

I've been using Jedi for years and I've never seen slowdown like this. I think this demonstrates that this is not just a problem with slowdown on the first completion. Each time it's just as slow. This project has only 2 modules, with a total of <300 lines of code.

@deathaxe
Could you show me your "python_package_paths" setting for Jedi, so I can see if this gets rid of the slowdown on my machine?

@deathaxe
Copy link
Contributor Author

deathaxe commented Sep 6, 2018

Just added a webbrowser.get(...).open() line somewhere in my code. The first time I enter url, it takes quite a long time - 1 to 3 seconds. But after that the delays seem constant at something like 0.3 to 0.6s.

The culprit for high RAM was the second line in my case.

// These settings override Default settings for the package
{
    "python_package_paths": [
        "C:\\Apps\\Sublime Text 3",
        // "C:\\Apps\\Sublime Text 3\\python3.3.zip",
        "C:\\Apps\\Sublime Text 3\\Data\\Lib\\python3.3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\pygments\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\ruamel-yaml\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\sublime_lib\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\tabulate\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\lxml\\st3_windows_x64",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\pathtools\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\wcwidth\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\coverage\\st3_windows_x64",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\watchdog\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\pywinpty\\st3_windows_x64",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\backrefs\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\dateutil\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\MARKUP~1\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\pymdownx\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\pyte\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\PYTHON~1\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\pyyaml\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\regex\\st3_windows_x64",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\yaml_macros_engine\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\python-jinja2\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\jsonschema\\all",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\mdpopups\\st3",
        "C:\\Apps\\Sublime Text 3\\Data\\Packages\\Jedi - Python autocompletion\\dependencies",
    ],
}

@kylebebak
Copy link
Contributor

Hmm...

My settings for Jedi are just the default settings. In particular, python_package_paths is an empty list. So something else is causing the slowdown for me. At least now we have a reproducible case.

Just typing and retyping various parts of the following causes slowdown that doesn't get better with repeated attempts. But maybe this is to be expected. @srusskih Any ideas?

import webbrowser
webbrowser.get('abc').open(url)

@mew1033
Copy link

mew1033 commented Sep 20, 2018

I'm having the same issue with the same error:

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\Chandler\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\Chandler\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

Anything I can do to help figure out what's going on? And is there a temporary workaround?

@ac130kz
Copy link

ac130kz commented Oct 3, 2018

Same issue (Ubuntu 18.04, fresh installation of Sublime), even though my "python_interpreter": "/usr/bin/python3":

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 685, in on_query_completions
    res = vel.on_query_completions(prefix, locations)
  File "/home/ac130kz/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/completion.py", line 154, in on_query_completions
    location=locations[0]
  File "/home/ac130kz/.config/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

@mew1033
Copy link

mew1033 commented Oct 29, 2018

@srusskih Is there anything I can do to help locate this issue and reproduce it? I've disabled Sublime Jedi because of the slowdowns and I'm missing it.

@srusskih
Copy link
Owner

srusskih commented Oct 30, 2018

@mew1033 do you have a way how the issue can be reproduced?

@srusskih
Copy link
Owner

srusskih commented Nov 12, 2018

reproducible case is in #276 👍 but didn't measure the RAM... only slowdown

@mew1033
Copy link

mew1033 commented Nov 14, 2018

@srusskih Do you still want me to get a reproducible configuration set up, or did you figure it out from @onebits?

@barathbheeman
Copy link

any update on the issue? with jedi st is literally unusable with up to 5 seconds of delay every time I try type anything.

@ninja542
Copy link

ninja542 commented Dec 8, 2018

yeah, I recently noticed this, and I had to remove the package, but this package was pretty useful and I hope I can continue using it :/

@srusskih
Copy link
Owner

srusskih commented Dec 10, 2018

any update on the issue? with jedi st is literally unusable with up to 5 seconds of delay every time I try type anything.

@barathbheeman sounds really bad, it looks like Jedi (jedi lib) by it self are really slow on your env.

@srusskih
Copy link
Owner

as workaround feel free install one of previous versions :(

@srusskih
Copy link
Owner

Have found this davidhalter/jedi#1242

@davidhalter
Copy link

I only just realized how bad this issue was. Big sorry for that. I therefore did a release immediately. (0.13.2)

@srusskih
Copy link
Owner

please check a new release

@mew1033
Copy link

mew1033 commented Mar 6, 2019

I'm still having slowdowns on the latest release. Windows 10, Sublime 3, Python 2.

@kylebebak
Copy link
Contributor

kylebebak commented Mar 28, 2019

I know this may not be helpful, but I can also still confirm that auto-complete for Python files using Sublime Jedi is much slower than auto-complete for any other language I use in ST.

Entering if var is None: into the editor causes noticeable lag as I type if, var, and None.

If I retype if var is None: again, right below the previous if var is None, I run into the same lag. In other words, it doesn't get faster after fetching completions for a given piece of text.

Who knows if this is an issue with Sublime Jedi or with Jedi, but this is obviously not how this is supposed to work. And again, in the past (before August 2018 for me) lag was never a problem with this plugin.

@kylebebak
Copy link
Contributor

kylebebak commented Mar 28, 2019

I added the following to User/Python.sublime-settings to disable auto-complete except on ., as suggested in readme.

"auto_complete_triggers": [{"selector": "source.python", "characters": "."}],
"auto_complete_selector": "-",

This is nice, because ST no longer lags like crazy trying to fetch the Jedi auto-completions, and you still get the info popup if you hover over text, and you get auto-completions for methods and properties and anything that's preceded by ..

But, it kills the rest of Sublime Text's auto-complete functionality for your Python files, which is totally unacceptable. The readme even suggests doing this not just for your Python files, but in all your ST files, by placing the above text in User/Preferences.sublime-settings!

The workaround to me seems to be creating a setting that only disables auto-complete for Sublime Jedi, while keeping the rest of its functionality. I will look into doing this.

@srusskih
Copy link
Owner

@kylebebak thanks for a feedback.
If you would have a time and inspiration could you please collect some logs to investigate the issue?
how to set up logging you can find here https://github.com/srusskih/SublimeJEDI#logging

thanks. will try to look what I can find.

@kylebebak
Copy link
Contributor

Hey @srusskih

Thanks (again) for the super fast response!

I opened a PR, #286, that addresses this slowdown in a different way. Please let me know what you think!

If you'd still like me to look into logging, I can do that this weekend.

@deathaxe deathaxe closed this as completed Aug 6, 2020
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

8 participants