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

RPC Freezes Up On Completions Windows #1267

Closed
kevinjfoley opened this issue Jan 12, 2018 · 12 comments
Closed

RPC Freezes Up On Completions Windows #1267

kevinjfoley opened this issue Jan 12, 2018 · 12 comments

Comments

@kevinjfoley
Copy link
Contributor

As company returns completions while typing my RPC process will often run out of control and eat up a ton of memory. This causes emacs to freeze and I'm unable to even use C - g to gain control back.

Watching the process manager I can see pythonw.exe memory usage double and after 30 - 60 seconds I get the completions back and get control of emacs. If I kill pythonw.exe I get control back right away without any completions.

This seems similar to #199 and #212 but those are pretty old so I'm wondering if this was solved and maybe I'm missing something in my setup?

My config is:

Elpy Configuration

Virtualenv........: None
RPC Python........: 3.5.4 (c:/.../pythonw.exe)
Interactive Python: python (c:/.../python.exe)
Emacs.............: 25.1.1
Elpy..............: 1.17.0
Jedi..............: 0.11.1
Rope..............: 0.9.4-1
Autopep8..........: 1.3.3
Yapf..............: 0.20.0
Syntax checker....: flake8.exe (c:/.../flake8.exe)
@MartinBurian
Copy link

MartinBurian commented Jan 16, 2018

I was seeing the same issue on Arch linux. As I type in a python buffer, elpy starts spinning at 100% CPU when asked for completions and takes a few minutes to return them. Not always, just in some cases. I found a somwhat minimal file that did that for me:

import dateutil.parser as dtparser

clicks={}
tstr="2017-12-11T10:00:00"
t=dtparser.parse(tstr)
if t not in clicks:
    d=1

# start typing clicks bleow

I concluded it to be a Jedi issue, as the server does not do anything that could go that wrong/. Plus the problem went away when I updated jedi to the latest version. Current elpy config:

