-
Notifications
You must be signed in to change notification settings - Fork 25
Bad performance when refresh highlight in large file #42
Comments
Hi, sorry for taking so long to reply. There's a bug in vim-lsp-cxx-highlight with newer versions of neovim which causes highlighting to clear whenever it's updated. You're not supposed to notice when the highlight refreshes (apart from when adding new lines) as the old highlight shouldn't clear until the new highlighting is fully applied. I fixed it in 054d571 but I'm not sure if you are experiencing this exact bug or just feel that the plugin is sluggish. If it's general slowness there's a lot of things that factor into this. I agree that a parsing time of usually 100-500ms isn't ideal but I personally haven't noticed vim or neovim visibly locked up/hanging as a result. Generally I would attribute most of the performance issues to vimscript and vim/neovim's single threaded execution. As much as I don't particularly like writing vimscript and it's super slow, it still offers the best user experience for most. I also don't think breaking this plugin into a separate application is necessary given the small scope of what this plugin does. This would make the installation process much more complicated and some users would likely consider it a non-starter to have to do anything other than just clone the repo, even worse if they have to compile rust or c++ code. One possibility I had in mind was to write some of the compute portions in lua and enable it on neovim via the builtin lua system. Using lua could provide a moderate speedup but I haven't written lua in many years so I haven't got around to it. Please let me know if the mentioned fix makes a difference for you. |
It's sluggish, and I don't feel the patch exactly speeds up the cxx. 100-500ms of STW for the large file is improvable, I found that the sluggish code is
It maybe uses the cache to prevent the rendered line from render again. BTW vim-lsp-cxx-highlight/syntax/lsp_cxx_highlight.vim Lines 26 to 34 in 054d571
default for highlight
|
Sorry to hear that wasn't the fix, but if you believe there's room for optimizing I would be happy to accept a PR. Thanks for noticing the syntax file bug. I missed that since I copied the suggestion from one of the comments and forgot to adjust it. |
Do you think using When cxx received the BTW, I use nvim-treesitter, if cxx could provide a whitelist to render is the best, most of highlighting could be done by nvim-treesitter. |
I have met the perfomance problem too. Each edit causes a long time slag.
|
Describe the bug
didopen and didsave will trigger cxx to highlight the overall symbols in the buffer.
Without triggering these events, the highlight looks weird after editing.
If the file is large enough, it will make neovim hang for a few hundred milliseconds.
Maybe cxx should use asynchronous tech such as RPC or refresh the current view window first?
To Reproduce
git clone https://github.com/neovim/neovim.git && cd neovim
bear make CMAKE_INSTALL_PREFIX=$HOME/.local
nvim -u ~/mini.vim src/nvim/window.c +1000
yy
p
:w
cat ~/mini.vim
Expected behavior
highlight as smooth as possible.
Configuration (Fill this out):
Log File:
the content of log is redundant, so I post the file instead of paste its content directly.
lsp-cxx-hl.log.tar.gz
The text was updated successfully, but these errors were encountered: