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, 30 Nov 2024 11:51:49 +0200 Message-ID: <865xo59hhm.fsf@gnu.org> References: <8734k0cs1u.fsf@subvertising.org> <86zfm2jjbo.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8603"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74281@debbugs.gnu.org To: divya@subvertising.org, Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 30 10:52:15 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 1tHK98-00026T-E4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Nov 2024 10:52:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tHK8y-0007hB-KW; Sat, 30 Nov 2024 04:52:04 -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 1tHK8w-0007gu-Gx for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 04:52:02 -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 1tHK8w-00068P-83 for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 04:52:02 -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=cb02+qPoHhtgiIwF+YYOEh3cyskynX5L7YjzhXvmlTs=; b=SY53Y1y/B8RxvNZZ15GMfC77b6Z72ayU8sOaK8KawLrop0C24UqiJR5/yOeZjRESCgtZybWgXN7KP+GuIsCcWlmTaKRiLmZyHjln2QTECa171o5VG2wSmG37LhOsAN/MXDA+L5q9OVWs14CAm7mWVetIodmVI3Ne3LrFmVz1sYIRRKiPCBw1jxC0UqTC0QRGlanXjFm+TOkuoN9vLh9knj98kQohZSaxsbcx9auGcRYfB9TvqRe2TWT8hjIuUcgzAYzOBEWLIE3fAkyqvOKrVhfcl1gTHKk2zpRGzZEEjWsw7/eqn5rpVdW+717x5KtJ96D0mE/3nCpycX3tRGU6Hw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tHK8w-0006cK-2D for bug-gnu-emacs@gnu.org; Sat, 30 Nov 2024 04:52:02 -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, 30 Nov 2024 09:52:02 +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.173296032025426 (code B ref 74281); Sat, 30 Nov 2024 09:52:02 +0000 Original-Received: (at 74281) by debbugs.gnu.org; 30 Nov 2024 09:52:00 +0000 Original-Received: from localhost ([127.0.0.1]:45463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHK8t-0006c1-Km for submit@debbugs.gnu.org; Sat, 30 Nov 2024 04:52:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHK8s-0006bi-0A for 74281@debbugs.gnu.org; Sat, 30 Nov 2024 04:51:58 -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 1tHK8m-00064P-OI; Sat, 30 Nov 2024 04:51:52 -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=cb02+qPoHhtgiIwF+YYOEh3cyskynX5L7YjzhXvmlTs=; b=dg8uRr3Ps4h+ 8PLeMCfX08N7oJpJKZAybLfhaWLKCY0z85NYExwMZ4C8ciaaQIwdZshCz1QU8UjwNQlhLITZZbR40 TvDC9JPbxfwM4FBEftn+epvb9BRQfEzqY8ZBUZGlaKrziPLOP7saLzt3B/z3D7C52VNc+QS9JIy9h q0VF80Uqsk9/53QUG19MrVk+NxtRSP/VLMp0mOpAG8qtU68bw7zKwDE9lIsJ5YUoKlxZGojR1iaDc lT76y7lgvXrtPlOUfQb0TiBgzG9X9UhouBLi3D9ihLgRRL8uByeItePBIGFkWJrNtOUCpjecq8dq0 kOo1UBH30fB7+curdiuZ5Q==; In-Reply-To: (message from Stefan Monnier on Thu, 14 Nov 2024 11:56:37 -0500) 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:296128 Archived-At: 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. > > > > >