Org-mode mailing list
 help / color / mirror / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Bug: fragile org refile cache
Date: Sat, 1 May 2021 21:48:39 +0700
Message-ID: <s6jpo8$ejb$1@ciao.gmane.io> (raw)
In-Reply-To: <877dklxecq.fsf@localhost>

On 29/04/2021 23:08, Ihor Radchenko wrote:
> 
> My experience is exactly opposite. Or maybe I miss something. Can you
> elaborate?

Some additions. org-outline-path-cache is used solely by 
org-refile-get-targets (maybe there are some calls in other packages) 
but it efficiency is questionable. It was not clear for me earlier that 
the cache is reset before each scan through a buffer. So if 
org-refile-use is disabled, org-outline-path-cache from previous run of 
org-refile or org-goto is not used as well. A query to 
org-outline-path-cache requires at least one backward search and hash 
lookup. During sequential scan in org-refile-get-targets it is enough to 
have previous heading path to update it when new heading is found. I 
think, org-outline-path-cache should be deprecated.

> Just cleanup heading text:

I have realized what is wrong with this benchmark. It runs so fast 
because it matches no headings, so it never spent time for cleaning them up.

> (benchmark-run 1
>    (goto-char (point-min))
>    (while (re-search-forward "^\\*+" nil t)
>      (let ((case-fold-search nil))

(beginning-of-line)
should be added before next call and (end-of-line) somewhere later in 
while body.

>        (looking-at org-complex-heading-regexp)
>        (if (not (match-end 4)) ""
> 	;; Remove statistics cookies.
> 	(org-trim
> 	 (org-link-display-format
> 	  (replace-regexp-in-string
> 	   "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
> 	   (match-string-no-properties 4)))))))) => (0.013364877 0 0.0)

On 29/04/2021 21:12, Ihor Radchenko wrote:
> For the cleaned heading text, I do not think that re-calculating the
> heading text on each change is a good idea. It may degrade typing
> latency. Yet, an acceptable approach could be simply invalidating cache
> for the changed headings. Then, outline paths can be re-calculated on
> changed headings when needed.

I agree that it is enough to invalidate cleaned heading on edit to 
refresh it in org-refile-get-targets. On the other hand, I still prefer 
text properties since they could be fetched even if some lines have been 
added or removed before. Position-based cache is useless in such cases.

Concerning typing latency, it should be postponed and resumed when no 
new edits is performed for certain period of time (~1s). However I am 
unsure if it is possible to accurately track all affected lines since 
later changes can add/remove lines before the line scheduled for 
invalidation.

On 30/04/2021 02:17, Tim Cross wrote:
> I suspect the reason it is not done automatically is that getting that
> right for all use cases is very hard to do without adding adverse impact
> to performance. A cache which is marked as 'dirty' too often results in
> too frequent cache refresh operations, but at the same time, determining
> what changes in an org file actually invalidate the cache can be a
> process intensive operation.

I believed that idea risen in this thread was to regenerate cache 
instead of spitting
"Please regenerate the refile cache with `C-0 C-c C-w'"
leaving more tricky cases for the user.



  parent reply	other threads:[~2021-05-01 14:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 16:09 Maxim Nikulin
2021-04-29  0:50 ` Samuel Wales
2021-04-29  1:29   ` Ihor Radchenko
2021-04-29  1:34     ` Samuel Wales
2021-04-29 12:45       ` Maxim Nikulin
2021-04-29 14:12         ` Ihor Radchenko
2021-04-29 15:04           ` Maxim Nikulin
2021-04-29 16:08             ` Ihor Radchenko
2021-04-29 16:51               ` Maxim Nikulin
2021-04-30 16:56               ` Maxim Nikulin
2021-05-01 14:48               ` Maxim Nikulin [this message]
2021-05-02  6:59                 ` Ihor Radchenko
2021-05-04 16:55                   ` Maxim Nikulin
2021-05-05  0:53                     ` Ihor Radchenko
2021-04-29 13:30       ` Ihor Radchenko
2021-04-29 19:17         ` Tim Cross
2021-04-29 22:43           ` Samuel Wales
2021-05-02  7:03           ` Ihor Radchenko

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://orgmode.org

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

  git send-email \
    --in-reply-to='s6jpo8$ejb$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

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git