1

In my current Emacs setup the org agenda takes a ridiculous amount of time to start up, up to 2 minutes. It happens both on Ubuntu and MacOS.

Version information:

  • Emacs: GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2018-02-18

  • Orgmode: Org mode version 9.1.6 (9.1.6-44-ge6f891-elpaplus @ /home/jx/.emacs.d/elpa/develop/org-plus-contrib-20180205/).

  • I'm using Spacemacs' develop branch.

However, this problem happens on both Ubuntu 16.04 LTS and the latest MacOS. Actually it has persisted for a very long period of time so I doubt if it's related to any particular Emacs/Org version.

The only information I was able to gather from the Messages buffer during start up is the following:

Using vacuous schema [2 times]
There is no ElDoc support in this buffer
Showing all blocks ... done
Using vacuous schema

I'm not sure why by starting up org agenda Emacs would have something to do with "ElDoc support" and "vacuous schema". It seems to me that those are something related to editing with some other programming languages instead of purely org mode.

Is there anything I configured wrong that I should try to improve? Are the above messages related to some #BEGIN_SRC blocks in the org files included in the agenda list? I don't think I would ever need source code blocks when I'm viewing an agenda buffer. How can I speed up the startup process? Or is it simply that I have too many files as org-agenda-files (currently dozens)? I'd think this amount of agenda files is still quite normal and there must be optimization that I can perform.

EDIT: I ran the elp profiling and here are the results:

Function Name, Call Count, Elapsed Time, Average Time

org-agenda                                                    1           116.6048159   116.6048159
org-agenda-list                                               1           116.29427357  116.29427357
org-agenda-prepare                                            1           109.15345470  109.15345470
org-agenda-prepare-buffers                                    1           108.98258905  108.98258905
org-agenda-get-day-entries                                    1288        7.0089191339  0.0054417074
org-agenda-get-scheduled                                      1288        3.726361062   0.0028931374
org-agenda-get-deadlines                                      1288        2.1579713230  0.0016754435
org-agenda--timestamp-to-absolute                             14544       1.1317418120  7.781...e-05
org-agenda-get-timestamps                                     1288        0.3673404320  0.0002852021
org-agenda-get-sexps                                          1288        0.3438970410  0.0002670008
org-agenda-get-restriction-and-command                        1           0.310503975   0.310503975
org-agenda-get-blocks                                         1288        0.3083237900  0.0002393818
org-agenda-prepare-window                                     1           0.157091024   0.157091024
org-agenda-skip                                               8624        0.0781296389  9.059...e-06
org-agenda-files                                              49          0.026090686   0.0005324629
org-agenda-finalize                                           1           0.013325178   0.013325178
org-agenda-mode                                               1           0.009848546   0.009848546
org-agenda-finalize-entries                                   23          0.006178961   0.0002686504
org-agenda-today-p                                            2604        0.0061717839  2.370...e-06
org-agenda-skip-eval                                          16968       0.0052723920  3.107...e-07
org-agenda-highlight-todo                                     112         0.0039840550  3.557...e-05
org-agenda-format-item                                        112         0.0038309749  3.420...e-05
org-agenda-new-marker                                         208         0.0031529359  1.515...e-05
org-agenda-format-date-aligned                                28          0.0007373120  2.633...e-05
org-agenda-add-time-grid-maybe                                28          0.0003810809  1.361...e-05
org-agenda-fix-displayed-tags                                 112         0.000342384   3.057e-06
org-agenda-fontify-priorities                                 1           0.00018465    0.00018465
org-agenda-align-tags                                         1           0.000160119   0.000160119
org-agenda-get-day-face                                       28          0.000156385   5.585...e-06
org-agenda-get-category-icon                                  112         7.702...e-05  6.877...e-07
org-agenda-span-name                                          23          4.4484e-05    1.934...e-06
org-agenda-span-to-ndays                                      1           2.3496e-05    2.3496e-05
org-agenda-fit-window-to-buffer                               1           2.0877e-05    2.0877e-05
org-agenda-time-of-day-to-ampm-maybe                          21          1.124...e-05  5.353...e-07
org-agenda-set-mode-name                                      1           9.226e-06     9.226e-06
org-agenda-mark-header-line                                   1           8.774e-06     8.774e-06
org-agenda-reset-markers                                      1           4.829e-06     4.829e-06
org-agenda-deadline-face                                      4           4.761e-06     1.19025e-06
org-agenda-update-agenda-type                                 1           1.575e-06     1.575e-06
org-agenda-ndays-to-span                                      2           1.174e-06     5.87e-07
org-agenda-mark-clocking-task                                 1           7.16e-07      7.16e-07
org-agenda-use-sticky-p                                       1           5.02e-07      5.02e-07

Not sure if this says much though.

  • In my setup, the initial search and/or skip function can have a lot to do with the speed at which data is gathered for the creation of *Org Agenda*. If you are using org-agenda-custom-commands, you can comment out certain criteria to see which setting causes the most time consumption and then determine whether anything can be tweaked. Of course, multiple agenda/todo blocks rolled into just one agenda command can also cause additional time delay. A longer span of time and multiple entries in the org agenda files can also cost more time to search. – lawlist Feb 6 '17 at 15:21
0

The standard answer to questions of this sort is: profile the code while executing the function that takes a long time. One way to do that is to say M-x elp-instrument package RET org RET, then create the agenda, then say M-x elp-results. That should give you an idea of where the time is spent and maybe a hint of where things are going wrong. If you are still stumped, I would urge you to post the profile to the org mode mailing list (and don't forget to mention version numbers for everything). BTW, elp is one profiler, but there is a built-in profile in emacs (see commands profiler-start, profiler-end and profiler-report) and there may be others.

  • I ran the profiler and posted the results in my question now, though I'm not sure if it says much. – xji Feb 18 '18 at 12:12
  • It says that org-agenda-prepare-buffers takes up the lion's share of the time, but all the other calls only contribute 15% of that time, so something is going on in org-agenda-prepare-buffers that is not captured by this profile. Can you please edit the question and add version information? M-x emacs-version and M-x org-version. If you are using old versions, you might want to upgrade. Otherwise, the next step might be to post this to the org-mode mailing list. – NickD Feb 18 '18 at 13:11
  • I updated the version information. Though the problem has always been there. I just didn't take time to deal with it. So I doubt whether it is version-specific. I thought I sent an email to the mailing list at emacs-orgmode@gnu.org but maybe I didn't do it correctly. I might try again later. – xji Feb 18 '18 at 17:01
  • The versions are recent, so that's OK. When you say "dozens" of files, how many files are you talking about? And did you try the suggestions that @lawlist made in the comment to your question? It might be a good idea to post the setting of your org-agenda-custom-commands (but I would encourage you to post - again if necssary - to the mailing list: your initial mail might have fallen through the cracks but the maintainer, Nicolas Goaziou, is very responsive in general and very interested in problematic behaviour, such as what you describe). – NickD Feb 18 '18 at 17:22
0

I finally found out the problem. I've been using Spacemacs and the spell-checking layer would automatically initiate flyspell on each org file, resulting in tremendous delay. If I disable flyspell from being automatically activated, the agenda is shown in a few seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.