Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-12 Thread Ihor Radchenko
aroz...@gmail.com writes:

> Happy to. What is the best way to temporarily downgrade to 9.5.5? I install
> Emacs through this  Arch AUR
> package, which installs the latest version of Org automatically.

If you have Emacs 28, Org 9.5.5 is built-in there.
Or you can git clone Org repo, checkout release_9.5.5, and use it in
front of Emacs load-path when loading Emacs. See
https://orgmode.org/manual/Installation.html

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-12 Thread arozbiz
Happy to. What is the best way to temporarily downgrade to 9.5.5? I install
Emacs through this  Arch AUR
package, which installs the latest version of Org automatically.

Best,
Alan

On Mon, Dec 12, 2022 at 3:32 AM Ihor Radchenko  wrote:

> aroz...@gmail.com writes:
>
> > Thanks. It definitely helps, but it's still quite slow. What's made the
> > biggest difference is is advising the relevant functions to turn flyspell
> > off beforehand and then turn it back on.
>
> Sure, but it is not going to help others.
>
> Could you try to produce the profile using Org 9.5.5 and Org 9.6?
> I am wondering if there is anything in Org 9.6 that is slowed compared
> to Org 9.5.5.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-12 Thread Ihor Radchenko
aroz...@gmail.com writes:

> Thanks. It definitely helps, but it's still quite slow. What's made the
> biggest difference is is advising the relevant functions to turn flyspell
> off beforehand and then turn it back on.

Sure, but it is not going to help others.

Could you try to produce the profile using Org 9.5.5 and Org 9.6?
I am wondering if there is anything in Org 9.6 that is slowed compared
to Org 9.5.5.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Flyspell process called frequently when using Org export (was: Flyspell causes severe slowdown when manipulating footnotes)

2022-12-12 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Upon further investigation, Org frequently starts and kills the
> spellchecker when the document contains `LocalWords' comments.
>
> 1. Start Emacs
>
>emacs -Q
>
> 2. Configure Flyspell
>
>(add-hook 'text-mode-hook #'flyspell-mode)
>(add-hook 'prog-mode-hook #'flyspell-prog-mode)
>
> 3. Create a new Org file
>
># LocalWords: xyz
>
>Hello there!
>
> 4. Export the file to HTML
>
> Expected:
>
>   No Ispell process started on export.
>
> Actual:
>
>   A new Ispell process started on export.

Confirmed.
This is because `org-html-final-function' uses `mhtml-mode' to indent the
resulting html file. `mhtml-mode' unconditionally runs `prog-mode-hook'
thus starting Ispell.

We may try `delay-mode-hooks' around `set-auto-mode', but it is not
honoured by `mhtml-mode'. I guess we can report this as Emacs bug.

> P.S. I also see Org starting Ispell over and over when holding down
> `C-v' in a long document that contains lots of scattered `LocalWords'
> comments.

This sounds like a normal Ispell behaviour.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-11 Thread arozbiz
Thanks. It definitely helps, but it's still quite slow. What's made the
biggest difference is is advising the relevant functions to turn flyspell
off beforehand and then turn it back on.

```
(defun azr/org-footnote-disable-flyspell (orig-fun  args)
  (flyspell-mode -1)
  (apply orig-fun args)
  (flyspell-mode))

(advice-add 'org-footnote-new :around #'azr/org-footnote-disable-flyspell)
(advice-add 'org-footnote-delete :around
#'azr/org-footnote-disable-flyspell)
```

Best,
Alan

On Sat, Dec 10, 2022 at 4:24 AM Ihor Radchenko  wrote:

> aroz...@gmail.com writes:
>
> > Thanks Ihor for the response. Unfortunately, setting
> > org-element--cache-self-verify to nil didn't work. Profile report
> attached.
>
> Thanks!
> I just pushed a slight optimization to the footnote sorting code.
> Can you try again using the latest main?
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=169333e1c
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: Flyspell process called frequently when using Org export (was: Flyspell causes severe slowdown when manipulating footnotes)

2022-12-11 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Rudolf Adamkovič  writes:
>
>> Unrelated to the footnotes mentioned above
>
> Note how I change the email subject to mark a new topic.
> In Emacs, it is M-x message-change-subject

TIL!  Thank you.

> I am unable to reproduce using the latest Org.

I apologize for not providing a sequence of reproduction steps.

