emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: numbchild@gmail.com
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [ISSUE] org-mode fill paragraph is slow and suspend often
Date: Tue, 26 Oct 2021 16:21:57 +0800	[thread overview]
Message-ID: <87cznsnql6.fsf@localhost> (raw)
In-Reply-To: <PAXPR08MB66400699DACEB31F4F0650F1A3849@PAXPR08MB6640.eurprd08.prod.outlook.com>

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

"Christopher M. Miles" <numbchild@gmail.com> writes:

> Emacs often suspend for a long time.
> ...
>         1467  26%                       - org-element--cache-sync
> ...
>         1334  23%                              - catch
>         1332  23%                               - and
>         1332  23%                                - org-indent-add-properties

Thanks for reporting!
It looks like competing catch..throw.  Both org-indent and org-element
are using `interrupt' signals.

Can you try the attached patch and report back?

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element-cache-Rename-interrupt-org-element-cache.patch --]
[-- Type: text/x-diff, Size: 4808 bytes --]

From cb0a73d58d429b62576822a98235a6bd3ff85809 Mon Sep 17 00:00:00 2001
Message-Id: <cb0a73d58d429b62576822a98235a6bd3ff85809.1635236424.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Tue, 26 Oct 2021 16:14:40 +0800
Subject: [PATCH] org-element-cache: Rename `interrupt'
 `org-element--cache-interrupt'

* lisp/org-element.el (org-element--cache-sync,
org-element--cache-process-request, org-element--parse-to): Some other
code (at least, `org-indent-mode') is using `interrupt' signal in
`after-change-functions'.  Rename `interrupt' signal used in
org-element-cache to unique `org-element--cache-interrupt'.

Reported in https://list.orgmode.org/PAXPR08MB66400699DACEB31F4F0650F1A3849@PAXPR08MB6640.eurprd08.prod.outlook.com/T/#u
---
 lisp/org-element.el | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index acc6c56c2..33c7a4051 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -5818,7 +5818,7 @@ (defun org-element--cache-sync (buffer &optional threshold future-change)
 	  (when org-element--cache-sync-timer
 	    (cancel-timer org-element--cache-sync-timer))
           (let ((time-limit (time-add nil org-element-cache-sync-duration)))
-	    (catch 'interrupt
+	    (catch 'org-element--cache-interrupt
               (when org-element--cache-sync-requests
                 (org-element--cache-log-message "Syncing down to %S-%S" (or future-change threshold) threshold))
 	      (while org-element--cache-sync-requests
@@ -5877,8 +5877,8 @@ (defun org-element--cache-process-request
 not registered yet in the cache are going to happen.  See
 `org-element--cache-submit-request' for more information.
 
-Throw `interrupt' if the process stops before completing the
-request."
+Throw `org-element--cache-interrupt' if the process stops before
+completing the request."
   (org-element--cache-log-message "org-element-cache: Processing request %s up to %S-%S, next: %S"
                        (let ((print-length 10) (print-level 3)) (prin1-to-string request))
                        future-change
@@ -5899,7 +5899,7 @@ (defun org-element--cache-process-request
           (while t
 	    (when (org-element--cache-interrupt-p time-limit)
               (org-element--cache-log-message "Interrupt: time limit")
-	      (throw 'interrupt nil))
+	      (throw 'org-element--cache-interrupt nil))
 	    (let ((request-key (org-element--request-key request))
 		  (end (org-element--request-end request))
 		  (node (org-element--cache-root))
@@ -6012,7 +6012,7 @@ (defun org-element--cache-process-request
       (let ((limit (+ (org-element--request-beg request) (org-element--request-offset request))))
 	(cond ((and threshold (> limit threshold))
                (org-element--cache-log-message "Interrupt: position %d after threshold %d" limit threshold)
-               (throw 'interrupt nil))
+               (throw 'org-element--cache-interrupt nil))
 	      ((and future-change (>= limit future-change))
 	       ;; Changes happened around this element and they will
 	       ;; trigger another phase 1 request.  Skip re-parenting
@@ -6086,7 +6086,7 @@ (defun org-element--cache-process-request
                 (org-element--cache-log-message "Interrupt: %s" (if exit-flag "threshold" "time limit"))
                 (setf (org-element--request-key request) key)
                 (setf (org-element--request-parent request) parent)
-                (throw 'interrupt nil))
+                (throw 'org-element--cache-interrupt nil))
 	      ;; Shift element.
 	      (unless (zerop offset)
                 (when (>= org-element--cache-diagnostics-level 3)
@@ -6207,8 +6207,9 @@ (defun org-element--parse-to (pos &optional syncp time-limit)
 When optional argument SYNCP is non-nil, return the parent of the
 element containing POS instead.  In that case, it is also
 possible to provide TIME-LIMIT, which is a time value specifying
-when the parsing should stop.  The function throws `interrupt' if
-the process stopped before finding the expected result."
+when the parsing should stop.  The function throws
+`org-element--cache-interrupt' if the process stopped before finding
+the expected result."
   (catch 'exit
     (save-match-data
       (org-with-wide-buffer
@@ -6280,7 +6281,7 @@ (defun org-element--parse-to (pos &optional syncp time-limit)
 	       (parent (org-element-property :parent element)))
            (while t
 	     (when (org-element--cache-interrupt-p time-limit)
-               (throw 'interrupt nil))
+               (throw 'org-element--cache-interrupt nil))
              (when (and inhibit-quit org-element--cache-interrupt-C-g quit-flag)
                (when quit-flag
 	         (cl-incf org-element--cache-interrupt-C-g-count)
-- 
2.32.0


  reply	other threads:[~2021-10-26  8:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26  6:18 [ISSUE] org-mode fill paragraph is slow and suspend often Christopher M. Miles
2021-10-26  8:21 ` Ihor Radchenko [this message]
2021-10-27 14:34   ` Christopher M. Miles
2021-10-27 15:16     ` Ihor Radchenko
2021-10-28  3:23       ` [SOLVED] " Christopher M. Miles

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=87cznsnql6.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=numbchild@gmail.com \
    /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).