Skip to content

Strange freeze when finding a clojure/clojurescript file (seems to be inside treesit-query-compile) #109

Closed
@alexispurslane

Description

@alexispurslane

Expected behavior

Loading files under a reasonable size basically instantly, as with other tree-sitter modes (Rust, TSX, and Bash are others I've tested for comparison).

Actual behavior

A strange... hang, for a second, whenever I open a clojure or clojurescript file with my editor set up to use clojure-ts-mode for them.

Profiles:

    112,106,431  95% - command-execute
    112,106,431  95%  - funcall-interactively
    112,106,431  95%   - god-mode-self-insert
     86,508,896  73%    - funcall-interactively
     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
          5,120   0%              file-remote-p
          3,072   0%            + set-auto-mode--find-matching-alist-entry
          2,048   0%              file-name-sans-versions
         62,464   0%           + hack-local-variables
         34,816   0%           + set-auto-mode-1
         28,672   0%           + inhibit-local-variables-p
         16,376   0%           + hack-dir-local--get-variables
          1,024   0%             looking-at
      4,650,744   3%          + font-lock-mode
          7,911   0%          + run-hooks
        106,331   0%         + run-hooks
          9,208   0%         + make-auto-save-file-name
          1,024   0%           backup-file-name-p
         48,775   0%        + insert-file-contents
          1,024   0%          abbreviate-file-name
          8,184   0%       + find-buffer-visiting
          2,048   0%         abbreviate-file-name
          2,048   0%         string-match
          2,048   0%         file-truename
             21   0%       + create-file-buffer
          2,506   0%      + pop-to-buffer-same-window
      1,587,548   1%     + execute-extended-command
          2,357   0%     + kill-buffer
     21,584,390  18%    + byte-code
      2,940,040   2%    + completing-read-default
      1,068,919   0%    + god-mode-lookup-key-sequence
          4,186   0%    + format-prompt
      2,789,025   2% + redisplay_internal (C function)
      2,586,883   2% + timer-event-handler
         12,288   0% + corfu--auto-post-command
          8,288   0% + winner-save-old-configurations
          4,200   0% + #<byte-code-function 737>
          3,072   0% + gcmh-register-idle-gc
            328   0% + #<interpreted-function 077>
             80   0% + motion-selection--motion-selection
              0   0%   ...

         481  80% - command-execute
         481  80%  - funcall-interactively
         481  80%   - god-mode-self-insert
         262  44%    - funcall-interactively
         261  43%     - project-find-file
         261  43%      - project-find-file-in
         205  34%       - find-file
         205  34%        - find-file-noselect
         202  34%         - find-file-noselect-1
         200  33%          - after-find-file
         195  32%           - normal-mode
         189  31%            - set-auto-mode
         188  31%             - set-auto-mode--apply-alist
         188  31%              - set-auto-mode-0
         188  31%               - clojure-ts-clojurescript-mode
         164  27%                - clojure-ts-mode
         114  19%                 - treesit-major-mode-setup
         114  19%                  - treesit-validate-font-lock-rules
          91  15%                     treesit-query-compile
          23   3%                   clojure-ts--ensure-grammars
          10   1%                 + treesit-ready-p
           1   0%                 + clojure-ts-mode-variables
          24   4%                + run-mode-hooks
           1   0%             + hack-dir-local--get-variables
           6   1%            + font-lock-mode
           5   0%           + run-hooks
           2   0%            insert-file-contents
           1   0%           abbreviate-file-name
           1   0%         + file-truename
           1   0%         + find-buffer-visiting
          52   8%       + project--read-file-name
           4   0%       + project-files
           1   0%     + execute-extended-command
         122  20%    - god-mode-lookup-key-sequence
          85  14%     - god-mode-lookup-command
          85  14%      - apply
          85  14%       - which-key--god-mode-lookup-command-advice
          85  14%        + #<native-comp-function god-mode-lookup-command>
          37   6%     + god-key-string-after-consuming-key
          97  16%    + byte-code
          91  15%   redisplay_internal (C function)
          11   1% + ...
          10   1% + timer-event-handler
           1   0% + which-key--hide-popup

Steps to reproduce the problem

find-file, or anything that involves it, really.

Operating System Version

aarch64-apple-darwin24.5.0 (Apple Mac Studio M1 Max running macOS 15.5 Sequoia).

Emacs Version

feature/igc emacs 31.0.50 from HEAD. (Also tried Emacs 30.1 from the homebrew emacs-plus package and had the same issues.)

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 -I/opt/homebrew/opt/gcc/15/ -L/opt/homebrew/opt/gcc/15/ -Wl,-rpath,/opt/homebrew/opt/libmps/15/ -I/opt/homebrew/opt/libmps/include -I/opt/homebrew/opt/libgccjit/include' 'LDFLAGS=-L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/libmps/lib -L/opt/homebrew/opt/libgccjit/lib' PKG_CONFIG_PATH=/usr/lib/pkgconfig/:/opt/homebrew/share/pkgconfig/

System Configuration Features: `ACL GLIB GNUTLS IMAGEMAGICK LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS

clojure-ts-mode version

Include here the version string displayed by M-x clojure-ts-mode-display-version. Here's an example:

clojure-ts-mode 0.4.0-snapshot (package: 20250512.2008)

tree-sitter-clojure grammar version

Tried with https://github.com/sogaiu/tree-sitter-clojure.git v0.0.12 and the problem persists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions