GNU bug report logs - #81334
32.0.50; fontifying buffers with many blocks is very slow

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Shaun Dern <smdern@HIDDEN>; dated Tue, 30 Jun 2026 17:08:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 81334 <at> debbugs.gnu.org:


Received: (at 81334) by debbugs.gnu.org; 1 Jul 2026 11:24:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 01 07:24:12 2026
Received: from localhost ([127.0.0.1]:58478 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wet36-0006Tb-22
	for submit <at> debbugs.gnu.org; Wed, 01 Jul 2026 07:24:12 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38636)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wet33-0006TC-O4
 for 81334 <at> debbugs.gnu.org; Wed, 01 Jul 2026 07:24:10 -0400
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 <eliz@HIDDEN>)
 id 1wet2y-0005nO-Bn; Wed, 01 Jul 2026 07:24:04 -0400
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=gFqEjx6cUmGhGbQtGUHSWkLTR+xZUcTBY0wvnXlsrSM=; b=ZJn7qQHDN6fW
 WtPYrNUeiFFRZZjz0uEJYWRmbjKE+9E37VFYyWjmWtlgqOYkIbcOXu6+Xh9uefhpp8JH3KtJUinuT
 W2+dMQrh9Z5PFPRjfMx9Gm3PY7bfKv3KShNsNwerByOWt0ks/Sy6aNw0bfPhafb/nw2tmjlSLJ5eX
 Tt5Sht4OpV9aXq8lKtPrYP9aOzp6jq7ZKTGniYVjaIXIQGS5d6c2WSJM9k7pegzyEzA7jmUl5drio
 SVwHXBrFJUITQw+wO8G9lAlxk6BKEpXUVAJgEUIFLzGPdtR3nuQHtc3Px1jbI4Unb541AnaxDo7hr
 J+T9zyeJZtIcPlKP1T/s6g==;
Date: Wed, 01 Jul 2026 14:24:01 +0300
Message-Id: <86mrwbc5ri.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Shaun Dern <smdern@HIDDEN>,
 Rahul Martim Juliato <rahuljuliato@HIDDEN>
In-Reply-To: <CA+AMHnb8dRwav4bC_BeL73Np5F1-98vz9NAu9jb2jzrf_gXY9g@HIDDEN>
 (message from Shaun Dern on Tue, 30 Jun 2026 08:57:00 -0700)
Subject: Re: bug#81334: 32.0.50;
 fontifying buffers with many blocks is very slow