Upon further investigation, Org frequently starts and kills the
spellchecker when the document contains `LocalWords' comments.

1. Start Emacs

   emacs -Q

2. Configure Flyspell

   (add-hook 'text-mode-hook #'flyspell-mode)
   (add-hook 'prog-mode-hook #'flyspell-prog-mode)

3. Create a new Org file

   # LocalWords: xyz
   
   Hello there!

4. Export the file to HTML

Expected:

  No Ispell process started on export.

Actual:

  A new Ispell process started on export.

P.S. I also see Org starting Ispell over and over when holding down
`C-v' in a long document that contains lots of scattered `LocalWords'
comments.

Rudy
-- 
"The whole science is nothing more than a refinement of everyday
thinking."
-- Albert Einstein, 1879-1955

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Flyspell process called frequently when using Org export (was: Flyspell causes severe slowdown when manipulating footnotes)

2022-12-11 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Unrelated to the footnotes mentioned above

Note how I change the email subject to mark a new topic.
In Emacs, it is M-x message-change-subject

> ... , but I noticed that Org
> starts and kills Ispell all the time.  I see the following messages
> repeated over and over when working with Org:
>
>   Starting new Ispell process aspell with american dictionary...done
>   ...
>   Ispell process killed
>
> For the sake of experiment, I have just tried to export (to HTML) a
> subtree that contains nothing in it but a single BibTeX source block.
> Sure enough, Org started and killed a new Ispell process!
>
> P.S. I use Flyspell with the following (standard) configuration:
>
>   (add-hook 'after-init-hook
> (lambda ()
>   (add-hook 'text-mode-hook #'flyspell-mode)
>   (add-hook 'prog-mode-hook #'flyspell-prog-mode)))

I am unable to reproduce using the latest Org.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-10 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> I just pushed a slight optimization to the footnote sorting code.

Unrelated to the footnotes mentioned above, but I noticed that Org
starts and kills Ispell all the time.  I see the following messages
repeated over and over when working with Org:

  Starting new Ispell process aspell with american dictionary...done
  ...
  Ispell process killed

For the sake of experiment, I have just tried to export (to HTML) a
subtree that contains nothing in it but a single BibTeX source block.
Sure enough, Org started and killed a new Ispell process!

P.S. I use Flyspell with the following (standard) configuration:

  (add-hook 'after-init-hook
(lambda ()
  (add-hook 'text-mode-hook #'flyspell-mode)
  (add-hook 'prog-mode-hook #'flyspell-prog-mode)))

Rudy
-- 
"Strange as it may sound, the power of mathematics rests on its evasion
of all unnecessary thought and on its wonderful saving of mental
operations."
-- Ernst Mach, 1838-1916

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-10 Thread Ihor Radchenko
aroz...@gmail.com writes:

> Thanks Ihor for the response. Unfortunately, setting
> org-element--cache-self-verify to nil didn't work. Profile report attached.

Thanks!
I just pushed a slight optimization to the footnote sorting code.
Can you try again using the latest main?

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=169333e1c

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-08 Thread arozbiz
Thanks Ihor for the response. Unfortunately, setting
org-element--cache-self-verify to nil didn't work. Profile report attached.

On Wed, Dec 7, 2022 at 7:23 AM Ihor Radchenko  wrote:

> aroz...@gmail.com writes:
>
> > I just upgraded to Org 9.6 and I've noticed that having flyspell-mode
> > turned on causes very large slowdowns when adding or deleting footnotes
> in
> > an org file with lots of footnotes (e.g., more than 200, which is common
> > for the academic articles that I use org for). Any ideas for what might
> be
> > causing this?
>
> Most likely cache updates.
> Could you please (1) Set org-element--cache-self-verify to nil and see
> if things get back to normal; (2) If things are still slow after setting
> the variable, please run M-x profiler-start ... M-x profiler-report and
> share the data. See https://orgmode.org/list/87ee2nlslt.fsf@localhost.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>

