GNU bug report logs -
#78697
`treesit-major-mode-setup` causing substantial pause when finding a file
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
# Problem
As the title says: `treesit-major-mode-setup` appears to be causing a substantial pause when finding a file that involves tree sitter modes (that I have installed). I'm unclear s to why.
# Detailed Information
## System
Apple Mac Studio M1 Max running macOS 15.5 Sequoia (`aarch64-apple-darwin24.5.0`) (temporarily using it instead of my Linux machine for work reasons)
## Emacs
I've tried a few variations of Emacs to root out the problem:
### emacs-plus <at> 31 from Homebrew
System Configuration Options: `--disable-dependency-tracking --disable-silent-rules --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp --infodir=/opt/homebrew/Cellar/emacs-plus <at> 31/31.0.50/share/info/emacs --prefix=/opt/homebrew/Cellar/emacs-plus <at> 31/31.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 'CFLAGS=-O2 -DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT'`
System Configuration 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`
#### Issues:
- Random freezes all the time
- Substantial freezes when opening a file
### `feature/igc` emacs 31.0.50 from HEAD
System Configuration Options: `--prefix=/usr/local --with-tree-sitter --with-xwidgets --with-ns --with-native-compilation=aot --with-imagemagick --without-compress-install --with-small-ja-dic --without-selinux --without-gsettings CC=clang 'CFLAGS=-O3 -march=native`
System Configuration Features: `ACL GLIB GNUTLS IMAGEMAGICK LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM XWIDGETS ZLIB`
#### Issues
- Thanks to the experimental MPS garbage collector, the random intermediate pauses have gone away (although it's still odd they were there – even without MPS my Emacs configuration doesn't pause randomly on Linux)
- However, while shorter, the pauses upon opening a new file are the same.
### same as above but with `treesit-auto` disabled
Profiling the previous two versions seemed to indicate that a function in the `treesit-auto` package was to blame, so I disabled `treesit-auto-mode` to see if that made a difference; it did not. However, it narrowed down the issue further:
#### Issues
- There is no undue pause when opening any other kind of file; only tree-sitter enabled files are so slow.
- Most time opening a file (38%) is spent within `treesit-major-mode-setup`:
```
112,106,431 95% - command-execute
...
84,918,927 72% - find-file
84,916,421 72% - find-file-noselect
84,902,072 72% - find-file-noselect-1
84,852,273 72% - after-find-file
84,735,710 72% - normal-mode
80,077,055 68% - set-auto-mode
79,933,703 68% - set-auto-mode--apply-alist
79,923,463 68% - set-auto-mode-0
79,923,463 68% - clojure-ts-clojurescript-mode
45,382,937 38% - clojure-ts-mode
45,305,561 38% + treesit-major-mode-setup
25,386 0% + treesit-ready-p
20,512 0% + clojure-ts-mode-variables
17,202 0% clojure-ts--ensure-grammars
8,288 0% + clojure-ts--compute-semantic-indentation-rules-cache
34,540,526 29% + run-mode-hooks
...
```
The function `clojure-ts-clojurescript-mode` seems to add significant overhead as well, even though it appears to be a simple derived mode that doesn't even have any body forms. It didn't have any problem on Linux.
I'm rather at a loss as to what's going on.
[publickey - alexispurslane@pm.me - 0x41E61568.asc (application/pgp-keys, attachment)]
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 10 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.