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.el seems to be causing my Emacs to hang every 15-20 minutes on my Mac OSX machine #239

Open
ginobean opened this issue Jun 26, 2015 · 11 comments

Comments

@ginobean
Copy link

I was using jedi.el with popwin and jedi-direx, but when I was editing python files, my Emacs buffer would mysteriously freeze from time to time. If I press C-g to abort a couple times, Emacs would unfreeze for a short period of time, then freeze again.
using the (setq debug-on-quit t) feature, I took a look at the stack trace when it was mysteriously freezing. looks like it's freezing on the epc package's rpc call.
What's mysterious is that auto-completion and browse to definition seem to work fine for 10-15 minutes, at least until the buffer freezes. BTW, 10-15 and 15-20 minutes are somewhat arbitrary numbers I picked. It's definitely freezing at least a couple times within an hour, possibly more.
In any case, although I like the featureset of jedi.el, due to the mysterious freezing, I've decided to switch to using ropemacs for the time being..

@syohex
Copy link
Collaborator

syohex commented Jun 26, 2015

Which emacs version do you use ?

@ginobean
Copy link
Author

Initially, 24.3.1. Then, I tried the latest version of GNU Emacs: 24.5.1. It seemed to have the same buffer freezing issue. At first, I tried to ignore it. But then, after it had happened about a dozen times over a couple days, I realized it was getting a bit too annoying to deal with.

Also, I had two separate Emacs instances running some of the time, with a different Python source file in each Emacs instance. I don't know if this is relevant or not. I think it froze even when I just had the one instance running.

@syohex
Copy link
Collaborator

syohex commented Jun 27, 2015

Emacs 24.3 has timer bug which causes Emacs hangs up, however this issue is occurred on Emacs 24.5, this is not related to timer bug.

Is this issue occurred without popwin and jedi-direx ?

@ginobean
Copy link
Author

I was able to get an Emacs debug stack trace just now. It looks to me like you are using process-send-string to send the entire contents of the edit buffer to the jedi server.
Now, for files that are fairly small (< 10K bytes size), this may be doable. But if you are sending the entire contents of the buffer to jedi every couple seconds, my guess is that jedi has to reparse the mostly same buffer repeated every couple seconds. As the buffer size gets significantly larger (i.e. the python source file gets larger), there comes a point when the jedi server is no longer able to keep up with the requests sent to to it by jedi.el.

For me, this threshold seems to be reached with an edit file of about 16K. Which, by most programming metrics, is a fairly small sized file.

So, it looks like it's not so much that Emacs is hanging, but Emacs ends up slowing down to a crawl due to the repeated full buffer parse requests being sent to the jedi server.

Just my two cents, but could it be that the time complexity issues of larger edit buffer sizes is basically causing jedi.el to slow down to a crawl ?

If my theory is basically correct, then most likely jedi.el can only reasonably be used on edit buffers under 10K.

Does the jedi api support interactive editing without necessitating a full send of the buffer contents ? I would imagine there are 2 significant factors at play here: 1) the transmission time to send over the buffer contents; 2) the time for the jedi server to reparse the buffer contents. When parts 1 and 2 are done iteratively and frequently, again, it seems to me that this would inherently involve significant time complexity bottlenecks.

@glyph
Copy link
Contributor

glyph commented Mar 25, 2017

I'm also seeing this, increasingly frequently in recent months. Even on relatively small (~1000-line) buffers.

@bryanbates
Copy link

bryanbates commented Jul 26, 2017

I'm able to reproduce this on macOS Sierra (10.12.6), Emacs 25.2.1 (from emacsformacosx.com) by opening a new Python file and entering:

import argparse

parser = argparse.

After argparse., I see a single underscore, and Emacs freezes completely.

Jedi version: 20160425.2156
Jedi-core version: 20170121.610

(I'll attempt to eliminate confounding variables in my setup in the next day or two.)

@bryanbates
Copy link

Confounding factor: I was attempting to use Fira Code's ligatures, which are currently known to cause similar problems.

Disabling them cleared up my particular issue.

@jaseemabid
Copy link

+1 on Fira. Used to mess up way too many things including edts, magit and jedi. Disabled the font and things are great again.

@immerrr
Copy link
Collaborator

immerrr commented Nov 10, 2018

Hi all, could you please try out the latest version and see if the issue persists?

@appetrosyan
Copy link

+1 Persists.

@immerrr
Copy link
Collaborator

immerrr commented Jan 29, 2020

@appetrosyan could you try adding

(setq jedi:server-args `("--log-level=DEBUG"
                         ,(format "--log=%s" (expand-file-name "~/jediepcserver.log"))
                         "--log-traceback"))

to the config and check the $HOME/jediepcserver.log.* files for clues regarding what's happening?

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

No branches or pull requests

7 participants