-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow Markdown Highlighting #4139
Comments
With
I am led to believe that Markdown is a bit slow for now and the author intends to improve it in the future. Did you try the flamegraph on the version before the Markdown update? I am also on Linux (AlmaLinux 9) using the latest Kitty terminal. |
Ok I tested again before the update to the markdown grammar. I am very surprised that you do not notice this. Its very noticeable when comparing between editing rust and working on a somewhat large markdown file (1k loc). I sit at a constant 10% CPU utilization (which is a lot considering my CPU). The second I close the file (or switch to a rust file for example) the utilization drops to1%. Just an example which might better highlight my problem: When I edit the following line from the helix changelog: - The `extend_line` command has been replaced with `extend_line_below` and a new `extend_line` command now exists ([#3046](https://github.com/helix-editor/helix/pull/3046)) I start holding backspace at the EOL and let got at the first - The `extend_line` command has been replaced with `extend_line_below` and a new `extend_line` command now exists ([#3046]( but instead helix keeps deleting: - The `extend_line` command has been replaced with `extend_line_below` and a new `extend_line` This seems pretty extreme to me in terms of lag. |
I tried your test with the changelog and my results were even worse, it deleted the entire line! Perhaps @MDeiml could comment? Some threads maxed out: I also tried on some technical writing I was working on which is mostly just prose of 700 lines with many embedded code blocks. I am using the Gnome system monitor and it reads 0.04-0.13% for Kitty running Helix with the file being edited/marksman language server running on an ancient Intel Haswell i7. I found no lag editing that. Could it be all the links in the changelog are causing the slowdown? There is something going on... |
Okay its definitely the links, by simply removing all of them completely fixes the lag. |
Are you sure that this is really the same grammar? To me this looks like helix simply spends a ton of time calling the TS parser during the deletions. |
Yeah, I checked the grammar commit nvim-treesitter/nvim-treesitter#3048 against the date I last updated the plugin and it is the new split version: Date split parser was added to
|
Thanks for looking into this :) I know my way around the helix highlighting implementation so I will try to find out what helix is doing differently here and fix the bug. I am going to have to look at nvim-treesitter to find out what they are doing differently... Which is going to be a pain (lua + C is not nearly as nice to read as rust) |
I think I found the cause: The links are highlighted using injections and injections are currently not parsed incrementally.
I am looking into addressing this but its not trivial. |
This is fixed by #4146. |
I'm sorry I didn't participate in the discussion. Just wanted to say thank you, I think this was the best solution. The markdown grammar is slow, and that probably can't be fixed, but making parsing fully incremental should make any tree sitter parser sufficiently fast. I'm guessing this also sped up a lot of other grammars 👍 |
Summary
Since the recent update to the markdown grammer by @David-Else, I have noticed extreme slowdown on markdown files. For example if I hold down backspace and then let go, helix keeps deleting for roughly 0.5seconds.
I have a very beefy PC so this should really not be happening and do not see issues for any other language.
To isolate problems I have disabled the LSP but the problem persists until I turn of syntax highlighting (
set-language text
) completly.Looking at the flamegraphs (with LSP disabled) I noticed that a ton of time seems to be spend on parsing TS compared to other languages (rust in this example)
opening and deleting some text in a md file:
opening and deleting some text in a rust file:
Reproduction Steps
Open any markdown file with syntax highlighting enabled and started deleting text
Helix log
No response
Platform
Linux
Terminal Emulator
alacritty
Helix Version
22.08.1-165-g4d4be0e8
The text was updated successfully, but these errors were encountered: