From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ilya Zakharevich Newsgroups: gmane.emacs.devel Subject: [PATCH] 5x speedup of flyspell-buffer Date: Wed, 12 Apr 2023 06:50:30 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2401"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Apr 12 17:18:49 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmcFF-0000V6-NQ for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Apr 2023 17:18:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmcEf-0000Pr-Hc; Wed, 12 Apr 2023 11:18:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmars-0008F8-Qj for emacs-devel@gnu.org; Wed, 12 Apr 2023 09:50:36 -0400 Original-Received: from powdermilk.math.berkeley.edu ([169.229.140.13]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmarq-0007Q7-Dq for emacs-devel@gnu.org; Wed, 12 Apr 2023 09:50:36 -0400 Original-Received: by powdermilk.math.berkeley.edu (Postfix, from userid 5260) id EEA7712019C; Wed, 12 Apr 2023 06:50:30 -0700 (PDT) Content-Disposition: inline Received-SPF: none client-ip=169.229.140.13; envelope-from=serganov@math.berkeley.edu; helo=powdermilk.math.berkeley.edu X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 12 Apr 2023 11:18:11 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305272 Archived-At: 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))