-
Notifications
You must be signed in to change notification settings - Fork 109
fix slow highlighter on vim 7.4 #80
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
base: master
Are you sure you want to change the base?
Conversation
Uses "syntax keyword" instead of "keyword match" to find subjects to highlight, which is much faster. The problem is that the type of regex used by vim-easytags is a pathological bad case for the NFA regex engine which was introduced in vim 7.4. As reported here: https://groups.google.com/forum/#!topic/vim_dev/cPcMap1BdQw The patch was taken from the vim-easytags issues list on github, credit for it goes to @juliantaylor.
Meh, I've been using this and suddenly it's slow again, now I really don't know what's happening anymore. Perhaps I'll just wait until ZyX gets the VimL to Lua(JIT) translator working and see how it can be done entirely on the script side... |
the slow part is the regex engine, unless viml also exchanges that or reverts the default back to vims old engine (set re=1 I think) a JIT is not going to help |
you may be able to speed some things up by only searching for words in the displayed file instead of all, but the extra check is typically not worth it unless you have a ridiculously large tag database. |
I also wonder why this even needs a regex. I haven't looked at the code in-depth but from the length of the regex it seems that it's loading in a big chunk of the tag database, and telling vim:
It seems a bit extreme. Might be better to just keep a patricia trie of the tag database around (and periodically update it), and just loop over the entire document querying the patricia trie if the symbol is present. This is the sort of thing that would be easy squeezy in a really fast scripting language. |
Disregard my earlier comment about it being slow again. Somehow I wasn't using my fork with the patch applied as I originally thought. So, with this patch applied (and python support enabled), vim is workable again! Since neovim doesn't have python support yet, I can't edit my files with neovim, which is a real shame. |
Not just for the python version anymore. It does help, the first highlight seems slow, but afterwards I can actually navigate a file without burning my house down, which is a huge improvement.
Turns out that applying the same thing to the VimL side of the story also has beneficial effects, of course ;). |
@xolox I notice you've given your ole' project another look again, so I would like to request a comment about whether these 2 tiny commits are valid or not. They do seem to improve the responsiveness a lot and the changes are not nearly as invasive as the async branch. Speeding up the non-async codepath will make putting off async support much more bearable. As well as sparing my poor laptop more. That would allow me to use xolox/vim-easytags again in vundle :). By the way, I'm also a neovim contributor and I'm investigating some of the reasons why the vim codepath is slow (like The only thing that's a bit of a pain and will be difficult to optimize directly is the regex syntax highlighting, but perhaps we'll be able to work around that. By the way, the neovim job feature would be quite ideal for async support, I think. None of that clientserver horsing around. But I think you don't want to go down that route just yet, as it's not present in vanilla vim. Since I can't live without this plugin, it's effectively stopping me from using the editor on which I work ;). |
They are valid from your perspective (performance) but not from my perspective (e.g. you removed all references to On the other hand I'm open to thinking about performance improvements like using |
there is also a way to choose the old regex engine for specific regexes only |
@juliantaylor: Thanks for the hint, I'll take a look. A hybrid approach does seem best to me. |
Please try out version 3.6 (see b6f8757) and let me know how it works for you. By default it may still be slow, but take a look at the new g:easytags_syntax_keyword option. Note that 3.6 includes 3.5 which merged a huge feature branch, so here's hoping that works out well... |
Forgot to mention one thing: Please note that right now this 'feature' is not integrated with the "accelerated Python syntax highlighting" feature, because I'm considering ripping that out and replacing it with a fast Vim script implementation (if I can build one :-). |
For neovim, even when integrating the keyword fix, it still locks up too much (you wouldn't believe the # of calls to
The first one was more or less eliminated by this patch, but the second one still exists. For vanilla vim, which I use with python enabled, the regex bottleneck still exists (as you mention, it's not integrated), yet the So now both codepaths have exactly 1 bottleneck :). Do you have any idea about how you would rewrite the vim part (on a high level) to perform better? When I get some more time for neovim I'm going to try to optimize some parts of the vimscript engine to make |
@aktau: The number of strings/lists/dictionaries created and destroyed during a single About optimizing, one thought came to mind: When I originally created the accelerated Python syntax highlighting I noticed how fast it is compared to the Vim script version while they mostly do the same thing. I can think of two reasons:
You specifically mention Last but not least: A long time ago I created simple functions to accurately time code execution in a way that can be easily presented to the user in a human friendly format. Nothing is stopping me from using these functions in a more granular way so that we can easily pick apart |
Exactly, the
Indeed. I might be misremembering, in which case its
This (plus
A high-level view from the VimL side could help my diagnosis of the issue as well. |
See also xolox/vim-easytags#80 where I suggested to add accurate timing to the vim-easytags plug-in. This change will facilitate that.
See also #80 where I suggested to add accurate timing to the vim-easytags plug-in. Here it is :-). This is still quite rudimentary but it's already an improvement over what was there before!
Uses "syntax keyword" instead of "keyword match" to find subjects to
highlight, which is much faster. The problem is that the type of regex used
by vim-easytags is a pathological bad case for the NFA regex engine which
was introduced in vim 7.4.
As reported here:
https://groups.google.com/forum/#!topic/vim_dev/cPcMap1BdQw
The patch was taken from the vim-easytags issues list on github, credit for
it goes to @juliantaylor.
Fixes issue #68.