References: <CA+AMHnb8dRwav4bC_BeL73Np5F1-98vz9NAu9jb2jzrf_gXY9g@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81334
Cc: 81334 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Shaun Dern <smdern@HIDDEN>
> Date: Tue, 30 Jun 2026 08:57:00 -0700
> 
> Opening a large Markdown buffer in markdown-ts-mode blocks for several seconds (CPU at 100%). The time
> scales with the number of blocks rather than the byte size: a buffer of many short blocks is far slower than a
> larger buffer of few long ones.
> 
> Recipe (emacs -Q --batch; requires the markdown and markdown-inline grammars)
> 
>     (require 'markdown-ts-mode)
>     (with-temp-buffer
>       (dotimes (i 8000) (insert (format "- item %d\n" i)))
>       (markdown-ts-mode)
>       (message "%.3f s" (car (benchmark-run 1 (font-lock-ensure)))))
> 
>   Observed here: ~3.8 s to fontify this 95 KB buffer. The cost tracks the
>   number of blocks, not the byte count: a 4x larger buffer (370 KB) of a few
>   long paragraphs fontifies in ~0.07 s.
> 
> tree-sitter grammars: tree-sitter-grammars/tree-sitter-markdown v0.4.1
>   (markdown and markdown-inline).
> 
> In GNU Emacs 32.0.50 (build 1, aarch64-apple-darwin25.5.0, NS appkit-2685.60 Version 26.5.1 (Build 25F80))
>  of 2026-06-29
> System Description: macOS (aarch64-apple-darwin25.5.0)

Thanks.

Rahul, could you please look into this?

I've ran this under the Lisp profiler, and obtained the following
profile:

        2559  86%   Automatic GC
         392  13% - command-execute
         392  13%  - call-interactively
         382  12%   - funcall-interactively
         382  12%    - execute-extended-command
         382  12%     - command-execute
         382  12%      - call-interactively
         382  12%       - funcall-interactively
         382  12%        - eval-region
         380  12%         - let
         380  12%          - save-current-buffer
         380  12%           - unwind-protect
         380  12%            - progn
         375  12%             - message
         375  12%              - car
         375  12%               - benchmark-call
         375  12%                - #<interpreted-function 402>
         375  12%                 - font-lock-ensure
         375  12%                  - #<byte-code-function 1E3>
         375  12%                   - font-lock-fontify-region
         375  12%                    - font-lock-default-fontify-region
         375  12%                     - font-lock-fontify-syntactically-region
         375  12%                      - treesit-font-lock-fontify-region
         336  11%                       - treesit-update-ranges
         222   7%                        - treesit--update-range-1
         111   3%                         - treesit--update-ranges-local
          53   1%                            make-overlay
          46   1%                            treesit-parser-create
           6   0%                          - treesit--set-embed-ranges
           5   0%                             treesit-parser-root-node
           1   0%                             treesit-parser-set-included-ranges
           5   0%                          - treesit-query-range
           4   0%                             treesit-query-capture
           1   0%                             treesit-node-start
           1   0%                          - treesit-query-range-by-language
           1   0%                             treesit-query-capture
         107   3%                         - treesit--update-ranges-non-local
         101   3%                            treesit-parser-list
           3   0%                          - treesit-query-range
           3   0%                             treesit-query-capture
           1   0%                            treesit--merge-ranges
           1   0%                          - seq-filter
           1   0%                             make-closure
           1   0%                            treesit--clip-ranges
           1   0%                           treesit-parser-language
           1   0%                           treesit-query-language
         114   3%                          append
          25   0%                       - treesit--font-lock-fontify-region-1
           4   0%                          treesit-query-capture
           3   0%                          make-closure
           3   0%                          #<byte-code-function 872>
           2   0%                          markdown-ts--fontify-unordered-list-marker
           1   0%                        - facep
           1   0%                           internal-lisp-face-p
           1   0%                          buffer-modified-p
           9   0%                       - cl-remove-if-not
           9   0%                        - apply
           9   0%                         - cl-remove
           4   0%                          - funcall
           4   0%                           - #<byte-code-function 06C>
           4   0%                            - treesit-node-language
           1   0%                               treesit-parser-language
           4   0%                       - mapcan
           4   0%                        - #<byte-code-function A9A>
           3   0%                         - treesit--children-covering-range-recurse
           2   0%                          - treesit--children-covering-range-recurse
           2   0%                           - treesit--children-covering-range-recurse
           2   0%                              treesit-node-next-sibling
           1   0%                         treesit-subtree-stat
           4   0%             - markdown-ts-mode
           4   0%              - markdown-ts-mode--initialize
           4   0%               - markdown-ts--set-up
           3   0%                - treesit-major-mode-setup
           3   0%                 - treesit-font-lock-recompute-features
           3   0%                  - treesit-validate-and-compile-font-lock-rules
           3   0%                   - treesit--compile-query-with-cache
           3   0%                      treesit-query-compile
           1   0%                - require
           1   0%                 - byte-code
           1   0%                  - require
           1   0%                   - byte-code
           1   0%                    - custom-declare-variable
           1   0%                     - custom-initialize-reset
           1   0%                      - eval
           1   0%                       - funcall
           1   0%                        - #<byte-code-function 4B8>
           1   0%                         - executable-find
           1   0%                          - locate-file
           1   0%                             locate-file-internal
           1   0%             - let
           1   0%              - while
           1   0%                 <
           2   0%         - require
           1   0%          - byte-code
           1   0%           - require
           1   0%            - byte-code
           1   0%             - require
           1   0%                read
           1   0%            read
          10   0%   - byte-code
          10   0%    - read-extended-command
          10   0%     - read-extended-command-1
          10   0%      - completing-read
          10   0%       - completing-read-default
          10   0%          read-from-minibuffer
           3   0% - timer-event-handler
           3   0%  - apply
           3   0%   - markdown-ts--enable-code-block-in-context-mode
           2   0%    - markdown-ts-at-code-block-p
           2   0%     - cl-some
           2   0%        read
           1   0%    - sit-for
           1   0%     - redisplay
           1   0%        redisplay_internal (C function)
           2   0%   redisplay_internal (C function)
           1   0% - ...
           1   0%  - completion-try-completion
           1   0%   - completion--nth-completion
           1   0%    - seq-some
           1   0%     - seq-do
           1   0%      - mapc
           1   0%       - #<byte-code-function A48>
           1   0%        - #<byte-code-function A8E>
           1   0%         - eval
           1   0%          - let
           1   0%           - funcall
           1   0%            - #<byte-code-function BA8>
           1   0%             - completion-basic-try-completion
           1   0%              - try-completion
           1   0%               - #<byte-code-function 0F1>
           1   0%                - complete-with-action
           1   0%                   try-completion




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81334; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 30 Jun 2026 17:07:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 30 13:07:55 2026
Received: from localhost ([127.0.0.1]:53132 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1webwB-0008BU-CM
	for submit <at> debbugs.gnu.org; Tue, 30 Jun 2026 13:07:55 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:52818)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <smdern@HIDDEN>) id 1weapt-0001Pz-1H
 for submit <at> debbugs.gnu.org; Tue, 30 Jun 2026 11:57:21 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <smdern@HIDDEN>) id 1weapn-0008LJ-Kd
 for bug-gnu-emacs@HIDDEN; Tue, 30 Jun 2026 11:57:15 -0400
Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <smdern@HIDDEN>) id 1weapl-0007Xa-R6
 for bug-gnu-emacs@HIDDEN; Tue, 30 Jun 2026 11:57:15 -0400
