Subject: 24.0.90; org-mode: sluggish response and high CPU utilization with large .org files

From: Steve Revilak <[email-masked]>
Date: Mon, 26 Sep 2011 22:50:25 -0400

This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgement at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug.  If you can, give a recipe
starting from `emacs -Q':

I'd like to report an org-mode regression issue.  When working with
large .org files, Emacs 24.0.90 becomes sluggish, and consumes large
amounts of CPU.

I've attached an .org file (sample.org.gz) that causes emacs to exhibit
this behavior.  I apologize for the large attachment, but I have not
been able to reproduce this issue with small .org files.

Steps to reproduce:

(1) gunzip sample.org.gz

(2) run "top" in a terminal window.  We'll use top to monitor emacs CPU
utilization.

(3) Start emacs as "emacs -Q sample.org".  Emacs should open the file
with org-mode as the major mode.

(4) Press M-> to position point at the end of the buffer.

(5) Press RET and start typing.  You don't need to type anything
meaningful: nonsense like "fdfsds fdsfds fdsfdsf fdsfdfsds" will do.
Continue typing for 10-20 seconds.

(6) While typing notice the delay between pressing keys on the keyboard,
and the characters being displayed in the buffer.  To me, this feels
similar to typing characters into an ssh session, over a slow
communications link.

(7) While typing, observe emacs CPU utilization in top.  While
performing step (5), I observed emacs using 100% CPU.  (My machine has a
quad-core 2.66 GHz Intel Xeon processor; emacs was fully utilizing one
of the CPU cores).

(8) Repeat steps (3)--(7) with emacs 23.3.  With emacs 23.3, the delays
in (6) are not present.  As for step (7), I could not get emacs 23.3 to
use more than 2--4% CPU (as reported via top).

Uname for my system is
Linux sunny 2.6.37.6-0.7-desktop #1 SMP PREEMPT 2011-07-21 02:17:24 +0200 x86_64 x86_64 x86_64 GNU/Linux

Another thing you can try: put point in line 1, column zero.  Press and
hold the keyboard down arrow until point reaches the end of buffer;
then, press and hold the keyboard up arrow until point reaches the first
line of the buffer.  Repeat this a few times.  With emacs 24, the point
movement is `jerky', and emacs uses ~ 47% CPU (as reported by top).
With emacs 23.3, the point movement is `smooth', and emacs 23.3 uses
2--4% CPU (as reported by top).

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
     `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/local/emacs-24.0.90.1/share/emacs/24.0.90/etc/DEBUG.

In GNU Emacs 24.0.90.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.22.1)
  of 2011-09-26 on sunny
Windowing system distributor `The X.Org Foundation', version 11.0.10903000
configured using `configure  '--prefix=/usr/local/emacs-24.0.90.1/''

Important settings:
   value of $LC_ALL: nil
   value of $LC_COLLATE: C
   value of $LC_CTYPE: nil
   value of $LC_MESSAGES: nil
   value of $LC_MONETARY: nil
   value of $LC_NUMERIC: nil
   value of $LC_TIME: nil
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=local
   locale-coding-system: utf-8-unix
   default enable-multibyte-characters: t

Major mode: Perl

Minor modes in effect:
   diff-auto-refine-mode: t
   shell-dirtrack-mode: t
   display-time-mode: t
   tooltip-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   column-number-mode: t
   line-number-mode: t

Recent input:
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v 
C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v 
C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v 
C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v 
C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v C-v 
C-v C-v C-v C-v C-v C-v C-v <down-mouse-1> <mouse-1> 
C-x k <return> <down-mouse-1> <mouse-1> M-x r e p o 
r t - e m a <tab> <return>

Recent messages:
Saving file /home/srevilak/sample.org...
Wrote /home/srevilak/sample.org
Mark set
Saving file /home/srevilak/sample.org...
Wrote /home/srevilak/sample.org
FOLDED
CHILDREN
SUBTREE
byte-code: Beginning of buffer [3 times]
scroll-up-command: End of buffer [5 times]
scroll-up-command: End of buffer

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr message sendmail rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
emacsbug perl-mode tabify pcmpl-unix vc-bzr vc-sccs vc-svn vc-dir
org-clock dired-aux log-view vc-rcs two-column term disp-table ehelp
electric browse-url mule-util cal-move org-table dired pcvs pcvs-parse
pcvs-info pcvs-defs ewoc smerge-mode executable pcmpl-cvs ansi-color
ispell diff-mode help-mode view thingatpt reftex-parse newcomment
multi-isearch parse-time vc-cvs log-edit pcvs-util add-log vc ediff-merg
ediff-diff ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff
vc-dispatcher skeleton reftex-vcr reftex-dcr reftex reftex-vars tex-mode
compile shell latexenc diary-lib diary-loaddefs cal-iso vc-git org-wl
org-w3m org-vm org-rmail org-mhe org-mew org-irc org-jsinfo org-infojs
org-html format-spec org-exp ob-exp org-exp-blocks org-info org-gnus
org-docview org-bibtex bibtex org-bbdb org-agenda org byte-opt warnings
bytecomp byte-compile cconv macroexp advice help-fns advice-preload
ob-emacs-lisp ob-tangle ob-ref ob-lob ob-table org-footnote org-src
ob-comint comint ring ob-keys ob ob-eval org-pcomplete pcomplete
org-list org-faces org-compat org-entities org-macs noutline outline
easy-mmode regexp-opt cal-menu easymenu calendar cal-loaddefs edmacro
kmacro paren time time-date tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)