unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Divya Ranjan <divya@subvertising.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 74281@debbugs.gnu.org
Subject: bug#74281: 30.0.91; font-lock mode hangs on scrolling large Scheme file
Date: Thu, 14 Nov 2024 10:44:27 +0200	[thread overview]
Message-ID: <86zfm2jjbo.fsf@gnu.org> (raw)
In-Reply-To: <8734k0cs1u.fsf@subvertising.org> (bug-gnu-emacs@gnu.org)

> 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" <bug-gnu-emacs@gnu.org>
> 
> 
> 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%            - #<byte-code-function CEC>
         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%             - #<byte-code-function BCE>
         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%      - #<byte-code-function 5A0>
         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





  reply	other threads:[~2024-11-14  8:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-09 16:04 bug#74281: 30.0.91; font-lock mode hangs on scrolling large Scheme file Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14  8:44 ` Eli Zaretskii [this message]
2024-11-14  9:32   ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 10:06     ` Eli Zaretskii
2024-11-14 11:09       ` Divya Ranjan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 11:42         ` Eli Zaretskii
2024-11-14 16:56   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=86zfm2jjbo.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=74281@debbugs.gnu.org \
    --cc=divya@subvertising.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).