Received: by mail-oa1-x2b.google.com with SMTP id
 586e51a60fabf-43bfe209e45so2547851fac.0
 for <bug-gnu-emacs@HIDDEN>; Tue, 30 Jun 2026 08:57:13 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1782835032; cv=none;
 d=google.com; s=arc-20260327;
 b=Njn9sj2ibOT4PjQ84v8bD4JESGJ5+nCdspMlN7d7fdvgvUibrXLZ2YN7PQ9sG81C0w
 zahhO1dpFKyROBaIFLr3RkpTPrzdmTTFcdCScutkEV4tylN04YN/rZgf3bVJQ/lOpaQR
 qfECFJi75yMx9xHRRVnpFOjUptwTkba3yuV5t/thNX6Eam1x2eIs10PSsF3o+OCxJrcK
 M8AGjMZo13v7ZQ8QnEbnmleTIhwvgBGBUHPjv8dU4DP+3BkT2pUbNuW7yMf/baVeRYte
 rjXLxLDSDKBHYDqgnqMy7zSoturmH4EnwIApJEoJAspKhNUJCPn3AjMso4sTG5xRVQ6q
 WtJw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
 s=arc-20260327; 
 h=to:subject:message-id:date:from:mime-version:dkim-signature;
 bh=Ql46z8nVWQh90K8fu3SFKZz2vPNcHswMBpvepd7KIDk=;
 fh=+R8aXOFVnuBbN1nRXJJI02Ia//JUQJmLW/Uk/VaA0ag=;
 b=pxzRfVYF627wN6dhSLfQyj6fFfF32chUci/EcSkZVUWccoVixBJBaFSriAKWUDlsQQ
 g3MBciK8S10+TqZJN98gdNQHBSyGZh6awZhxgnJDI63BYJ/VcZEctxraXet3U39CUarH
 f8x4RH4ELpwjyZbcf2tXegJChR+pvgFjXH2OtnLQy3llcD6xOeBhj7wrYHoryF4OHgU6
 Mg5VPSN3q8SI8VwViuF6PdwFYxJVEFiUbhrP2DWoBrqf7YPeHt3Xux9Udv4hpCaJGzsh
 Cb1/A6+1Gs22+qYZyKd242yXd+wxLcLwmkDq2JRLelfV0dAilhXLSQUS3/Y+78/7iWjv
 Cn/g==; darn=gnu.org
