all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ilya Zakharevich <ilya@ilyaz.org>
To: emacs-devel@gnu.org
Subject: [PATCH] 5x speedup of flyspell-buffer
Date: Wed, 12 Apr 2023 06:50:30 -0700	[thread overview]
Message-ID: <ZDa3JvahgwJErJRK@math.berkeley.edu> (raw)

With the included patch, on my system flyspell-buffer speeds up 5
times.  For my typical file sizes, this is 20sec -> 4sec on a 600K
LaTeX file with 10,000 words detected by `aspell´ — which makes
using flyspell feasible.

  The version is not the most recent, but IIUC, flyspell did not change.

(The number 1.05 below is chosen to lower overhead of messages 50 times,
from 5x to 0.1x.  It is related to log(10000)/0.05 ∼ 10000/50.)

Enjoy,
Ilya

--- 28.0.91/lisp/textmodes/flyspell.el-orig	2022-01-22 12:43:04.000000000 -0800
+++ 28.0.91/lisp/textmodes/flyspell.el	2023-04-12 06:31:39.836769300 -0700
@@ -1437,7 +1437,9 @@ The buffer to mark them in is `flyspell-
                              (if ispell-many-otherchars-p
                                  "*" "?")))
          (buffer-scan-pos flyspell-large-region-beg)
-         case-fold-search)
+         case-fold-search
+         (countw 0)
+         (countw-rep 0))
     (with-current-buffer flyspell-external-ispell-buffer
       (goto-char (point-min))
       ;; Loop over incorrect words, in the order they were reported,
@@ -1450,10 +1452,13 @@ The buffer to mark them in is `flyspell-
 	  ;; identical words, and the loop below would search for that many.
 	  ;; That code seemed to be incorrect, and on principle, should
 	  ;; be unnecessary too. -- rms.
-	  (if flyspell-issue-message-flag
-	      (message "Spell Checking...%d%% [%s]"
-		       (floor (* 100.0 (point)) (point-max))
-		       word))
+	  (setq countw (1+ countw))
+	  (when (and flyspell-issue-message-flag
+		     (> countw (* 1.05 countw-rep)))
+	    (setq countw-rep countw)
+	    (message "Spell Checking...%d%% [%s]"
+		     (floor (* 100.0 (point)) (point-max))
+		     word))
 	  (with-current-buffer flyspell-large-region-buffer
 	    (goto-char buffer-scan-pos)
 	    (let ((keep t))



             reply	other threads:[~2023-04-12 13:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 13:50 Ilya Zakharevich [this message]
2023-04-13  6:54 ` [PATCH] 5x speedup of flyspell-buffer Eli Zaretskii
2023-04-13 10:23   ` Ilya Zakharevich
2023-04-13 10:32     ` Eli Zaretskii
2023-04-13 20:29       ` Ilya Zakharevich
2023-04-14  5:47         ` Eli Zaretskii
2023-04-14  6:39           ` Dr. Arne Babenhauserheide
2023-04-14  6:54             ` Eli Zaretskii
2023-04-15  1:51     ` interacting during (sit-for 0). Was: " Ilya Zakharevich
2023-04-15  2:01       ` Ilya Zakharevich

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZDa3JvahgwJErJRK@math.berkeley.edu \
    --to=ilya@ilyaz.org \
    --cc=emacs-devel@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.