emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Christopher M. Miles" <numbchild@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: "Christopher M. Miles" <numbchild@gmail.com>,
	Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PERFORMANCE] Why some org code is so deep invoked?
Date: Fri, 12 Aug 2022 22:12:33 +0800	[thread overview]
Message-ID: <m28rntr1ik.fsf@numbchild@gmail.com> (raw)
In-Reply-To: <87h72h8v1j.fsf@localhost>


[-- Attachment #1.1: Type: text/plain, Size: 2118 bytes --]


Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>>> I do not see much issue with deep nesting of the code.
>>
>> Is this deep nested code normal in Emacs Lisp?
>>
>> Usually (based on my less than 20 times profiling experience), Emacs
>> wouldn't have deeper code than 40 levels. But my attachment profiler
>> report has more than 100 levels.
>>
>> If this is normal and fine, It's OK. I repeat, I ask this question for
>> curious purpose which want to get an answer for not important question.
>
> It depends. You are looking at the complex code here, which is not
> necessarily common.
>
> However, lisp nesting is tangent to performance. Shallow nesting can be
> slow while deep nesting can be fast. Or vice versa.
>
I see, thanks for answering.

>>> Could you please clarify what exactly is your problem?
>>> Is agenda generation slow?
>>
>> From the profiler report, you can see that Agenda is slow on clock table
>> generation because I have ~org-agenda-start-with-clockreport-mode~
>> enabled. And this deep code invocation is from it too. It's about 5
>> seconds to generate the org-agenda clock table. Actually I can tolerate
>> this time, Just found this performance issue when profiling and curious
>> to ask this question.
>
> Note that your profiler result does not look like taken from a 5
> second-lasting code:
>
>          390  13%     - completing-read
>
> Completing read takes >10% *CPU time* of the 5 seconds? Suspicious. I'd
> retry to get the profile.

I re-profiled three times, around 4 seconds.

>
> Also, I suggest to use M-x write-file in the profiler buffer when
> sharing something as deeply nested as you got. The resulting file is
> much more comfortable to view - it will preserve all the actual profiler
> data.

I see, I tried it, it indeed kept the profiler data!

>
> I will refrain from trying to deduce anything from the profiler for now.
>
> Please try to reproduce the report again and share it with us. Then, I
> will try to see if we can do anything on the Org side.

Ok, I attached the new generated profiler reports.


[-- Attachment #1.2: profiler-cpu-report-2.log --]
[-- Type: text/plain, Size: 152 bytes --]

        1284  57% + command-execute
         935  41% + ...
          21   0% + timer-event-handler
           2   0% + redisplay_internal (C function)

[-- Attachment #1.3: profiler-memory-report-2.log --]
[-- Type: text/plain, Size: 2528 bytes --]

    410,957,330  97% - command-execute
    410,957,330  97%  - call-interactively
    405,537,622  95%   - funcall-interactively
    331,652,432  78%    - org-agenda-redo-all
    331,652,432  78%     - if
    331,651,376  78%      - org-agenda-redo
    331,651,376  78%       - let*
    331,649,112  78%        - if
    331,649,112  78%         - progn
    331,649,112  78%          - let*
    331,649,112  78%           - eval
    331,649,112  78%            - let
    331,649,112  78%             - funcall
    331,649,112  78%              - #<lambda -0x196502c669cdd461>
    331,649,112  78%               - eval
    331,649,112  78%                - org-agenda-list
    331,649,112  78%                 - catch
    299,277,191  70%                  - let*
    213,251,714  50%                   - if
    213,105,362  50%                    - progn
    213,105,362  50%                     - let
    212,941,062  50%                      - setq
    212,940,006  50%                       - apply
    212,940,006  50%                        - org-clock-get-clocktable
    212,940,006  50%                         + let
          1,056   0%                       + org-plist-delete
        124,712   0%                      + org-agenda-files
         16,584   0%                        insert
          7,764   0%                      + if
         58,632   0%                    + or
         19,576   0%                    + if
          3,136   0%                    + let*
     78,430,580  18%                   + while
      7,306,892   1%                   + org-agenda-finalize
        148,040   0%                     add-text-properties
        139,819   0%                   + org-agenda-files
             48   0%                   + org-today
     32,366,705   7%                  + org-agenda-prepare
          4,160   0%                  + org-compile-prefix-format
          1,024   0%        + or
          1,056   0%      + turn-on-ligature-mode
     35,958,904   8%    + eyebrowse-create-window-config
     30,440,458   7%    + org-agenda
      6,646,049   1%      delete-window
        839,779   0%    + execute-extended-command
      5,419,708   1%   + byte-code
     11,917,712   2% + redisplay_internal (C function)
        280,655   0% + ...
          1,984   0% + timer-event-handler
          1,152   0% + corfu--auto-post-command
             80   0%   flyspell-post-command-hook
             80   0% + indent-guide-pre-command-hook
             80   0% + flycheck-maybe-display-error-at-point-soon

[-- Attachment #1.4: Type: text/plain, Size: 269 bytes --]



-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2022-08-12 14:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <62f5a905.c80a0220.1f07b.ffaeSMTPIN_ADDED_BROKEN@mx.google.com>
2022-08-12  1:51 ` [PERFORMANCE] Why some org code is so deep invoked? Ihor Radchenko
2022-08-12 12:14   ` Christopher M. Miles
     [not found]   ` <62f64617.050a0220.b0be5.b717SMTPIN_ADDED_BROKEN@mx.google.com>
2022-08-12 12:51     ` Bill Burdick
2022-08-12 14:16       ` Christopher M. Miles
     [not found]   ` <62f645de.050a0220.ff872.76ffSMTPIN_ADDED_BROKEN@mx.google.com>
2022-08-12 13:12     ` Ihor Radchenko
2022-08-12 14:12       ` Christopher M. Miles [this message]
     [not found]       ` <62f660a5.1f0a0220.73d8b.c78bSMTPIN_ADDED_BROKEN@mx.google.com>
2022-08-12 14:23         ` Ihor Radchenko
2022-08-12 14:30       ` Christopher M. Miles
     [not found]       ` <62f66552.050a0220.ed346.ac05SMTPIN_ADDED_BROKEN@mx.google.com>
2022-08-13  6:50         ` Ihor Radchenko
2022-08-13  8:10           ` Christopher M. Miles
     [not found]           ` <62f75d06.c80a0220.460f4.cc42SMTPIN_ADDED_BROKEN@mx.google.com>
2022-08-13  8:48             ` Ihor Radchenko
2022-08-13 13:48               ` Christopher M. Miles
2022-08-12  0:26 Christopher M. Miles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m28rntr1ik.fsf@numbchild@gmail.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).