[profiler-profile "28.1" cpu #s(hash-table size 217 test equal rehash-size 1.5 
rehash-threshold 0.8125 data ([nil nil nil nil nil nil nil nil nil nil nil nil 
nil nil nil nil] 37 [if "#" funcall let wc-count 
let* wc-mode-update setq progn if when "#" apply 
timer-event-handler nil nil] 131 ["#" funcall let 
wc-count let* wc-mode-update setq progn if when "#" apply 
timer-event-handler nil nil nil] 3 ["#" nil nil 
nil nil nil nil nil nil nil nil nil nil nil nil nil] 3 [file-truename 
file-truename file-truename file-truename org-roam-descendant-of-p 
org-roam-file-p org-roam-buffer-p if let azr/tab-bar-tab-name-current 
tab-bar-tabs tab-bar--current-tab-index doom-modeline-segment--workspace-name 
eval redisplay_internal\ \(C\ function\) nil] 3 [file-truename file-truename 
org-roam-descendant-of-p org-roam-file-p org-roam-buffer-p if let 
azr/tab-bar-tab-name-current tab-bar-tabs tab-bar--current-tab-find 
tab-bar--current-tab doom-modeline-segment--workspace-name eval 
redisplay_internal\ \(C\ function\) nil nil] 4 [file-relative-name 
org-roam-file-p org-roam-buffer-p if let azr/tab-bar-tab-name-current 
tab-bar-tabs tab-bar--current-tab-index doom-modeline-segment--workspace-name 
eval redisplay_internal\ \(C\ function\) nil nil nil nil nil] 3 
[doom-modeline-format--main eval redisplay_internal\ \(C\ function\) nil nil 
nil nil nil nil nil nil nil nil nil nil nil] 5 [org-roam-descendant-of-p 
org-roam-file-p org-roam-buffer-p if let azr/tab-bar-tab-name-current 
tab-bar--current-tab-make tab-bar--current-tab 
doom-modeline-segment--workspace-name eval redisplay_internal\ \(C\ function\) 
nil nil nil nil nil] 3 [org-roam-file-p org-roam-buffer-p if let 
azr/tab-bar-tab-name-current tab-bar--current-tab-make tab-bar--current-tab 
doom-modeline-segment--workspace-name eval redisplay_internal\ \(C\ function\) 
nil nil nil nil nil nil] 3 [org-roam-descendant-of-p org-roam-file-p 
org-roam-buffer-p if let azr/tab-bar-tab-name-current tab-bar-tabs 
tab-bar--current-tab-index doom-modeline-segment--workspace-name eval 
redisplay_internal\ \(C\ function\) nil nil nil nil nil] 3 
[org-roam-descendant-of-p org-roam-file-p org-roam-buffer-p if let 
azr/tab-bar-tab-name-current tab-bar-tabs tab-bar--current-tab-find 
tab-bar--current-tab doom-modeline-segment--workspace-name eval 
redisplay_internal\ \(C\ function\) nil nil nil nil] 3 ["#" org-element--parse-to org-element-at-point 
org-element-context org-footnote-action funcall-interactively command-execute 
nil nil nil nil nil nil nil nil nil] 4 [org-element-entity-parser 
org-element--object-lex org-element-context org-footnote-all-labels 
org-footnote-new org-footnote-action funcall-interactively command-execute nil 
nil nil nil nil nil nil nil] 4 [org-element-context org-footnote-all-labels 
org-footnote-new org-footnote-action funcall-interactively command-execute nil 
nil nil nil nil nil nil nil nil nil] 54 [org-footnote-new org-footnote-action 
funcall-interactively command-execute nil nil nil nil nil nil nil nil nil nil 
nil nil] 3 [rx--every rx--translate-or rx--translate-form rx--translate 
rx--translate-seq rx--translate-form rx--translate rx-to-string 
org-element--parse-generic-emphasis org-element-italic-parser 
org-element--object-lex org-element-context org-footnote-all-labels 
org-footnote-new org-footnote-action funcall-interactively] 3 
[org-element-at-point org-element-context org-footnote-all-labels 
org-footnote-new org-footnote-action funcall-interactively command-execute nil 
nil nil nil nil nil nil nil nil] 6 [org-element-footnote-reference-parser 
org-element--object-lex org-element-context org-footnote-all-labels 
org-footnote-new org-footnote-action funcall-interactively command-execute nil 
nil nil nil nil nil nil nil] 3 [font-lock-extend-jit-lock-region-after-change 
jit-lock-after-change org-footnote-new org-footnote-action 

Re: Flyspell causes severe slowdown when manipulating footnotes

2022-12-07 Thread Ihor Radchenko
aroz...@gmail.com writes:

> I just upgraded to Org 9.6 and I've noticed that having flyspell-mode
> turned on causes very large slowdowns when adding or deleting footnotes in
> an org file with lots of footnotes (e.g., more than 200, which is common
> for the academic articles that I use org for). Any ideas for what might be
> causing this?

Most likely cache updates.
Could you please (1) Set org-element--cache-self-verify to nil and see
if things get back to normal; (2) If things are still slow after setting
the variable, please run M-x profiler-start ... M-x profiler-report and
share the data. See https://orgmode.org/list/87ee2nlslt.fsf@localhost.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Flyspell causes severe slowdown when manipulating footnotes

2022-12-05 Thread arozbiz
I just upgraded to Org 9.6 and I've noticed that having flyspell-mode
turned on causes very large slowdowns when adding or deleting footnotes in
an org file with lots of footnotes (e.g., more than 200, which is common
for the academic articles that I use org for). Any ideas for what might be
causing this?

Alan