From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74281: 30.0.91; font-lock mode hangs on scrolling large Scheme file Date: Sat, 28 Dec 2024 13:09:46 +0200 Message-ID: <86msggt66d.fsf@gnu.org> References: <8734k0cs1u.fsf@subvertising.org> <86zfm2jjbo.fsf@gnu.org> <865xo59hhm.fsf@gnu.org> <8634iqwqtr.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8482"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, 74281@debbugs.gnu.org To: divya@subvertising.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 28 12:10:25 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1tRUi9-00024L-3B for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Dec 2024 12:10:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRUhp-0006SH-Ka; Sat, 28 Dec 2024 06:10:05 -0500 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 1tRUho-0006Qo-7w for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2024 06:10:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tRUhn-0006Iw-OJ for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2024 06:10:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=pbzpIoK0vkfHVzf5XmgiHs25TFpmYtXLAiFj0wrI8Lo=; b=CzHHWXuiARserqaGElMbOu0EaOtQ3FTIktHoQ1c1zmaNmd7C5NKu697xwihgaRR07VEtLZuc4rpyo7eYDMwppieZecjCswiMZ7MHYbnvBFf+KHIR4tXj34SlYeu5WNyaWCZpsRIsEV+XS+03qRE31adNedCfRoO+w6APDkHMP/K+e/SWXOyqoiOITCOTzAjsXidxzJpUk8CzEaeWgctPgxdxxC16GSe39cKbm1+8IqQkiJxD42U+uOFZFtxYgOonaQGG1VOzQsOccoNCA9NfsLe3x773klpjiA7MWu8EModihMbAGhTYbSquqFRQ31Zc+OSx+Yb5x/WGBiNWyzgykw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tRUhn-0006Ri-Hr for bug-gnu-emacs@gnu.org; Sat, 28 Dec 2024 06:10:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Dec 2024 11:10:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74281 X-GNU-PR-Package: emacs Original-Received: via spool by 74281-submit@debbugs.gnu.org id=B74281.173538419724744 (code B ref 74281); Sat, 28 Dec 2024 11:10:03 +0000 Original-Received: (at 74281) by debbugs.gnu.org; 28 Dec 2024 11:09:57 +0000 Original-Received: from localhost ([127.0.0.1]:48956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRUhh-0006R1-5H for submit@debbugs.gnu.org; Sat, 28 Dec 2024 06:09:57 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRUhf-0006Qo-98 for 74281@debbugs.gnu.org; Sat, 28 Dec 2024 06:09:55 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tRUha-0006GU-2f; Sat, 28 Dec 2024 06:09:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=pbzpIoK0vkfHVzf5XmgiHs25TFpmYtXLAiFj0wrI8Lo=; b=i6MlimP/g0Ut rZGFJtl/XlO4/BQv0kJ/He5iioiMIlL3vWbHKQs2CtfMftxcOoN10NQezl4D2mqh3JziSSLMQoK14 H97YIbWd7NMc03q/SAHh+I1NAVYHlt8kQKu/tf0uSByEeLjfsZ7X0XEqk/1VzMXN5oVTzri09+YL1 OC1wgb5Izt55LCZjp2e3AjuQFK5nnbPy22XG7jRBiPuWeJ2/1g4EKNpQCoTKTZk+XymJiQCmRuQ/2 XcAg8Qi/EZLPbGbhh/vv9LGfq80tk9El/nCMAbJlvacli+I/1Zc5HVBw9TgLqTtNQJIhhkuIJJQme 7OLxJ2onRKkzz0Bvmk7TwA==; In-Reply-To: <8634iqwqtr.fsf@gnu.org> (message from Eli Zaretskii on Sat, 14 Dec 2024 11:34:40 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297874 Archived-At: Ping! Ping! Ping! Divya, please respond. > Cc: monnier@iro.umontreal.ca, 74281@debbugs.gnu.org > Date: Sat, 14 Dec 2024 11:34:40 +0200 > From: Eli Zaretskii > > Ping! Ping! Divya, are you there? > > > Cc: 74281@debbugs.gnu.org > > Date: Sat, 30 Nov 2024 11:51:49 +0200 > > From: Eli Zaretskii > > > > Ping! Divya, could you please try Stefan's suggestions and report > > back? > > > > > Cc: Divya Ranjan , 74281@debbugs.gnu.org > > > From: Stefan Monnier > > > Date: Thu, 14 Nov 2024 11:56:37 -0500 > > > > > > > Stefan, what tools do we have to investigate slowness related to > > > > parse-partial-sexp? Or maybe you have suggestions for how to speed up > > > > font-lock in this case? > > > > > > Hmm... `parse-partial-sexp` is normally expected to be fast, unless it > > > has to scan a lot of text. > > > > > > > Here's the profile I get while moving with C-p through the above file: > > > > > > A stab in the dark, but maybe the relevant call is the one in: > > > > > > (state (if (or syntax-ppss-table > > > (not font-lock--syntax-table-affects-ppss)) > > > (syntax-ppss start) > > > ;; If `syntax-ppss' doesn't have its own syntax-table and > > > ;; we have installed our own syntax-table which > > > ;; differs from the standard one in ways which affects PPSS, > > > ;; then we can't use `syntax-ppss' since that would pollute > > > ;; and be polluted by its cache. > > > (parse-partial-sexp (point-min) start))) > > > > > > so the origin of the slowdown would be the (?#. "w 14") in the setting > > > below in `scheme.el`: > > > > > > (setq font-lock-defaults > > > '((scheme-font-lock-keywords > > > scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) > > > nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) > > > beginning-of-defun > > > (font-lock-mark-block-function . mark-defun))) > > > > > > in which case, setting a `syntax-ppss-table` should fix the problem, tho > > > we could also fix it by being more careful: AFAICT the purpose of this > > > (?#. "w 14") is only to change the syntax of `#` from "prefix" to "word" > > > without changing the comment-related flags, so it shouldn't cause > > > `font-lock--syntax-table-affects-ppss` to be set. > > > So, we could solve it by improving the code that sets > > > `font-lock--syntax-table-affects-ppss`, as in the patch below. > > > > > > > > > Stefan > > > > > > > > > diff --git a/lisp/font-lock.el b/lisp/font-lock.el > > > index 203131bfd5a..f6299920c0a 100644 > > > --- a/lisp/font-lock.el > > > +++ b/lisp/font-lock.el > > > @@ -1955,14 +1955,15 @@ font-lock-set-defaults > > > (dolist (char (if (numberp (car selem)) > > > (list (car selem)) > > > (mapcar #'identity (car selem)))) > > > - (unless (memq (car (aref font-lock-syntax-table char)) > > > - '(1 2 3)) ;"." "w" "_" > > > - (setq font-lock--syntax-table-affects-ppss t)) > > > - (modify-syntax-entry char syntax font-lock-syntax-table) > > > - (unless (memq (car (aref font-lock-syntax-table char)) > > > - '(1 2 3)) ;"." "w" "_" > > > - (setq font-lock--syntax-table-affects-ppss t)) > > > - )))) > > > + (let ((old-syntax (aref font-lock-syntax-table char))) > > > + (modify-syntax-entry char syntax font-lock-syntax-table) > > > + (let ((new-syntax (aref font-lock-syntax-table char))) > > > + (unless (and (equal (cdr old-syntax) (cdr new-syntax)) > > > + (memq (logand (car old-syntax) 255) '(1 2 3 6)) > > > + (memq (logand (car new-syntax) 255) '(1 2 3 6)) > > > + (equal (ash (car old-syntax) -8) > > > + (ash (car new-syntax) -8))) > > > + (setq font-lock--syntax-table-affects-ppss t)))))))) > > > ;; (nth 4 defaults) used to hold `font-lock-beginning-of-syntax-function', > > > ;; but that was removed in 25.1, so if it's a cons cell, we assume that > > > ;; it's part of the variable alist. > > > > > > > > > > > > > > > > > > > > > > > > > > >