Slow opening of files

What happened?

Opening files is slow to the point that opening a file with thousand lines takes few seconds. It only seems to affect Elixir files, other files (like javascript or text) are unaffected. I am on a reasonably fast PC (Dell XPS 13 with intel i7).

I tried profiling loading the file which always seems to point to dtrt-indent-mode. Full profile below.

9591  74% - command-execute
8462  65%  - funcall-interactively
8285  64%   - execute-extended-command
8285  64%    - apply
8183  63%     - doom--fix-broken-smie-modes-a
8183  63%      - let
8183  63%       - let
8183  63%        - let*
8183  63%         - unwind-protect
8183  63%          - progn
8183  63%           - let
8183  63%            - let*
8183  63%             - unwind-protect
8183  63%              - progn
8183  63%               - funcall
8183  63%                - #<subr dtrt-indent-mode>
8178  63%                 - smie-config-guess
8178  63%                  - condition-case
8178  63%                   - funcall
8178  63%                    - #<subr smie-config-guess>
8174  63%                     - smie-config--guess
8170  63%                      - smie-config--get-trace
8134  63%                       - smie-indent-calculate
8134  63%                        - smie--funcall
5607  43%                         - smie-indent-after-keyword
3426  26%                          + smie-indent--rule
1876  14%                          + smie-indent-virtual
 304   2%                          + smie-indent-backward-token
1938  15%                         - smie-indent-keyword
1716  13%                          + smie-backward-sexp
 216   1%                          + smie-indent--rule
   4   0%                          + smie-indent-forward-token

Tried enabling tree-sitter but that didn’t have any effect. Also tried adding .editorconfig to bypass the indent-mode but that didn’t work also.

I had issues similar issues on Vim when using folds based on syntax, maybe this could be something similar. In Vim I was able to solve it by turning off syntax-based folding. I have little knowledge of emacs to know this is the same issue, but it feels like it.

What did you expect to happen?

Files should open reasonably fast.

Steps to reproduce

Haven’t yet tried to reproduce on a clean config. Can try if it will be relevant. Generally I just open a file and it takes a long time. LSP and tree-sitter startup doesn’t cause this, as the delay happens every time I open a new buffer, even if LSP and tree-sitter are already loaded.

System information


Loading data dump...

For now I just disable indentation detection in elixir-mode, which solve the issue. Not a perfect solution but since I usually use formatter with Elixir it’s not that big a deal.

Added this to config.el.

(add-to-list 'doom-detect-indentation-excluded-modes 'elixir-mode)

Yup, upstream issue: Opening largish files is crazy slow due to SMIE · Issue #463 · elixir-editors/emacs-elixir · GitHub

The Elixir module is fairly small. If this bothers you enough, when you are on 29 you could copy the module into your $DOOMDIR/modules and replace elixir-mode with elixir-ts-mode yanked from Emacs upstream as elixir-mode suggests.

Marking your workaround as the solution

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.