emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastian Wålinder" <s.walinder@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org-fold style text-properties slowdown
Date: Thu, 22 Jun 2023 10:30:51 +1000	[thread overview]
Message-ID: <87pm5oe3t0.fsf@nixos.mail-host-address-is-not-set> (raw)

Hello!

I write regularly in a massive org file ~160 000 lines, and experience progressive slowdowns as the buffer remains open when I have the setting `(setq org-fold-core-style 'text-properties)`.

When the file is first opened, all operations are very fast. But as I keep using, it keeps slowing down and eventually slows to a crawl where typing a single character takes several seconds. However, after closing the buffer and opening the file up again, the speed returns to normal.

With `(setq org-fold-core-style 'overlays)` in my `early-init.el`, I have no slowdown issue related to org-fold over time.

Running the CPU profiler while typing a few characters in the buffer yields me this report:
```
17969  99% - command-execute
17969  99%  - funcall-interactively
17956  99%   - org-self-insert-command
17940  99%    - org-fold-core--fix-folded-region
178   0%     - org-fold-core-next-folding-state-change
177   0%        #<compiled 0x72c2e0e7737b768>
42   0%     - org-fold-core-get-region-at-point
1   0%        org-fold-core--property-symbol-get-create
21   0%     - org-fold--reveal-outline-maybe
18   0%      - org-fold--reveal-headline-at-point
16   0%       - org-end-of-subtree
9   0%        - org-back-to-heading-or-point-min
8   0%         - org-before-first-heading-p
8   0%            org-element-at-point
1   0%           org-back-to-heading
6   0%          org-element-at-point
2   0%      - rx-to-string
2   0%       - rx--translate
2   0%        - rx--translate-form
1   0%         - rx--translate-or
1   0%            mapcan
1   0%     - org-fold-core-get-folding-spec
1   0%        org-fold-core--property-symbol-get-create
1   0%     - org-fold-core-region-folded-p
1   0%      - org-fold-core-get-folding-spec
1   0%         org-fold-core-get-folding-spec-from-alias
1   0%       #<compiled 0x1e4c54b2bcafef>
1   0%    - #<lambda 0x1e33d5fbace2c>
1   0%       let
1   0%    - org-element--cache-after-change
1   0%     - org-element--cache-submit-request
1   0%        org-element--cache-sync
3   0%   - my/system-hydra/profiler-stop-and-exit
3   0%    - hydra--call-interactively-remap-maybe
3   0%       funcall-interactively
3   0%   - evil-normal-state
1   0%    - evil-change-state
1   0%       evil-insert-state
3   0%   - my/system-hydra/profiler-report-and-exit
2   0%    - hydra--call-interactively-remap-maybe
2   0%       funcall-interactively
1   0%    - hydra-keyboard-quit
1   0%     - #<compiled 0x19801059c7c2>
1   0%      - message
1   0%       - apply
1   0%          mini-modeline--reroute-msg
1   0%   - evil-previous-line
1   0%    - evil-line-move
1   0%       line-move
1   0%   - my/system-hydra/body
1   0%    - my/hydra-pre-cursor
1   0%       evil-set-cursor-color
```
The memory profiler reports nothing significant. It appears `org-fold-core--fix-folded-region` is what's taking all the cycles. What's the best way for me to proceed debugging this? 

Setup:
`GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)`

`Org mode version 9.6.6 (release_9.6.6 @ /nix/store/q8adc2srnbipkahbwffwg006d09yk02g-emacs-git-20230618.0/share/emacs/30.0.50/lisp/org/)`

Thanks!
Sebastian


             reply	other threads:[~2023-06-22  0:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22  0:30 Sebastian Wålinder [this message]
2023-06-22 10:11 ` org-fold style text-properties slowdown 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=87pm5oe3t0.fsf@nixos.mail-host-address-is-not-set \
    --to=s.walinder@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 public 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).