all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Use cache in org-up-heading-safe
Date: Fri, 7 May 2021 00:02:19 +0700	[thread overview]
Message-ID: <s717et$s7h$1@ciao.gmane.io> (raw)
In-Reply-To: <87tung2aoq.fsf@localhost>

Though I still have not tested the patch, I think, it is an improvement 
and it is helpful in its current form. I am unable to tell if it follows 
code style.

Despite continuing discussion, I am unsure if it could be significantly 
better.

On 06/05/2021 21:34, Ihor Radchenko wrote:
> Maxim Nikulin writes:
>> In org-agenda.el org-up-heading-safe function is called only from
>> org-find-top-headline.
> 
> That's probably not the slowest part. org-agenda also calls
> org-up-heading-safe indirectly. In particular, org-get-tags is calling
> org-up-heading-safe to get inherited tags. It is org-get-tags that is
> taking >50% time of agenda generation in my agendas. And
> org-up-heading-safe was the largest contributor to that >50% time.

My bad, you mentioned tags earlier, but I grepped org-agenda.el only.
My new idea is that org-get-tags may have its own cache as well. Unsure 
if it should be tried.

> Scan through the whole buffer could be faster, but it is not always
> desired. Most of Org code only need information for current headline.
> Re-scanning the whole buffer would be costly.
> 
> Also, I tried to compare avl-tree with hash table. However, avl-tree
> does not give much benefit for my test case of an agenda with ~12000
> todo items. Since avl-tree requires much more custom code, hash table
> should be better.

Did you just replace gethash by avl-tree? Likely my idea is based on a 
wrong assumption. I hoped that having positions of headers it is 
possible to avoid jumps (goto-char ...) preceded or followed by regexp 
matching almost completely. Previous header for arbitrary initial 
position can be found using binary search through structure obtained 
during scan.

> +	                    (re-search-backward
> +                             (format "^\\*\\{1,%d\\} " level-up) nil t)
> +	                    (funcall outline-level))))

Unsure concerning the following optimization from the point of 
readability and reliability in respect to future modifications. Outline 
level can be derived from the length of matched string without the 
funcall requiring extra regexp.

If originally this code path had 50% contribution and performance 
already becomes several times better, further optimization of this part 
does not matter.



  reply	other threads:[~2021-05-06 17:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04 15:08 [PATCH] Use cache in org-up-heading-safe Ihor Radchenko
2021-05-05 16:40 ` Maxim Nikulin
2021-05-06 14:34   ` Ihor Radchenko
2021-05-06 17:02     ` Maxim Nikulin [this message]
2021-05-07  2:08       ` Ihor Radchenko
2021-05-08 11:28         ` Maxim Nikulin
2021-05-10 15:14           ` Ihor Radchenko
2021-05-15 11:58         ` Bastien
2021-05-16  6:15 ` Bastien
2021-05-16  6:36   ` Ihor Radchenko
2021-05-16  8:53     ` Bastien

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

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

  git send-email \
    --in-reply-to='s717et$s7h$1@ciao.gmane.io' \
    --to=manikulin@gmail.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.