pcdshub / Bug-Reports-and-Requests

Issue Tracking for PCDS Software
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Tab completion is very slow #39

Closed ZLLentz closed 4 years ago

ZLLentz commented 4 years ago

Bug Report

All tab completions in hutch python are very slow. (I suppose some of them are merely kind of slow).

Expected Behavior

All tab completions should be zippy. It doesn't have to do much!

Context

Everyone complains about this but nobody has made an issue for it. This sort of bug tends to be difficult to debug.

Steps To Reproduce

  1. hutch-python
  2. pick something and tab

Your Environment

pcds-3.3.4

egaltier commented 4 years ago

We have seen the same slow behavior on tab completion with the mecpython. A fix would smooth down the operation.

klauer commented 4 years ago

I don't see these issues in my local environment, so it's tough to confirm a fix.

This may be related to jedi being installed in the environment and clashing with ophyd magic. Can someone try the following fix?

%config IPCompleter
..
IPCompleter.use_jedi=<Bool>
    Current: True
    Experimental: Use Jedi to generate autocompletions. Default to True if jedi
    is installed.

In [3]: %config IPCompleter.use_jedi
Out[3]: True

In [4]: %config IPCompleter.use_jedi = False

In [5]: %config IPCompleter.use_jedi
Out[5]: False

Other potential thing is related to the current working directory being on super-slow NFS, which the author's suggested remediation is fix your NFS: https://github.com/davidhalter/jedi/issues/1276

ZLLentz commented 4 years ago

Hmm, perhaps this commit was a mistake: https://github.com/pcdshub/hutch-python/commit/293b301b74b952eccdf3314cb64138a0b1ac4575#diff-ac55ee6bfbd76c5ae348764d5dd2be76

klauer commented 4 years ago

Are there still complaints about this after the jedi fix?

ZLLentz commented 4 years ago

Unclear if jedi fix was deployed

ZLLentz commented 4 years ago

I'm doing some testing on this right now because it makes everything else about the hutch python session really annoying to use (and debugging everything else is super slow).

It seems like the jedi fix didn't even work. Here's a hutch-python session using the latest release, running off of the disk instead of NFS. I tried to tab complete (not shown, was super slow) and then I tried to check if use_jedi was True or not:

In [1]: from IPython import get_ipython

In [2]: get_ipython
Out[2]: <function IPython.core.getipython.get_ipython()>

In [3]: ip = get_ipython()

In [4]: ip.Completer.use_jedi
Out[4]: True

After this, I set use_jedi to False in-session and found that my tabs were zippy again. So for some reason the "don't use jedi" config we applied in hutch python didn't take affect. It also means that if we do figure out how to make this work, tabs will be fast.

Confusingly, I also have:

In [10]: ip.config
Out[10]:
{'InteractiveShellApp': {'extensions': ['hutch_python.ipython_log',
   'hutch_python.bug'],
  'matplotlib': 'qt5',
  'Completer': {'use_jedi': False}},
 'TerminalIPythonApp': {'quick': True}}
ZLLentz commented 4 years ago

This will be fixed in the next release :tada: