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

Emacs freezes when opening larger python files #703

Closed
shofetim opened this issue Oct 7, 2014 · 14 comments
Closed

Emacs freezes when opening larger python files #703

shofetim opened this issue Oct 7, 2014 · 14 comments

Comments

@shofetim
Copy link

shofetim commented Oct 7, 2014

When opening a (larger) python file in emacs, emacs will freeze for several seconds, to a minute, taking 100% CPU. It is barely noticeable on small files, but on something with more substance, like this it will hang for 30 seconds or so.

It appears to be a recent problem, I hadn't updated to prelude master in a month or so, and it was working before the update.

@shofetim
Copy link
Author

shofetim commented Oct 9, 2014

50e430f appears to be the problem. It turned on which-function-mode for all languages, and which-function-mode depends on imenu, which appears to be very very slow for larger python files.

@bbatsov
Copy link
Owner

bbatsov commented Oct 9, 2014

@toctan Can you have a look at this? Perhaps your imenu tweaks have something to do with the slowness.

shofetim added a commit to shofetim/prelude that referenced this issue Oct 9, 2014
@toctan
Copy link
Contributor

toctan commented Oct 10, 2014

@bbatsov I can't reproduce this. Even if I concat this file ten times into a python file over 10000 lines of code, it's still reasonably fast on my machine.

@shofetim What version of Emacs are you using?

Try to comment these lines of code below in prelude-python.el, restart Emacs and open this file again to see if it's faster.

