emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>,
	John Mathena <jmmathena@gmail.com>
Subject: Re: [BUG] org-element--cache gives "Unregistered buffer modifications" warning [9.5 (9.5-g859984 @ /home/john/.emacs.d/straight/build/org/)]
Date: Sat, 18 Dec 2021 12:43:26 -0500	[thread overview]
Message-ID: <CAFyQvY01nGvz7U24hx7y7PwuFf9vidJD7SE-T3FS8fpuYWZOGw@mail.gmail.com> (raw)
In-Reply-To: <878rwiil7c.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 2893 bytes --]

On Fri, Dec 17, 2021 at 11:34 PM Ihor Radchenko <yantar92@gmail.com> wrote:

> > There's a setup included in there; I forgot about that. If you don't mind
> > trying it again, this would download everything needed:
> Thanks! I was able to follow your steps this time.

I really appreciate making this extra effort to help me out. Thanks!

> > Sorry, but I am getting similar backtrace in another function now:
> Sigh... Should be fixed now. I did not expect that arguments to cache
> functions could ever be markers.
> After the fix, I was able to see the warning you were talking about in
> the earlier email. Your test case revealed an important omission in the
> cache logic when a huge number of edits are stacked together into
> asynchronous cache queue. Thanks you for providing the excellent
> reproducer!

No problem! The ox-hugo tests end up indirectly testing a lot of Org
features :D

> On latest main, your example file is exported without any warnings.

I just verified that. Also, I did not even need to add
`(org-element-cache-reset)' in `org-hugo--get-pre-processed-buffer' after
the `(insert ..)' in the temp buffer.

Is that expected?

Also, I noticed that now the exports are much more snappier than before!

Also, I noticed that the large number of edits makes the cache use a lot
> of memory adding load onto the Emacs garbage collector. May I know what
> exactly ox-hugo does that triggers that many edits? Exporting your
> example files took approximately 30sec on my system (both with and
> without cache). I believe that the speed can be improved if cache is
> used more optimally.

That command exports 81 subtrees (as of now) from ox-hugo-manual.org to
independent Markdown files.

That said, I think that `org-hugo--get-pre-processed-buffer' [1] is the
performance bottleneck. It was added so that Org subtree exports can work
even if one subtree has an internal link to a different subtree in the same

The pre processing logic slurps up the AST of the whole Org buffer, does
org-element-copy on all the link org-elements to point to a place outside
the exported subtree, fixes that link so that the export works, and copies
the modified link element back on the original element. And then the whole
Org temp buffer is overwritten with the modified AST.
And then.. the subtree export happens from there.

This is the only way possible as far as I know to support cross-subtree
links. Credit for this implementation goes to Folkert van der Beek[2].

Let me know if you have any suggestions to improve the performance. I think
that the org-element-copy and writing the huge AST to temp Org buffer is
keeping the GC busy (the ox-hugo-manual.org is about 3700 lines right now).


[2]: https://github.com/kaushalmodi/ox-hugo/pull/280

[-- Attachment #2: Type: text/html, Size: 4338 bytes --]

  reply	other threads:[~2021-12-18 17:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-07 20:22 John Mathena
2021-11-08  5:59 ` Ihor Radchenko
2021-12-16  2:29   ` Kaushal Modi
2021-12-16  2:34     ` Kaushal Modi
2021-12-16  4:20       ` Ihor Radchenko
2021-12-16 14:33         ` Kaushal Modi
2021-12-16 15:18           ` Ihor Radchenko
2021-12-16 16:16             ` Kaushal Modi
2021-12-18  4:35               ` Ihor Radchenko
2021-12-18 17:43                 ` Kaushal Modi [this message]
2021-12-19  9:47                   ` Ihor Radchenko
2022-04-24  3:37                 ` Difference seen in org-version strings when built from git Kaushal Modi
2022-04-24  3:59                   ` Ihor Radchenko
2022-01-06 11:17 ` [BUG] org-element--cache gives "Unregistered buffer modifications" warning [9.5 (9.5-g859984 @ /home/john/.emacs.d/straight/build/org/)] Karl Voit
2022-01-06 12:25   ` 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:

  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=CAFyQvY01nGvz7U24hx7y7PwuFf9vidJD7SE-T3FS8fpuYWZOGw@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jmmathena@gmail.com \
    --cc=yantar92@gmail.com \
    --subject='Re: [BUG] org-element--cache gives "Unregistered buffer modifications" warning [9.5 (9.5-g859984 @ /home/john/.emacs.d/straight/build/org/)]' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


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).