bastibe / org-journal

A simple org-mode based journaling mode
BSD 3-Clause "New" or "Revised" License
1.23k stars 122 forks source link

org-schedule slow due to org-journal-mark-entries #394

Closed fleimgruber closed 2 years ago

fleimgruber commented 2 years ago

Emacs 27.2 org-mode 9.5.3 org-journal 20210417.1612

As mentioned in issue title, org-schedule takes about 5-10 seconds for the calendar to be responsive. Most of the time is spent in org-journal-mark-entries, see these CPU profiler results:

- command-execute                                               20139  87%
 - call-interactively                                           20138  87%
  - funcall-interactively                                       20138  87%
   - org-schedule                                               20133  87%
    - org--deadline-or-schedule                                 20133  87%
     - #<compiled 0x1a115c5>                                    20133  87%
      - org-add-planning-info                                   20130  87%
       - org-read-date                                          20129  87%
        - calendar                                              19747  86%
         - calendar-basic-setup                                 19747  86%
          - calendar-generate-window                            19725  86%
           - #<compiled 0x781192d>                              19249  83%
            - run-hooks                                         19249  83%
             - org-journal-mark-entries                         19249  83%
              - org-journal--list-dates                         19249  83%
               - org-journal--list-files                        19248  83%
                - seq-filter                                    13007  56%
                 - seq-map                                      13007  56%
                  - apply                                       13007  56%
                   - #<compiled 0x7fd36d>                       13007  56%
                    - mapcar                                    12997  56%
                     - #<compiled 0x5d2e6e5>                    12978  56%
                      - #<compiled 0x1329be1>                   12929  56%
                       - org-journal--dir-and-file-format->pattern              12454  54%
                        - file-truename                          9100  39%
                         - file-truename                         5374  23%
                            file-truename                        2087   9%
                        - org-journal--format->regex               2762  12%
                         - replace-regexp-in-string               2230   9%
                            apply                                 195   0%
                            #<compiled 0x1fc2c2dedeef>                 55   0%
...

Any ideas on what might going on here? How to further debug this?

fleimgruber commented 2 years ago

As a workaround I do (remove-hook 'calendar-today-visible-hook 'org-journal-mark-entries).

bastibe commented 2 years ago

That's weirdly slow. What operating system are you using, how many journal files do you have, and what journal mode are you using (daily, weekly, monthly)?

For reference, my a-few-thousand-files journal renders the calendar almost instantly on Windows (slow!) and Linux.

fleimgruber commented 2 years ago

What operating system are you using

I am Windows and Linux, it is slightly slower under Windows.

how many journal files do you have

The org-journal-dir has about 300 files beneath it (recursively).

what journal mode are you using (daily, weekly, monthly)?

yearly.

For reference, my a-few-thousand-files journal renders the calendar almost instantly on Windows (slow!) and Linux.

I don't understand "almost instantly" together with "slow!".

I see how this might be hard to debug / reproduce - for me the workaround is ok as I don't use that calendar feature. Please proceed with this issue as you see fit, it is solved for me.

bastibe commented 2 years ago

Please reopen if you'd like to continue this discussion.