ARC-Authentication-Results: i=1; mx.google.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1782835032; x=1783439832; darn=gnu.org;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Ql46z8nVWQh90K8fu3SFKZz2vPNcHswMBpvepd7KIDk=;
 b=JpXjsXJNl4RYAxBjFLfnnMa4kl+3hKE6I0KelqHPzKEnMssNI3QQRiS4bDt+DYkYRa
 5VMy9EnjOdgxnrNstM5uds9ThWukZ9N7+WB6yaFTeQTTglT/5me7AY4GhGttGqj4p12r
 bZV02MvBqj9L85ubA7NGU9uznV/lC3HglAW/wJzE+nVhC7KZVLsfalWoww/F4pXGeqPt
 hD+8UpGP7cPv5mqTjMM6iBRAiLMiA9YDL/LKeKKKaPmdyhecZ/zt3BhMuuzWVSdQ7mNU
 bOxgAq6rItbhscrxBWlOygGSbJBJYbI4lKWQQCnnHNOBKKGnkBaECGjq9eQ4+8di1XtG
 jcMw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20251104; t=1782835032; x=1783439832;
 h=to:subject:message-id:date:from:mime-version:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=Ql46z8nVWQh90K8fu3SFKZz2vPNcHswMBpvepd7KIDk=;
 b=HDUVLY186RncmbYuzt31C44RGGJG83aI4j/nENCGwONEwaYwMx+K5UAI3F+LViRsLz
 YT0jXtSc5AAogT2xuhmj5HoW99e+ZJv9rD2SlqOffWw0exBfFOo3npMkG3j5QC+nul64
 p7a+ZtoeMutHSVBT7bu5Cdw1H3MyF+KIgtlasGteJw43n6XWa9W5uJSDYK8i69lK6AlR
 2OCP/StZy+c8jbiydj3K8O2PfjowcwH69ojA+HaQrTJKT27j7EIasjOsYLGx15EiCR4W
 t+PIqjfRhy4DaixzLQC23175zgbZtCusjTXcvz3lEeTFv4iBTJH9/rjcFy4g9VTnNmrU
 YyPQ==
X-Gm-Message-State: AOJu0YwYnvti9St7mbXp2oaqSKnohy3X1pnKvXcdsbL+Z1fv9NjUtDME
 Tt+PbnvSlDXs+AmMJZX0lLSeOGvf3vbEv/BJ2V+Rl9TIlE1kGJm7MOqtw/AKOIClbbp5Lmj/4Tf
 RtwuMdqaB8o9RwaJYqbERSH1QXSu5CuDSpMgp
X-Gm-Gg: AfdE7ck0j0bE0q5PxUoKSn/6VC94SQ+raPJeYOHzyrj7+kb6KQZR3pufYm5rxZrYMoX
 bXfM/EzpfSnvk1LUE/fIKaf3aQSwGHbyekjwE2Q2y8LCU2dqzQ7TmBGGR3uD4ZJQOOumXg3A8Bx
 cl9uf8+NJGey0wy4P6Ex8ylBRuFIy8toAAPkhQHLT8w3bA0+IU/oEMpudpIEOAAJsolf/XRH+EP
 YJOZMTyNj3KJGJW++Tna3vZhwVPT8uG1C1UwMhqXc6qrNdLDNJVbnKpnzoBhASfygtIfxpk
X-Received: by 2002:a05:6808:1496:b0:495:daf4:bfd5 with SMTP id
 5614622812f47-495eafbdd91mr3838006b6e.37.1782835031977; Tue, 30 Jun 2026
 08:57:11 -0700 (PDT)
MIME-Version: 1.0
From: Shaun Dern <smdern@HIDDEN>
Date: Tue, 30 Jun 2026 08:57:00 -0700
X-Gm-Features: AVVi8Cd1lIlnuVK_FQe93u0WrQtbElgRNMf2hhtD5_rt_w-4sI42OPwnpVarMVc
Message-ID: <CA+AMHnb8dRwav4bC_BeL73Np5F1-98vz9NAu9jb2jzrf_gXY9g@HIDDEN>
Subject: 32.0.50; fontifying buffers with many blocks is very slow
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000c6372a06557aa0ef"
Received-SPF: pass client-ip=2001:4860:4864:20::2b;
 envelope-from=smdern@HIDDEN; helo=mail-oa1-x2b.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_KAM_HTML_FONT_INVALID=0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Opening a large Markdown buffer in markdown-ts-mode blocks
 for several seconds (CPU at 100%). The time scales with the number of blocks
 rather than the byte size: a buffer of many short blocks is far [...] 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (smdern[at]gmail.com)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.0 FORGED_GMAIL_RCVD      'From' gmail.com does not match 'Received'
 headers
 0.0 HTML_MESSAGE           BODY: HTML included in message
 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted
 Colors in HTML
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 30 Jun 2026 13:07:54 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--000000000000c6372a06557aa0ef
Content-Type: text/plain; charset="UTF-8"

Opening a large Markdown buffer in markdown-ts-mode blocks for several
seconds (CPU at 100%). The time scales with the number of blocks rather
than the byte size: a buffer of many short blocks is far slower than a
larger buffer of few long ones.