RPC Python........: 3.6.2 (/usr/sbin/python)
Interactive Python: ipython (/usr/sbin/ipython)
Emacs.............: 25.3.1
Elpy..............: 1.17.0
Jedi..............: 0.11.1
Rope..............: Not found (0.10.7 available)
Autopep8..........: 1.3.3
Yapf..............: Not found (0.20.1 available)
Syntax checker....: flake8 (/usr/sbin/flake8)```

@jorgenschaefer
Copy link
Owner

This would most likely be a problem with Jedi. I'm afraid this is really difficult to debug. :-(

@kevinjfoley
Copy link
Contributor Author

I've tried a few things to improve performance and so far it seems downgrading Jedi to 0.11.0 has resolved the issue. There's still some hangups but they are fairly short.

@sam-s
Copy link
Contributor

sam-s commented Jan 24, 2018

same problem - elpy freezes.
not using jedi.
how do I disable whatever is doing that?
emacs is not usable ATM.

@jorgenschaefer
Copy link
Owner

Hm. Could you do M-x toggle-debug-on-quit, hit C-g when Emacs freezes, and post the resulting backtrace?

@sam-s
Copy link
Contributor

sam-s commented Jan 26, 2018

despite C-g, it hangs for some time and shows
Debugger entered--Lisp error: (quit)
in *Backtrace*. nothing else.

@sam-s
Copy link
Contributor

sam-s commented Jan 26, 2018

sometimes I get

Debugger entered--Lisp error: (quit)
  redisplay_internal\ \(C\ function\)()

nothing interesting.

@jorgenschaefer jorgenschaefer modified the milestones: v1.18, v1.19 Jan 28, 2018
@jorgenschaefer
Copy link
Owner

This sounds like a problem specific to windows. Maybe some kind of process config, like a buffer size or so. No idea, sadly. :-(

@sam-s
Copy link
Contributor

sam-s commented Feb 2, 2018

I am using mac os x, not windows.

@jorgenschaefer
Copy link
Owner

Ah. The title of the issue seems a bit confusing, then.

In any case, I have no idea. If Emacs freezes in redisplay code, it's not communication with the backend, which makes it hard to figure out what the problem is, really. Maybe using os x's equivalent of strace, whatever that might be. I'm at a loss, I'm afraid.

@sam-s
Copy link
Contributor

sam-s commented Feb 2, 2018

the following patch "solved" the problem:

diff --git a/elpy.el b/elpy.el
index 36698bc..4bad302 100644
--- a/elpy.el
+++ b/elpy.el
@@ -2540,7 +2540,7 @@ Returns the result, blocking until this arrived."
                                   (lambda (err)
                                     (setq error-object err
                                           error-occured t)))))
-    (elpy-promise-wait promise elpy-rpc-timeout)
+    ;; (elpy-promise-wait promise elpy-rpc-timeout)
     (cond
      (error-occured
       (elpy-rpc--default-error-callback error-object))
@@ -2559,16 +2559,16 @@ called with the error list.
 
 Returns a PROMISE object."
   (let ((promise (elpy-promise success error)))
-    (with-current-buffer (elpy-rpc--get-rpc-buffer)
-      (setq elpy-rpc--call-id (1+ elpy-rpc--call-id)
-            elpy-rpc--last-call (float-time))
-      (elpy-rpc--register-callback elpy-rpc--call-id promise)
-      (process-send-string
-       (get-buffer-process (current-buffer))
-       (concat (json-encode `((id . ,elpy-rpc--call-id)
-                              (method . ,method-name)
-                              (params . ,params)))
-               "\n")))
+    ;; (with-current-buffer (elpy-rpc--get-rpc-buffer)
+    ;;   (setq elpy-rpc--call-id (1+ elpy-rpc--call-id)
+    ;;         elpy-rpc--last-call (float-time))
+    ;;   (elpy-rpc--register-callback elpy-rpc--call-id promise)
+    ;;   (process-send-string
+    ;;    (get-buffer-process (current-buffer))
+    ;;    (concat (json-encode `((id . ,elpy-rpc--call-id)
+    ;;                           (method . ,method-name)
+    ;;                           (params . ,params)))
+    ;;            "\n")))
     promise))
 
 (defun elpy-rpc--register-callback (call-id promise)
@@ -2584,12 +2584,12 @@ Must be called in an elpy-rpc buffer."
 (defun elpy-rpc--get-rpc-buffer ()
   "Return the RPC buffer associated with the current buffer,
 creating one if necessary."
-  (when (not (elpy-rpc--process-buffer-p elpy-rpc--buffer))
-    (setq elpy-rpc--buffer
-          (or (elpy-rpc--find-buffer (elpy-library-root)
-                                     elpy-rpc-python-command)
-              (elpy-rpc--open (elpy-library-root)
-                              elpy-rpc-python-command))))
+  ;; (when (not (elpy-rpc--process-buffer-p elpy-rpc--buffer))
+  ;;   (setq elpy-rpc--buffer
+  ;;         (or (elpy-rpc--find-buffer (elpy-library-root)
+  ;;                                    elpy-rpc-python-command)
+  ;;             (elpy-rpc--open (elpy-library-root)
+  ;;                             elpy-rpc-python-command))))
   elpy-rpc--buffer)
 
 (defun elpy-rpc--process-buffer-p (buffer)
@@ -3085,7 +3085,7 @@ Returns a possible multi-line docstring."
   "String used to format references in xref buffers.")
 
 ;; Elpy location structure
-(when (featurep 'xref)
+(when nil ; (featurep 'xref)
   (cl-defstruct (xref-elpy-location
                  (:constructor xref-make-elpy-location (file pos)))
     "Location of a python symbol definition."

I wonder if making this feature optional would be an acceptable solution for you.

@jorgenschaefer jorgenschaefer modified the milestones: v1.19, v1.20 Mar 31, 2018
@galaunay
Copy link
Collaborator

galaunay commented Jul 6, 2019

Is this issue still relevant ?

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

5 participants