Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs diagnosis: Org-mode unbearably slow and often stalls

My Emacs (GNU Emacs 25.1.1 (x86_64-w64-mingw32) under Windows 10 64-bit) has become unusably slow and choppy, especially in Org-mode, e.g. may pause for 2+ seconds to move the cursor and 3+ seconds to refresh to show an expanded tree.

Based on my benchmark-init report, I have done some downsizing by trimming content in my .emacs to reduce require and load statements, changing them into autoload hook or load after eval.

I have also completed a few profiler-report, some of the result looks difficult for me to interpret (e.g. 'line-move-visual' uses lots of memory), and I don't know what packages some of these processes below to and how to tweak and make changes to improve performance. Below is the partially expanded output for profiler-report (mem+cpu), while working on an .org file with around 1500 lines, thanks in advance!

(work.org at ~1500 lines)
- command-execute                                         259,247,035  98%
 - call-interactively                                     259,247,035  98%
  - funcall-interactively                                 259,142,758  98%
   - previous-line                                        203,846,889  77%
    - line-move                                           203,846,889  77%
     - line-move-visual                                    92,655,384  35%
      - posn-at-point                                           3,520   0%
         file-remote-p                                          3,520   0%
       window-inside-pixel-edges                               12,844   0%
   - org-cycle                                             46,120,698  17%
    - org-cycle-internal-local                             45,429,666  17%
     - run-hook-with-args                                  45,176,010  17%
      - org-optimize-window-after-visibility-change        41,890,667  15%
       - org-subtree-end-visible-p                         41,862,858  15%
        - pos-visible-in-window-p                           2,111,314   0%
         - jit-lock-function                                  153,338   0%
          - jit-lock-fontify-now                              150,304   0%
           - jit-lock--run-functions                          135,144   0%
            - run-hook-wrapped                                135,144   0%
             + #<compiled 0x2c09399>                          135,144   0%
             #<compiled 0x2cf3709>                             15,160   0%
           file-remote-p                                       18,898   0%
         + eval                                                 1,056   0%
          org-end-of-subtree                                    1,056   0%
       + recenter                                              21,840   0%
      + org-cycle-hide-archived-subtrees                       47,260   0%
        org-cycle-show-empty-lines                              9,232   0%
      + org-cycle-hide-drawers                                  2,936   0%
     + org-show-children                                       12,456   0%
       outline-next-heading                                     5,120   0%
     + org-show-entry                                           1,776   0%
     + outline-flag-region                                      1,520   0%
    + org-hide-block-toggle-maybe                             114,356   0%
    + run-hook-with-args-until-success                         11,744   0%
    + org-cycle-item-indentation                                6,198   0%
    + org-cycle-level                                           5,648   0%
      org-at-table-p                                            5,312   0%
   + execute-extended-command                               8,947,699   3%
   + next-line                                                227,472   0%
  + byte-code                                                 104,277   0%
+ redisplay_internal (C function)                           4,519,393   1%
+ elscreen-run-screen-update-hook                              17,698   0%
  internal-timer-start-idle                                     8,137   0%
+ timer-event-handler                                           2,000   0%
+ eldoc-schedule-timer                                          1,056   0%
  ...                                                               0   0%
like image 484
menuhin Avatar asked Nov 24 '16 19:11

menuhin


3 Answers

I found the package that is probably the main reason for the slowdown of Org-mode in my Emacs.

It is the package 'org-bullets' that has not been updated for 2+ years.

By removing its 'require' statement and all the subsequent related settings in my .emacs file, the Org-mode in my Emacs is getting back to state with usable responsiveness.

like image 179
menuhin Avatar answered Nov 11 '22 04:11

menuhin


I don't know if this is related to your issue, but i also had an extremely slow orgmode on windows, especially when building the agenda.

I found out that the following line solved that for me, when adding it to my big orgmode files:

#+STARTUP: showeverything
like image 42
sanenr9 Avatar answered Nov 11 '22 05:11

sanenr9


What helped me was changing undo-limit to 50. The default value is 80000 (on Mac which brew). Unless you really need any huge amount as default you should change that accordingly. For me 50 is good enough.

(setq undo-limit 50)

EDIT As @Phil pointed out, this variable is related to number of bytes kept in the history buffer. For most of the cases it should be bigger, to not corrupt "undo" feature. If that's an issue, try which value that works best for you.

like image 24
Navidot Avatar answered Nov 11 '22 05:11

Navidot