Skip to content

Opening largish files is crazy slow due to SMIE #463

Open
@bitwalker

Description

@bitwalker

I have an Elixir file with ~4k lines in it, more than a few of them actually - and every time I open them, it takes ~10-20 seconds for the file to open. Its honestly driving me nuts.

I ran the profiler to see what is going on, and it looks like the only thing taking any meaningful time at all is elixir-mode's use of SMIE, in particular the elixir-smie--semi-ends-match function and its use of looking-back. It so utterly dominates the samples in the profiler, that fixing this would completely fix the problem I'm seeing (and presumably others are seeing as well, its wild to me that this isn't reported already).

It seems to me that a much more efficient method than is currently used in elixir-smie--semi-ends-match should be possible, or at least use some heuristics to avoid backtracking nearly as much as it does currently. The documentation for looking-back specifically states to avoid using it wherever possible, and we're using it twice to first detect elixir-smie--block-operator-regexp but then reject .+fn.+. At a minimum it would be faster to add a specialized regex that does that match in one go. If I knew more about how all the pieces fit together, I'd take a stab at rewriting it, but wanted to get some feedback first. Have you seen this issue? If so, how have you handled it in your own config?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions