emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Kaushal Modi <kaushal.modi@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: Sun, 19 Dec 2021 17:47:22 +0800	[thread overview]
Message-ID: <87ee69rknp.fsf@localhost> (raw)
In-Reply-To: <CAFyQvY01nGvz7U24hx7y7PwuFf9vidJD7SE-T3FS8fpuYWZOGw@mail.gmail.com>

Kaushal Modi <kaushal.modi@gmail.com> writes:

>> 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?

Depends on your Emacs version. We had to disable the warning for
Emacs<28 because some internal Emacs staff sometimes caused
false-positives. However, if you tested using Emacs 28 or later, not
seeing the warning is suspicious.

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

Just 145k buffer should normally cause no performance issues on Org side
(on main). Even when you parse the whole buffer into AST. Problems begin
around 5-10Mb. Yet, my 15Mb notes file is perfectly usable :D

I looked through your `org-hugo--get-pre-processed-buffer':

1. org-element-copy should not be too much of an issue, unless you have
   many links. Yet, I am not sure why you need to use copy. You may as
   well modify the original element directly.

2. You call org-element-map twice making Org loop over the whole AST
   twice.

3. It is slightly more optimal to make your lambdas in org-element-map
   return nil. org-element-map allocates an extra list collecting all
   non-nil return values. If your lambda always returns nil, that list
   will not have to be created.

Having said that, my local benchmarking did not show that
org-hugo--get-pre-processed-buffer is a bottleneck. M-x profiler-start
mostly revealed slowness of org-hugo--org-babel-exp-code,
org-babel-expand-noweb-references, org-babel-sha1-hash, and
org-macro-replace-all. Can you also try M-x profiler and see what is the
bottleneck in your case?

Best,
Ihor


  reply	other threads:[~2021-12-19  9:46 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
2021-12-19  9:47                   ` Ihor Radchenko [this message]
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:
  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=87ee69rknp.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jmmathena@gmail.com \
    --cc=kaushal.modi@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/)]' \
    /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

Code repositories for project(s) associated with this 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).