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: Thu, 14 Nov 2024 10:44:27 +0200 Message-ID: <86zfm2jjbo.fsf@gnu.org> References: <8734k0cs1u.fsf@subvertising.org> 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="36027"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74281@debbugs.gnu.org To: Divya Ranjan , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 14 09:45: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 1tBVTf-00096a-UQ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Nov 2024 09:45:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBVTN-00085t-5y; Thu, 14 Nov 2024 03:45: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 1tBVTK-00084T-Qf for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 03:45:03 -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 1tBVTK-0006mW-I1 for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 03:45:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=oucMvSyq0rgwGsBb91xaujpdlb3hWEiclHQmu0av3wQ=; b=FtYG+IKDuAHuqIDLaLacsYE5MKLwB4VwPilXxVqw4/AISTh1V1DHGDN7lT0F2nW/LY50Kb5ClUaYmCB2O/EavjaCYlPh0+Agb6EgfmNNLsVT7O9t5yGJ4Sak73xhx21BQhvjo4uFek3xcERMEDxL4wsBHeHPxduiKIlkYHpKA/b65P37KpKho9WlFbaBmnQwQu+2wWyKX9YjGaBVT5W4/1GBBHitJG1YsVwJIU4cvo2BbuoPn7CPjtxDjWtFFvuY1FPa6zMqlMeU36W1h1tDcy7WEaECu7ZSPo4dBAPOVRc35qZ4oMMDbGletydCHF8yU2X0E2Mr6OGpNPY4X7dB8A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBVTK-0001iJ-4y for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 03:45: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: Thu, 14 Nov 2024 08:45: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.17315738886550 (code B ref 74281); Thu, 14 Nov 2024 08:45:02 +0000 Original-Received: (at 74281) by debbugs.gnu.org; 14 Nov 2024 08:44:48 +0000 Original-Received: from localhost ([127.0.0.1]:44939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBVT5-0001hZ-Nl for submit@debbugs.gnu.org; Thu, 14 Nov 2024 03:44:48 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBVT3-0001hL-Tp for 74281@debbugs.gnu.org; Thu, 14 Nov 2024 03:44:46 -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 1tBVSw-0006bD-Ft; Thu, 14 Nov 2024 03:44:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=oucMvSyq0rgwGsBb91xaujpdlb3hWEiclHQmu0av3wQ=; b=UP0C8I0xjqRWL8a/FKhT Q1mC4jrJ1bhdXXLaLi61hPyg216FRHi+T6RH9CGnN7V2XdZ5zoYqH2fP3JvXg7B8/WJO/A5mTC0Zj gwlk+kUMa+MRhK1Kdd3eBTnHKkeX0mOErtCO1rJihILERFptJNmZ2+i1+fh9GtcBvAee6l38bWNgV vMJvG8uS+5Wn+Rn5tY9fqRkQaKs3Y2rJNwwILNy1dd7SyQpP2FTFvxDCje0qqUGcbVn4BVlmM2u6Y W/B48W6pqk4kOEMlpk/rKcdybyaBSZ7UCBP4iAmiSkn2mSnNxoporzPI3Eq4s9UU90hJtGZ9Wp+Fo sk4ZYQcjfHXPWg==; In-Reply-To: <8734k0cs1u.fsf@subvertising.org> (bug-gnu-emacs@gnu.org) 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:295314 Archived-At: > Date: Sat, 09 Nov 2024 16:04:13 +0000 > From: Divya Ranjan via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > 1. In emacs -Q, open a fairly big Scheme file (> 70k) and try to move in > the file with C-n, C-f or mouse scrolling. It sverely lags for several > seconds, doesn’t even respond to C-g. I can only reproduce this with C-p when moving from the end of the file. C-n and C-f are instantaneous here, even though this is an unoptimized build of Emacs 30. > 2. Toggle font-lock-mode off through M-x, then try to scroll. It works > as expected, no serious lags. > > 3. Running the profiler also shows font-lock as the culprit. The profile I measured is below. It seems like the bottleneck is parse-partial-sexp, which means the syntax table scheme-mode-syntax-table might be the immediate suspect. > This makes working on big projects, in my case the source code of GNU > Guix distribution an impossible situation. I haven’t tried setting up > (Guile) Scheme with Tree-Sitter, but shouldn’t simple > syntax-highlighting be not a serious problem? > > To try a big Scheme file and reproduce this, open tex.scm in > gnu/packages/tex.scm in Guix source tree: > > https://git.savannah.gnu.org/cgit/guix.git 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? Here's the profile I get while moving with C-p through the above file: 1151 66% - ... 1151 66% - command-execute 1151 66% - call-interactively 1151 66% - funcall-interactively 1151 66% - previous-line 1151 66% - line-move 798 45% - line-pixel-height 798 45% - jit-lock-function 798 45% - jit-lock-fontify-now 798 45% - jit-lock--run-functions 798 45% - run-hook-wrapped 798 45% - # 798 45% - font-lock-fontify-region 798 45% - font-lock-default-fontify-region 798 45% - font-lock-fontify-syntactically-region 798 45% - font-lock-default-fontify-syntactically 798 45% parse-partial-sexp 353 20% - line-move-visual 353 20% - vertical-motion 353 20% - jit-lock-function 353 20% - jit-lock-fontify-now 353 20% - jit-lock--run-functions 353 20% - run-hook-wrapped 353 20% - # 353 20% - font-lock-fontify-region 353 20% - font-lock-default-fontify-region 353 20% - font-lock-fontify-syntactically-region 353 20% - font-lock-default-fontify-syntactically 353 20% parse-partial-sexp 585 33% - redisplay_internal (C function) 577 33% - jit-lock-function 577 33% - jit-lock-fontify-now 577 33% - jit-lock--run-functions 577 33% - run-hook-wrapped 577 33% - # 577 33% - font-lock-fontify-region 577 33% - font-lock-default-fontify-region 577 33% - font-lock-fontify-syntactically-region 577 33% - font-lock-default-fontify-syntactically 577 33% parse-partial-sexp 6 0% Automatic GC