(when (fboundp #'python-imenu-create-flat-index)
    (setq-local imenu-create-index-function
                #'python-imenu-create-flat-index))

@toctan
Copy link
Contributor

toctan commented Oct 10, 2014

@shofetim And does it make any difference if you turn off anaconda-mode?

@toctan
Copy link
Contributor

toctan commented Oct 10, 2014

@shofetim Also, you may try to disable flycheck-mode.

@shofetim
Copy link
Author

What version of Emacs are you using?

GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of 2014-06-16 on friesian

cat /etc/issue
Debian GNU/Linux 7 \n \l

uname -a
Linux friesian 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux

Though I have two machines, one running Debian Wheezy and the other Jessie and they both exhibit the same problem.

Try to comment these lines
...

Still slow.

And does it make any difference if you turn off anaconda-mode?

Still slow.

Also, you may try to disable flycheck-mode.

No improvement.

@toctan
Copy link
Contributor

toctan commented Oct 10, 2014

@shofetim I suppose there is no issue with vanilla Emacs, so what if you do not enable prelude-python module at all?

@shofetim
Copy link
Author

so what if you do not enable prelude-python module at all?

So I tried with a clean checkout of prelude, no prelude-modules.el and that loaded files fine. I then evaled (require 'prelude-python) and it was back to taking a looooong time.

@pigmej
Copy link

pigmej commented Oct 10, 2014

What about electric-indent-mode / electric-layout-mode added recently ?

I had a feeling that it slow downs my emacs a bit. Maybe thats the issue ?

Open prelude-python and seach for electric layout. Comment it out.

(I writting from mobile, so sorry for not providing a code to disable it)

-----Original Message-----
From: Jordan Schatz [email protected]
Date: Thu, 09 Oct 2014 21:53:20
To: bbatsov/[email protected]
Reply-To: bbatsov/prelude [email protected]
Subject: Re: [prelude] Emacs freezes when opening larger python files (#703)

so what if you do not enable prelude-python module at all?

So I tried with a clean checkout of prelude, no prelude-modules.el and that loaded files fine. I then evaled (require 'prelude-python) and it was back to taking a looooong time.


Reply to this email directly or view it on GitHub:
#703 (comment)

@toctan
Copy link
Contributor

toctan commented Oct 17, 2014

I finally reproduced the problem on an older mac. The problem is that which-function-mode relies onimenu, which is very slow with large python files because the python-mode create imenu index function is quite inefficient. With which-function-mode turned off, even with larger files, the navigation is quite smooth.
@bbatsov So, I think we should revert 50e430f, which turns on which-function-mode for every major mode.

@ghost
Copy link

ghost commented Oct 17, 2014

I don't know what I'm talking about but is there a way that we can change the way python-mode creates imenu? Because as you said it is so slow and not usable, if we could somehow make it efficient it will solve both this problem and imenu issue.

@ghost
Copy link

ghost commented Oct 17, 2014

BTW I suggest instead of reverting 50e430f just disable which-function-mode for python mode

suutari-ai added a commit to suutari-ai/prelude that referenced this issue Feb 10, 2015
* 'master' of github.com:bbatsov/prelude:
  Use gfm-mode instead of plain markdown-mode
  Switch the bindings for zop-to-char and zop-up-to-char
  Add the zop-to-char package
  Minor README tweak - Gittip is now Gratipay
  Warn if the modules file is missing
  Require imenu for prelude-goto-symbol
  `turn-on-eldoc-mode' is an obsolete command (as of 24.4); use `eldoc-mode' instead.
  Use K&R as default style
  Revert "[Fix bbatsov#782] Added magit-filenotify"
  Remove fringe size customization
  fix magit-filenotify error
  Added cython-mode to auto install list
  [Fix bbatsov#764] Removed redundant command
  [Fix bbatsov#783] Removed rainbow-mode from prelude-packages
  [Fix bbatsov#779] Moved elisp-slime-nav to elisp module
  [Fix bbatsov#782] Added magit-filenotify
  [Fix bbatsov#703] Disable which-fun-mode in python-mode
  Removed redundant guru-mode require package
  Don't create already existed directories
  Fix condition for "if prelude alredy installed"
  Reflect flx upstream variable name fix.
  autosave undo history
  Auto install protobuf-mode
  [Close bbatsov#547] Removed ack-and-a-half from prelude
  [Fix bbatsov#623] Restored kill-region defadvice
  [Fix bbatsov#753] Add a note for helm-M-x
  [Fix bbatsov#756] Added helm-ag to auto install list
  elixir module
  Update default opam commands to newest syntax
  Setup the new flycheck-ocaml syntax checker
  Update copyright years
  Install SLIME from MELPA
  helm-every-where takes responsibility for buffers-list

Conflicts:
	modules/prelude-python.el
suutari added a commit to suutari/prelude that referenced this issue Feb 10, 2015
* 'master' of github.com:suutari-ai/prelude:
  personal, vendor: Remove persp-mode stuff
  personal: Update custom-safe-themes
  Use gfm-mode instead of plain markdown-mode
  Switch the bindings for zop-to-char and zop-up-to-char
  Add the zop-to-char package
  Minor README tweak - Gittip is now Gratipay
  Warn if the modules file is missing
  Require imenu for prelude-goto-symbol
  `turn-on-eldoc-mode' is an obsolete command (as of 24.4); use `eldoc-mode' instead.
  Use K&R as default style
  Revert "[Fix bbatsov#782] Added magit-filenotify"
  Remove fringe size customization
  fix magit-filenotify error
  Added cython-mode to auto install list
  [Fix bbatsov#764] Removed redundant command
  [Fix bbatsov#783] Removed rainbow-mode from prelude-packages
  [Fix bbatsov#779] Moved elisp-slime-nav to elisp module
  [Fix bbatsov#782] Added magit-filenotify
  [Fix bbatsov#703] Disable which-fun-mode in python-mode
  Removed redundant guru-mode require package
  Don't create already existed directories
  Fix condition for "if prelude alredy installed"
  Reflect flx upstream variable name fix.
  autosave undo history
  Auto install protobuf-mode
  [Close bbatsov#547] Removed ack-and-a-half from prelude
  [Fix bbatsov#623] Restored kill-region defadvice
  [Fix bbatsov#753] Add a note for helm-M-x
  [Fix bbatsov#756] Added helm-ag to auto install list
  elixir module
  Update default opam commands to newest syntax
  Setup the new flycheck-ocaml syntax checker
  Update copyright years
  Install SLIME from MELPA
  helm-every-where takes responsibility for buffers-list

Conflicts:
	personal/custom.el
DarrenN added a commit to DarrenN/prelude that referenced this issue Feb 14, 2015
* 'master' of https://github.com/bbatsov/prelude: (38 commits)
  [Fix bbatsov#798] Prompt for confirmation in prelude-kill-other-buffers
  Use gfm-mode instead of plain markdown-mode
  Switch the bindings for zop-to-char and zop-up-to-char
  Add the zop-to-char package
  Minor README tweak - Gittip is now Gratipay
  Warn if the modules file is missing
  Require imenu for prelude-goto-symbol
  `turn-on-eldoc-mode' is an obsolete command (as of 24.4); use `eldoc-mode' instead.
  Use K&R as default style
  Revert "[Fix bbatsov#782] Added magit-filenotify"
  Remove fringe size customization
  fix magit-filenotify error
  Added cython-mode to auto install list
  [Fix bbatsov#764] Removed redundant command
  [Fix bbatsov#783] Removed rainbow-mode from prelude-packages
  [Fix bbatsov#779] Moved elisp-slime-nav to elisp module
  [Fix bbatsov#782] Added magit-filenotify
  [Fix bbatsov#703] Disable which-fun-mode in python-mode
  Removed redundant guru-mode require package
  Don't create already existed directories
  ...
murtaza52 pushed a commit to murtaza52/prelude that referenced this issue Feb 16, 2015
rishihahs added a commit to rishihahs/prelude that referenced this issue Feb 18, 2015
* upstream/master: (57 commits)
  [Fix bbatsov#798] Prompt for confirmation in prelude-kill-other-buffers
  Use gfm-mode instead of plain markdown-mode
  Switch the bindings for zop-to-char and zop-up-to-char
  Add the zop-to-char package
  Minor README tweak - Gittip is now Gratipay
  Warn if the modules file is missing
  Require imenu for prelude-goto-symbol
  `turn-on-eldoc-mode' is an obsolete command (as of 24.4); use `eldoc-mode' instead.
  Use K&R as default style
  Revert "[Fix bbatsov#782] Added magit-filenotify"
  Remove fringe size customization
  fix magit-filenotify error
  Added cython-mode to auto install list
  [Fix bbatsov#764] Removed redundant command
  [Fix bbatsov#783] Removed rainbow-mode from prelude-packages
  [Fix bbatsov#779] Moved elisp-slime-nav to elisp module
  [Fix bbatsov#782] Added magit-filenotify
  [Fix bbatsov#703] Disable which-fun-mode in python-mode
  Removed redundant guru-mode require package
  Don't create already existed directories
  ...
wadoon added a commit to wadoon/prelude that referenced this issue Feb 28, 2015
* 'master' of github.com:bbatsov/prelude: (30 commits)
  [Fix bbatsov#798] Prompt for confirmation in prelude-kill-other-buffers
  Use gfm-mode instead of plain markdown-mode
  Switch the bindings for zop-to-char and zop-up-to-char
  Add the zop-to-char package
  Minor README tweak - Gittip is now Gratipay
  Warn if the modules file is missing
  Require imenu for prelude-goto-symbol
  `turn-on-eldoc-mode' is an obsolete command (as of 24.4); use `eldoc-mode' instead.
  Use K&R as default style
  Revert "[Fix bbatsov#782] Added magit-filenotify"
  Remove fringe size customization
  fix magit-filenotify error
  Added cython-mode to auto install list
  [Fix bbatsov#764] Removed redundant command
  [Fix bbatsov#783] Removed rainbow-mode from prelude-packages
  [Fix bbatsov#779] Moved elisp-slime-nav to elisp module
  [Fix bbatsov#782] Added magit-filenotify
  [Fix bbatsov#703] Disable which-fun-mode in python-mode
  Removed redundant guru-mode require package
  Don't create already existed directories
  ...
jarpy pushed a commit to jarpy/prelude that referenced this issue Mar 29, 2015
kutsurak pushed a commit to kutsurak/prelude that referenced this issue Apr 6, 2015
ryanwersal pushed a commit to ryanwersal/prelude that referenced this issue May 5, 2015
dfc added a commit to dfc/prelude that referenced this issue May 8, 2015
* upstream/master: (25 commits)
  Minor README tweak - Gittip is now Gratipay
  Warn if the modules file is missing
  Require imenu for prelude-goto-symbol
  `turn-on-eldoc-mode' is an obsolete command (as of 24.4); use `eldoc-mode' instead.
  Revert "[Fix bbatsov#782] Added magit-filenotify"
  Remove fringe size customization
  fix magit-filenotify error
  Added cython-mode to auto install list
  [Fix bbatsov#764] Removed redundant command
  [Fix bbatsov#783] Removed rainbow-mode from prelude-packages
  [Fix bbatsov#779] Moved elisp-slime-nav to elisp module
  [Fix bbatsov#782] Added magit-filenotify
  [Fix bbatsov#703] Disable which-fun-mode in python-mode
  Removed redundant guru-mode require package
  Don't create already existed directories
  Fix condition for "if prelude alredy installed"
  Reflect flx upstream variable name fix.
  autosave undo history
  Auto install protobuf-mode
  [Close bbatsov#547] Removed ack-and-a-half from prelude
  ...
celkins pushed a commit to celkins/prelude that referenced this issue Jun 11, 2015
@lackita
Copy link

lackita commented Sep 21, 2015

For anybody that is still having issues that happens upon this thread, I realized the core of my problem was actually trying to edit over tramp.

Dao007forever pushed a commit to Dao007forever/prelude that referenced this issue Nov 11, 2015
hbin pushed a commit to hbin/emacs.d that referenced this issue Feb 22, 2017
hbin pushed a commit to hbin/emacs.d that referenced this issue Feb 22, 2017
@fleutot
Copy link

fleutot commented Aug 20, 2020

I had a similar issue (freeze at opening python file) in 26.1, until I disabled flyspell-prog-mode.

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

6 participants