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: Sat, 13 Aug 2022 16:10:41 +0800	[thread overview]
Message-ID: <m2ilmwblzl.fsf@numbchild@gmail.com> (raw)
In-Reply-To: <87lers7i2x.fsf@localhost>


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


After applying this patch, seems deep level has improved.
I attched the profiler report in attachments.


[-- Attachment #1.2: cpu-profiler-report --]
[-- Type: application/emacs-lisp, Size: 50715 bytes --]

[-- Attachment #1.3: memory-profiler-report --]
[-- Type: application/emacs-lisp, Size: 278950 bytes --]

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



Ihor Radchenko <yantar92@gmail.com> writes:

> "Christopher M. Miles" <numbchild@gmail.com> writes:
>
>>          668  28%                                    - org-agenda-prepare-buffers
>> ...
>>          523  22%                                              - org--tag-add-to-alist
>
> I have a suspicion where the bottleneck is.
> Can you try the attached patch?
>
> From 1f5cdbd05c7012962ba3f12671805d77f52d836e Mon Sep 17 00:00:00 2001
> Message-Id: <1f5cdbd05c7012962ba3f12671805d77f52d836e.1660373309.git.yantar92@gmail.com>
> From: Ihor Radchenko <yantar92@gmail.com>
> Date: Sat, 13 Aug 2022 14:45:01 +0800
> Subject: [PATCH] org-agenda-prepare-buffers: Avoid quadratic behavior when
>  merging tags
>
> * lisp/org.el (org-agenda-prepare-buffers): Use the shortest list as
> the first argument in `org--tag-add-to-alist'.
>
> `org--tag-add-to-alist' is looping over the first argument.  When we
> use the accumulated tags as the first argument, each buffer tag will
> need to be looped over N_buffers/2 times on average, creating
> quadratic complexity.  Avoid this.
>
> Reported in https://orgmode.org/list/62f66552.050a0220.ed346.ac05SMTPIN_ADDED_BROKEN@mx.google.com
> ---
>  lisp/org.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 4eef56f45..b21bdf291 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -15196,8 +15196,8 @@ (defun org-agenda-prepare-buffers (files)
>  		 (append org-todo-keyword-alist-for-agenda org-todo-key-alist))
>  	   (setq org-tag-alist-for-agenda
>  		 (org--tag-add-to-alist
> -		  org-tag-alist-for-agenda
> -		  org-current-tag-alist))
> +		  org-current-tag-alist
> +                  org-tag-alist-for-agenda))
>  	   ;; Merge current file's tag groups into global
>  	   ;; `org-tag-groups-alist-for-agenda'.
>  	   (when org-group-tags
> -- 
> 2.35.1


-- 

[ 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-13  8:14 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
     [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 [this message]
     [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=m2ilmwblzl.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).