From: Ihor Radchenko <yantar92@gmail.com>
To: "Christopher M. Miles" <numbchild@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PERFORMANCE] Why some org code is so deep invoked?
Date: Sat, 13 Aug 2022 14:50:30 +0800 [thread overview]
Message-ID: <87lers7i2x.fsf@localhost> (raw)
In-Reply-To: <62f66552.050a0220.ed346.ac05SMTPIN_ADDED_BROKEN@mx.google.com>
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
"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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda-prepare-buffers-Avoid-quadratic-behavior-.patch --]
[-- Type: text/x-patch, Size: 1428 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 207 bytes --]
--
Ihor Radchenko,
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
next prev parent reply other threads:[~2022-08-13 6:51 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 [this message]
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=87lers7i2x.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=numbchild@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).