From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: treesitter local parser: huge slowdown and memory usage in a long file Date: Sun, 11 Feb 2024 20:16:11 -0800 Message-ID: <93F7DE13-0EC7-4A17-89B1-E07C99C6347B@gmail.com> References: <5991618.MhkbZ0Pkbq@fedora> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_26C946C9-038F-483D-A2E8-17D91DD9E186" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27296"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Ergus via Emacs development discussions." , Eli Zaretskii To: Vincenzo Pupillo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Feb 12 05:17:27 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rZNl1-0006ts-0R for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Feb 2024 05:17:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZNkG-0004ul-AT; Sun, 11 Feb 2024 23:16:40 -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 1rZNk6-0004tf-2P for emacs-devel@gnu.org; Sun, 11 Feb 2024 23:16:30 -0500 Original-Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZNk1-0000TG-DZ; Sun, 11 Feb 2024 23:16:29 -0500 Original-Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5d8b887bb0cso2382961a12.2; Sun, 11 Feb 2024 20:16:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707711383; x=1708316183; darn=gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=kWIWwLS41eBwBRQCEdKtY4yy+ZTCknXZjtNSQgNY3UU=; b=NnUY9NYm8UFgt1QxgkCtxuoR/e0brrCS2BM8pw0KaDNMC4xRqhe4JivoTZX3sM1NcI vDBbxsDTA2CeQjIFFPtY1KxOoMV0OZqpPb8en13EnDUQceKBn4q5Ugh8C8ixbpTZEyWh PmZ36WF+KdYhS6rUveqRh2+XYKrXGfnqMdXUqZ1S0mo1AaOkSY6RLuZ8HlVFUGCKs6I1 PXMyQ98/nyZJ0RcmohlyUVrLbb0H2LlkIfpMDe05z7ksDiGoI0MC9C0GPXe0Uol5ExTX 7HLBKJs9Ax+9DDP5xADHEwj2srNTQwT0FRq0uLO7HhbbgWr3WqLt1RgNS5mG/DIHGlRf DZXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707711383; x=1708316183; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kWIWwLS41eBwBRQCEdKtY4yy+ZTCknXZjtNSQgNY3UU=; b=G+6Pl7fCHZyAVagcDIo7orMRTAvzlUwAbVD52+sJMYj/4HFaZiBCp73wEdf7SyrOFF 1OwgJFHyuFA6KHnpcd6oBEAtm0StaP27Rx28lG2q6w3L5R8NTGN6sfoFkkrtEYcmfSrs LR0z2f+mzi8+6S1LfVgiL0nsb0ulMcuo381IYUuvF99d989YeDpgX5Yd7da5m3FfGvvf EwakwR78nOmuNxVSE1fVG1xe9zlfccY3139Fv2iXB+7N3MWq62ZX/Dt8UbqQj+mMNW7W 7d0XZm3P4cJnP163GgMwJRvZL7szK6qkFM1FrT2Rdr/VH7Ojk20HEUsD9D8AAZxXaUig QX4g== X-Gm-Message-State: AOJu0Yy6fcch4DR9t85g9iF6mC+9YAvrCuGicOSbiPzanWIm3XU6m4uO ooDi+KAF8ZTbBmaN0443GybyOC8wbwRF5yzmY6NBryzzBlomR6FF X-Google-Smtp-Source: AGHT+IGulcBFSTEZU+EDpMh3p61dU6C4/EJoDQBM5V1CN119Zhy/bXDZX4E1WqKxD1DSaKGbu+6b2w== X-Received: by 2002:a05:6a21:3489:b0:19e:b6c6:8f15 with SMTP id yo9-20020a056a21348900b0019eb6c68f15mr8726932pzb.25.1707711383444; Sun, 11 Feb 2024 20:16:23 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU63a/GUoJDBNJdXwMcNhSQRMMzAjf2GEaTG53LCzvYPsmcYzCqaEwciM811bbPPKTM1sg87GccTNwLGJM= Original-Received: from smtpclient.apple (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id y23-20020aa78557000000b006e09ec69d7dsm4159360pfn.98.2024.02.11.20.16.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2024 20:16:22 -0800 (PST) In-Reply-To: <5991618.MhkbZ0Pkbq@fedora> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=casouri@gmail.com; helo=mail-pg1-x52a.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:316123 Archived-At: --Apple-Mail=_26C946C9-038F-483D-A2E8-17D91DD9E186 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Feb 11, 2024, at 1:53 PM, Vincenzo Pupillo = wrote: >=20 > Hi,=20 > as a benchmark for my php-ts-mode (in 2 variants: one with = tree-sitter-phpdoc=20 > for php comment block, and another using regular expression for = comment block)=20 > I use tcpdf.php (from the tcpdf library). This php file has 24730 = lines and=20 > generates 669 parser ranges, 665 of which are for phpdoc.=20 >=20 > As you can see from the profile (I try to edit the comment on line = 2350) that I=20 > attached, the problem is in treesit--pre-redisplay. > I tried playing around with the code a bit but to no avail (for = example, I=20 > limited treesit-update-ranges to window-start and window-end).=20 > comments say: > ;; Force repase on _all_ the parsers might not be necessary, but > ;; this is probably the most robust way. >=20 > Any ideas? > My php-ts-mode (It's a working progress) is available here:=20 > https://github.com/vpxyz/php-ts-mode >=20 > Thanks > V. >=20 > p.s without phpdoc emacs is as fast as with short php files. > p.p.s. nvim with treesitter is as slow as my major mode with this = file. >=20 > GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, = cairo=20 > version 1.18.0) of 2024-02-11 --Apple-Mail=_26C946C9-038F-483D-A2E8-17D91DD9E186 Content-Disposition: attachment; filename=cpu_profiler_report.txt Content-Type: text/plain; x-mac-hide-extension=yes; x-unix-mode=0644; name="cpu_profiler_report.txt" Content-Transfer-Encoding: quoted-printable [profiler-profile "28.1" cpu #s(hash-table test equal data = ([redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil = nil nil nil nil nil nil nil] 124 [nil nil nil nil nil nil nil nil nil = nil nil nil nil nil nil nil] 945 [line-move-visual line-move next-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil] 6 [line-move-visual line-move previous-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil] 4 [treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil nil nil nil] 2744 = [jit-lock--antiblink-post-command nil nil nil nil nil nil nil nil nil = nil nil nil nil nil nil] 1 [syntax-class show-paren--categorize-paren = show-paren--locate-near-paren show-paren--default show-paren-function = apply timer-event-handler nil nil nil nil nil nil nil nil nil] 1 = [delete-dups xselect-convert-to-targets pgtk-own-selection-internal = "#" apply gui-backend-set-selection = gui-set-selection gui-select-text kill-new kill-region kill-line = funcall-interactively command-execute nil nil nil] 3 = [treesit-query-range treesit--update-ranges-local treesit-update-ranges = treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil] 1759 [treesit-query-range = treesit-update-ranges treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil nil] 1636 ["#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil nil nil nil nil nil] 1 [cl-delete cl-remove cl-remove-if-not = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil] 3 = [treesit-node-parent let* php-ts-mode--language-at-point = treesit-language-at treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil nil] 1 [treesit-buffer-root-node = treesit-node-at treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil nil nil nil] 102 [treesit-query-range treesit-update-ranges = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil] 2 [treesit--update-ranges-local treesit-update-ranges = treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil nil] 14 [cl-remove cl-remove-if-not = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil] 3 [treesit-parser-root-node treesit-font-lock-fontify-region = font-lock-fontify-syntactically-region font-lock-default-fontify-region = font-lock-fontify-region "#" = jit-lock--run-functions jit-lock-fontify-now jit-lock-function = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil] 52 = [treesit--font-lock-fontify-region-1 treesit-font-lock-fontify-region = font-lock-fontify-syntactically-region font-lock-default-fontify-region = font-lock-fontify-region "#" = jit-lock--run-functions jit-lock-fontify-now jit-lock-function = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil] 13 = [self-insert-command funcall-interactively command-execute nil nil nil = nil nil nil nil nil nil nil nil nil nil] 3 [parse-partial-sexp = syntax-ppss jit-lock--antiblink-post-command nil nil nil nil nil nil nil = nil nil nil nil nil nil] 2 [treesit-update-ranges treesit--pre-redisplay = run-hook-with-args redisplay--pre-redisplay-functions = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil = nil nil] 23 [treesit--update-ranges-local treesit-update-ranges = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil] 2 [comment-indent-new-line default-indent-new-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil nil] 1 [jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil nil nil nil nil nil nil] 3 [treesit-query-range = treesit--update-ranges-local treesit-update-ranges = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil] 1 = [treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil nil] 2 [make-closure syntax-ppss show-paren--default = show-paren-function apply timer-event-handler nil nil nil nil nil nil = nil nil nil nil] 1 ["#" newline = comment-indent-new-line default-indent-new-line funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil nil] 1 ["#" font-lock-unfontify-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil nil] 1 ["#" cl-remove = cl-remove-if-not treesit-font-lock-fontify-region = font-lock-fontify-syntactically-region font-lock-default-fontify-region = font-lock-fontify-region "#" = jit-lock--run-functions jit-lock-fontify-now jit-lock-function = redisplay_internal\ \(C\ function\) nil nil nil nil] 1 = [internal-echo-keystrokes-prefix nil nil nil nil nil nil nil nil nil nil = nil nil nil nil nil] 1 [facep treesit--font-lock-fontify-region-1 = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil] 1 [line-move next-line funcall-interactively command-execute nil = nil nil nil nil nil nil nil nil nil nil nil] 1 [frame-parameter if eval = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil = nil nil nil] 1 [mode-line-frame-control eval redisplay_internal\ \(C\ = function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 = [line-move previous-line funcall-interactively command-execute nil nil = nil nil nil nil nil nil nil nil nil nil] 2 [redisplay_internal\ \(C\ = function\) sit-for icomplete-exhibit icomplete-post-command-hook = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil] 24 [sit-for = icomplete-exhibit icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil nil] 30 ["#" = all-completions complete-with-action "#" = completion-pcm--all-completions completion-substring--all-completions = completion-flex-all-completions "#" = "#" mapc seq-do seq-some = completion--nth-completion completion-all-completions = completion-all-sorted-completions icomplete--sorted-completions] 7 = [interactive-form commandp "#" "#" all-completions complete-with-action "#" = completion-pcm--all-completions completion-substring--all-completions = completion-flex-all-completions "#" = "#" mapc seq-do seq-some = completion--nth-completion] 1 [all-completions complete-with-action = "#" = completion-pcm--all-completions completion-substring--all-completions = completion-flex-all-completions "#" = "#" mapc seq-do seq-some = completion--nth-completion completion-all-completions = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions] 68 [completion-pcm--all-completions = completion-substring--all-completions completion-flex-all-completions = "#" "#" mapc = seq-do seq-some completion--nth-completion completion-all-completions = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions icomplete-exhibit icomplete-post-command-hook = completing-read-default] 2 [delete-dups = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions icomplete-exhibit icomplete-post-command-hook = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil] 1 ["#" = minibuffer--sort-by-length-alpha completion-all-sorted-completions = icomplete--sorted-completions icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil] 2 ["#" = read-extended-command--affixation icomplete--augment = icomplete--render-vertical icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil] 1 [window--min-size-1 window--min-size-1 = window-min-size window-sizable window--resize-root-window-vertically = redisplay_internal\ \(C\ function\) completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil] 1 [redisplay_internal\ \(C\ function\) = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil nil nil] 22 = [completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil nil nil nil] = 67 [completion--flex-score "#" mapcar = "#" completion-all-sorted-completions = icomplete--sorted-completions icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil] 1 [try-completion complete-with-action "#" = completion--complete-and-exit minibuffer-force-complete-and-exit = icomplete-force-complete-and-exit icomplete-fido-ret = funcall-interactively command-execute completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil] 10 [execute-extended-command funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil nil nil nil nil] 1 = [Automatic\ GC nil] 165)) (26057 13278 384506 497000) nil] --Apple-Mail=_26C946C9-038F-483D-A2E8-17D91DD9E186 Content-Disposition: attachment; filename=mem_profiler_report.txt Content-Type: text/plain; x-mac-hide-extension=yes; x-unix-mode=0644; name="mem_profiler_report.txt" Content-Transfer-Encoding: quoted-printable [profiler-profile "28.1" memory #s(hash-table test equal data = ([profiler-start funcall-interactively command-execute = execute-extended-command funcall-interactively command-execute nil nil = nil nil nil nil nil nil nil nil] 631 [timer--time-setter timer-set-time = run-at-time execute-extended-command funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil nil] 24 = [timer--time-less-p timer--activate timer-activate run-at-time = execute-extended-command funcall-interactively command-execute nil nil = nil nil nil nil nil nil nil] 24 [timer--time-setter timer-set-idle-time = run-with-idle-timer jit-lock--antiblink-post-command nil nil nil nil nil = nil nil nil nil nil nil nil] 24 [nil nil nil nil nil nil nil nil nil nil = nil nil nil nil nil nil] 32744 [menu-bar-update-buffers-1 = menu-bar-update-buffers redisplay_internal\ \(C\ function\) nil nil nil = nil nil nil nil nil nil nil nil nil nil] 2016 [redisplay_internal\ \(C\ = function\) nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] = 316718 [string-match kill-this-buffer-enabled-p redisplay_internal\ \(C\ = function\) nil nil nil nil nil nil nil nil nil nil nil nil nil] 1024 = [timer--time-setter timer-set-time run-at-time run-with-timer = blink-cursor--start-timer blink-cursor-start apply timer-event-handler = nil nil nil nil nil nil nil nil] 216 [timer--time-less-p timer--activate = timer-activate run-at-time run-with-timer blink-cursor--start-timer = blink-cursor-start apply timer-event-handler nil nil nil nil nil nil = nil] 192 [timer-relative-time timer-inc-time timer-event-handler nil nil = nil nil nil nil nil nil nil nil nil nil nil] 672 [timer--time-setter = timer-inc-time timer-event-handler nil nil nil nil nil nil nil nil nil = nil nil nil nil] 288 [time-less-p timer-event-handler nil nil nil nil = nil nil nil nil nil nil nil nil nil nil] 288 [timer--time-less-p = timer--activate timer-activate timer-event-handler nil nil nil nil nil = nil nil nil nil nil nil nil] 264 [line-move-visual line-move next-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil] 4748 [default-font-height default-line-height = line-move-partial line-move next-line funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil] 8184 = [delete-and-extract-region "#" apply = "#" buffer-substring--filter = filter-buffer-substring kill-region kill-line funcall-interactively = command-execute nil nil nil nil nil nil] 24840 = [menu-bar-update-yank-menu kill-new kill-region kill-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil] 1152 [pgtk-own-selection-internal "#" apply gui-backend-set-selection gui-set-selection = gui-select-text kill-new kill-region kill-line funcall-interactively = command-execute nil nil nil nil nil] 368 [treesit--update-ranges-local = treesit-update-ranges treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil nil] 2464048 [treesit-query-range = treesit--update-ranges-local treesit-update-ranges = treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil] 6513544 [treesit-query-range = treesit-update-ranges treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil nil nil] 23008 [treesit--pre-redisplay = run-hook-with-args redisplay--pre-redisplay-functions = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil nil nil nil = nil nil nil] 571762456 [jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil nil nil nil nil nil nil] 8288 [treesit--update-ranges-local = treesit-update-ranges treesit-font-lock-fontify-region = font-lock-fontify-syntactically-region font-lock-default-fontify-region = font-lock-fontify-region "#" = jit-lock--run-functions jit-lock-fontify-now jit-lock-function = redisplay_internal\ \(C\ function\) nil nil nil nil nil] 5200 = [treesit-local-parsers-on treesit-font-lock-fontify-region = font-lock-fontify-syntactically-region font-lock-default-fontify-region = font-lock-fontify-region "#" = jit-lock--run-functions jit-lock-fontify-now jit-lock-function = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil] 2320 = [treesit-parser-root-node treesit-font-lock-fontify-region = font-lock-fontify-syntactically-region font-lock-default-fontify-region = font-lock-fontify-region "#" = jit-lock--run-functions jit-lock-fontify-now jit-lock-function = redisplay_internal\ \(C\ function\) nil nil nil nil nil nil] 1679304 = [treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil nil] 41440 [treesit--font-lock-fontify-region-1 = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil = nil nil] 51984 [treesit--update-ranges-local treesit-update-ranges = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil] 160 [treesit-local-parsers-at treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil] 80 = [treesit-local-parsers-at treesit-node-at let* = php-ts-mode--language-at-point treesit-language-at treesit--indent-1 = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil nil nil nil] 160 = [treesit-node-at let* php-ts-mode--language-at-point treesit-language-at = treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil nil] 3072 [treesit-node-parent let* = php-ts-mode--language-at-point treesit-language-at treesit--indent-1 = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil nil nil nil nil] 3584 = [format let* php-ts-mode--language-at-point treesit-language-at = treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil nil] 338 [looking-at looking-at-p and cond save-excursion let* = php-ts-mode--language-at-point treesit-language-at treesit--indent-1 = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil] 1024 = [treesit-local-parsers-at treesit-node-at treesit--indent-1 = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil] = 80 [treesit-buffer-root-node treesit-node-at treesit--indent-1 = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil] = 23857603 [treesit-node-at treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil] 3584 = [treesit-parent-while treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil] 256 = [treesit-local-parsers-at treesit-node-at let* = php-ts-mode--language-at-point treesit-language-at treesit-node-on = treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil] 80 [treesit-node-at let* php-ts-mode--language-at-point = treesit-language-at treesit-node-on treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil] 1536 [treesit-node-parent let* = php-ts-mode--language-at-point treesit-language-at treesit-node-on = treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil] 1792 [format let* php-ts-mode--language-at-point = treesit-language-at treesit-node-on treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil] 169 [treesit-local-parsers-on = treesit-node-on treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil nil nil nil] 80 [make-closure "#" = treesit--simple-indent-eval treesit--simple-indent-eval = treesit-simple-indent treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil] 4144 [string-match "#" "#" = treesit--simple-indent-eval treesit-simple-indent treesit--indent-1 = treesit-indent indent--funcall-widened indent-for-tab-command = funcall-interactively command-execute nil nil nil nil nil] 1024 = [treesit-simple-indent treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil] 1336 [looking-at = "#" treesit--simple-indent-eval = treesit-simple-indent treesit--indent-1 treesit-indent = indent--funcall-widened indent-for-tab-command funcall-interactively = command-execute nil nil nil nil nil nil] 2112 [string-match "#" treesit--simple-indent-eval treesit-simple-indent = treesit--indent-1 treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil nil] 1024 [indent-line-to treesit-indent indent--funcall-widened = indent-for-tab-command funcall-interactively command-execute nil nil nil = nil nil nil nil nil nil nil] 25168 [self-insert-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil nil nil] 732592 [make-closure syntax-ppss = jit-lock--antiblink-post-command nil nil nil nil nil nil nil nil nil nil = nil nil nil] 4144 [generate-new-buffer comment-normalize-vars = comment-indent-new-line default-indent-new-line funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil nil] 21 = [comment-normalize-vars comment-indent-new-line default-indent-new-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil] 2176 [timer--time-setter timer-set-time run-at-time = undo-auto--boundary-ensure-timer undo-auto--undoable-change newline = comment-indent-new-line default-indent-new-line funcall-interactively = command-execute nil nil nil nil nil nil] 24 [newline = comment-indent-new-line default-indent-new-line funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil nil nil] 50656 = [looking-at "#" newline = comment-indent-new-line default-indent-new-line funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil] 1152 = [comment-string-strip comment-indent-new-line default-indent-new-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil] 2304 [comment-indent-new-line default-indent-new-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil nil] 101648 [comment-enter-backward comment-indent-new-line = default-indent-new-line funcall-interactively command-execute nil nil = nil nil nil nil nil nil nil nil nil] 1024 [comment-normalize-vars = comment-indent comment-indent-new-line default-indent-new-line = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil] 1024 [comment-indent comment-indent-new-line = default-indent-new-line funcall-interactively command-execute nil nil = nil nil nil nil nil nil nil nil nil] 101824 [make-closure syntax-ppss = show-paren--default show-paren-function apply timer-event-handler nil = nil nil nil nil nil nil nil nil nil] 8288 [string-prefix-p = treesit-query-range treesit--update-ranges-local treesit-update-ranges = treesit--pre-redisplay run-hook-with-args = redisplay--pre-redisplay-functions redisplay_internal\ \(C\ function\) = nil nil nil nil nil nil nil nil] 7187 [delete-backward-char = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil nil nil] 25144 [treesit-query-range = treesit--update-ranges-local treesit-update-ranges = treesit-font-lock-fontify-region font-lock-fontify-syntactically-region = font-lock-default-fontify-region font-lock-fontify-region "#" jit-lock--run-functions jit-lock-fontify-now = jit-lock-function redisplay_internal\ \(C\ function\) nil nil nil nil] = 4144 [line-move-visual line-move previous-line funcall-interactively = command-execute nil nil nil nil nil nil nil nil nil nil nil] 4748 = [completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil nil nil nil] = 37647 [timer--time-setter timer-set-time run-at-time = undo-auto--boundary-ensure-timer undo-auto--undoable-change = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil] 24 = [minibuffer--regexp-setup completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil nil nil nil] 1024 [string-match = pgtk-device-class device-class minibuffer-setup-on-screen-keyboard = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil] 1024 [sit-for = icomplete-exhibit icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil nil] 816 [menu-bar-update-buffers-1 = menu-bar-update-buffers redisplay_internal\ \(C\ function\) sit-for = icomplete-exhibit icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil] 1008 [redisplay_internal\ \(C\ function\) sit-for = icomplete-exhibit icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil] 168822 [mode-line-default-help-echo = redisplay_internal\ \(C\ function\) sit-for icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil] 8184 [completion-pcm--pattern->regex = completion-pcm--all-completions completion-substring--all-completions = completion-flex-all-completions "#" = "#" mapc seq-do seq-some = completion--nth-completion completion-all-completions = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions icomplete-exhibit icomplete-post-command-hook] = 1152 [all-completions complete-with-action "#" = completion-pcm--all-completions completion-substring--all-completions = completion-flex-all-completions "#" = "#" mapc seq-do seq-some = completion--nth-completion completion-all-completions = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions] 4352 [version-to-list "#" all-completions complete-with-action "#" = completion-pcm--all-completions completion-substring--all-completions = completion-flex-all-completions "#" = "#" mapc seq-do seq-some = completion--nth-completion completion-all-completions = completion-all-sorted-completions] 3328 [delete-dups = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions icomplete-exhibit icomplete-post-command-hook = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil] 113424 = [minibuffer--sort-by-length-alpha completion-all-sorted-completions = icomplete--sorted-completions icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil] 53296 [minibuffer--sort-by-position = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions icomplete-exhibit icomplete-post-command-hook = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil] 64 = [minibuffer--sort-by-key minibuffer--sort-by-position = completion-all-sorted-completions icomplete--sorted-completions = icomplete-completions icomplete-exhibit icomplete-post-command-hook = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil] 85344 ["#" = read-extended-command--affixation icomplete--augment = icomplete--render-vertical icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil] 162492 [move-overlay icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil nil] 24 [format icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil nil] 6378 [redisplay_internal\ \(C\ = function\) completing-read-default read-extended-command-1 = read-extended-command byte-code command-execute nil nil nil nil nil nil = nil nil nil nil] 399513 [funcall-interactively command-execute = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil nil] 80 = [self-insert-command funcall-interactively command-execute = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil] 288 = [completion--flex-score "#" mapcar = "#" completion-all-sorted-completions = icomplete--sorted-completions icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil] 2304 [icomplete--render-vertical icomplete-completions = icomplete-exhibit icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil] 117856 [completion--hilit-from-re = "#" completion-lazy-hilit = icomplete--render-vertical icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil] 8128 [frame-height max-mini-window-lines = icomplete--render-vertical icomplete-completions icomplete-exhibit = icomplete-post-command-hook completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil] 8184 [timer--time-setter timer-set-time run-at-time = run-with-timer blink-cursor--start-timer blink-cursor-start apply = timer-event-handler completing-read-default read-extended-command-1 = read-extended-command byte-code command-execute nil nil nil] 24 = [timer--time-less-p timer--activate timer-activate run-at-time = run-with-timer blink-cursor--start-timer blink-cursor-start apply = timer-event-handler completing-read-default read-extended-command-1 = read-extended-command byte-code command-execute nil nil] 24 = [timer-relative-time timer-inc-time timer-event-handler = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil] 56 = [timer--time-setter timer-inc-time timer-event-handler = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil nil] 24 = [time-less-p timer-event-handler completing-read-default = read-extended-command-1 read-extended-command byte-code command-execute = nil nil nil nil nil nil nil nil nil] 24 [timer--time-less-p = timer--activate timer-activate timer-event-handler = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil nil nil nil] 24 = [completion--replace minibuffer-force-complete = minibuffer-force-complete-and-exit icomplete-force-complete-and-exit = icomplete-fido-ret funcall-interactively command-execute = completing-read-default read-extended-command-1 read-extended-command = byte-code command-execute nil nil nil nil] 72 [execute-extended-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil nil nil] 59696 [command-execute execute-extended-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil nil nil] 49783 [funcall-interactively command-execute = execute-extended-command funcall-interactively command-execute nil nil = nil nil nil nil nil nil nil nil nil] 16 [profiler-stop = funcall-interactively command-execute execute-extended-command = funcall-interactively command-execute nil nil nil nil nil nil nil nil = nil nil] 1563900 [Automatic\ GC nil] 17704)) (26057 13278 386045 775000) = nil] --Apple-Mail=_26C946C9-038F-483D-A2E8-17D91DD9E186 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks, the culprit is the call to treesit-update-ranges in = treesit--pre-redisplay, where we don=E2=80=99t pass it any specific = range, so it updates the range for the whole buffer. Eli, is there any = way to get a rough estimate the range that redisplay is refreshing? Do = you think something like this would work? (treesit-update-ranges (max (point-min) (- (window-start) 1000)) ; BEG (min (point-max) (+ (or (window-end) (+ (window-start) 4000)) = 1000))) ; END I guess the window-start would be outdated in pre-redisplay-function... Yuan= --Apple-Mail=_26C946C9-038F-483D-A2E8-17D91DD9E186--