Recipe (emacs -Q --batch; requires the markdown and markdown-inline
grammars)

    (require 'markdown-ts-mode)
    (with-temp-buffer
      (dotimes (i 8000) (insert (format "- item %d\n" i)))
      (markdown-ts-mode)
      (message "%.3f s" (car (benchmark-run 1 (font-lock-ensure)))))

  Observed here: ~3.8 s to fontify this 95 KB buffer. The cost tracks the
  number of blocks, not the byte count: a 4x larger buffer (370 KB) of a few
  long paragraphs fontifies in ~0.07 s.

tree-sitter grammars: tree-sitter-grammars/tree-sitter-markdown v0.4.1
  (markdown and markdown-inline).

In GNU Emacs 32.0.50 (build 1, aarch64-apple-darwin25.5.0, NS
appkit-2685.60 Version 26.5.1 (Build 25F80))
 of 2026-06-29
System Description: macOS (aarch64-apple-darwin25.5.0)

Configured using:
 '--disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
 --infodir=/opt/homebrew/Cellar/emacs-plus@32/32.0.50/share/info/emacs
 --prefix=/opt/homebrew/Cellar/emacs-plus@32/32.0.50
 --with-native-compilation=aot --with-xml2 --with-gnutls
 --without-compress-install --without-dbus --without-imagemagick
 --with-modules --with-rsvg --with-webp --with-ns
 --disable-ns-self-contained'

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY
KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM ZLIB

--000000000000c6372a06557aa0ef
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><span style=3D"background-color:transparent">Opening =
a large Markdown buffer in markdown-ts-mode blocks for several seconds=C2=
=A0</span><span style=3D"background-color:transparent">(CPU at 100%). The t=
ime scales with the number of blocks rather than the byte </span><span styl=
e=3D"background-color:transparent">size: a buffer of many short blocks is f=
ar slower than a larger buffer of few=C2=A0</span><span style=3D"background=
-color:transparent">long ones.</span></div><div><br>Recipe (emacs -Q --batc=
h; requires the markdown and markdown-inline grammars)<br><br>=C2=A0 =C2=A0=
 (require &#39;markdown-ts-mode)<br>=C2=A0 =C2=A0 (with-temp-buffer<br>=C2=
=A0 =C2=A0 =C2=A0 (dotimes (i 8000) (insert (format &quot;- item %d\n&quot;=
 i)))<br>=C2=A0 =C2=A0 =C2=A0 (markdown-ts-mode)<br>=C2=A0 =C2=A0 =C2=A0 (m=
essage &quot;%.3f s&quot; (car (benchmark-run 1 (font-lock-ensure)))))<br><=
br>=C2=A0 Observed here: ~3.8 s to fontify this 95 KB buffer. The cost trac=
ks the<br>=C2=A0 number of blocks, not the byte count: a 4x larger buffer (=
370 KB) of a few<br>=C2=A0 long paragraphs fontifies in ~0.07 s.<br><br>tre=
e-sitter grammars: tree-sitter-grammars/tree-sitter-markdown v0.4.1<br>=C2=
=A0 (markdown and markdown-inline).<br><br>In GNU Emacs 32.0.50 (build 1, a=
arch64-apple-darwin25.5.0, NS appkit-2685.60 Version 26.5.1 (Build 25F80))<=
br>=C2=A0of 2026-06-29<br>System Description: macOS (aarch64-apple-darwin25=
.5.0)<br><br>Configured using:<br>=C2=A0&#39;--disable-dependency-tracking =
--disable-silent-rules<br>=C2=A0--enable-locallisppath=3D/opt/homebrew/shar=
e/emacs/site-lisp<br>=C2=A0--infodir=3D/opt/homebrew/Cellar/emacs-plus@32/3=
2.0.50/share/info/emacs<br>=C2=A0--prefix=3D/opt/homebrew/Cellar/emacs-plus=
@32/32.0.50<br>=C2=A0--with-native-compilation=3Daot --with-xml2 --with-gnu=
tls<br>=C2=A0--without-compress-install --without-dbus --without-imagemagic=
k<br>=C2=A0--with-modules --with-rsvg --with-webp --with-ns<br>=C2=A0--disa=
ble-ns-self-contained&#39;<br><br>Configured features:<br>ACL GIF GLIB GMP =
GNUTLS JPEG LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY<br>KQUEUE NS PDUMPER P=
NG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS<br>TREE_SITTER WEBP XIM ZL=
IB<br></div></div>

--000000000000c6372a06557aa0ef--




Acknowledgement sent to Shaun Dern <smdern@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#81334; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 1 Jul 2026 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.