emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Morgan Smith <Morgan.J.Smith@outlook.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-clock-sum: Rewrite function to improve performance
Date: Thu, 20 Jul 2023 07:46:27 +0000	[thread overview]
Message-ID: <87bkg7xbxo.fsf@localhost> (raw)
In-Reply-To: <DM5PR03MB31630410C392C7B706E0488DC539A@DM5PR03MB3163.namprd03.prod.outlook.com>

Morgan Smith <Morgan.J.Smith@outlook.com> writes:

> I have a very big file with lots of clock entries and refreshing my clocktable
> has become slow.  Using '(benchmark-elapse (org-ctrl-c-ctrl-c))' I saw that it
> took 5.660532903 seconds to refresh it!  After this rewrite it only takes
> 3.384914703 seconds.  Not great, but better.

Thanks, but the approach you used is questionable.
You are forcing Org to parse the whole buffer as opposed to the existing
approach with parsing only the necessary parts.

While I do see how your implementation might be faster for certain Org
files (many clock entries, little other elements), but I do not see how
it can be faster in general case.

May you instead share the benchmark data for the original Org's code on
your file?

1. M-x profiler-start <RET> cpu <RET>
2. Generate the clock table
3. M-x profiler-report <RET>
4. M-x profiler-report-write-profile
5. Share the saved profile file

P.S.

I did a benchmark on another large buffer and with the existing
implementation I am getting (first column is time in ms):

       15989  58%                                              - org-clock-sum
       15837  58%                                               - org-element-at-point
       15517  56%                                                + org-element--parse-to

With your code

       27347  87%                                   - org-clock-sum
       27347  87%                                    - let*
       27347  87%                                     - unwind-protect
       27347  87%                                      - progn
       27347  87%                                       - let*
       27310  87%                                        - org-element-map
       27230  87%                                         + org-element-parse-buffer

and the code is not yet even done, stopping processing due to error.

Further, you dropped the

	     ((match-end 4)
	      ;; A naked time.

branch of the code, which accounts for CLOCK: => HH:MM lines that are not clock elements.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


      reply	other threads:[~2023-07-20  7:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 21:35 [PATCH] org-clock-sum: Rewrite function to improve performance Morgan Smith
2023-07-20  7:46 ` Ihor Radchenko [this message]

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=87bkg7xbxo.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=Morgan.J.Smith@outlook.com \
    --cc=emacs-orgmode@gnu.org \
    /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).