xolox / vim-easytags

Automated tag file generation and syntax highlighting of tags in Vim
http://peterodding.com/code/vim/easytags/
1.01k stars 109 forks source link

Vim hangs when generating a large tags file #145

Open rvega opened 8 years ago

rvega commented 8 years ago

I have a very large project (the linux kernel, actually) and I'm running :UpdateTags -R within it. I can see the ctags process running and the tags file being created in /tmp/tags.xxxx. When the ctags process finishes, however, the /tmp/tags.xxxx file disappears, vim hangs with 100% cpu consumption (not ctags but vim), starts filling up all my memory and the system becomes very unresponsive. I have waited far too long (hours) but the vim process never stops or goes back to normal.

Here's my relevant configuration in vimrc:

set tags=./tags;
let g:easytags_dynamic_files = 1
let g:easytags_async = 0
let g:easytags_auto_highlight = 0
let g:easytags_include_members = 1

I'm running latest vim compiled by myself and loading the vim-easytags plugin with https://github.com/junegunn/vim-plug

Can someone please help debug this issue?

rvega commented 8 years ago

Maybe this is related to the fact that easytags is outputting the results of ctags to stdout which is then caught by the plugin and it can't handle large files nicely? (the -f- parameter) As a workaround, I'm running ctags --fields=+l --c-kinds=+p --c++-kinds=+p --sort=no -ftags --extra=+q -R to generate the tags.

mike-zueff commented 8 years ago

Hello @rvega,

Have you tried to use vim-easytags in asynchronous mode?

let g:easytags_async=1

Also please ensure that you have this variable disabled (if you use YCM as well):

let g:ycm_collect_identifiers_from_tags_files=0

This configuration works fine for me for some large projects like the kernel.

rvega commented 8 years ago

Thanks @mike-zueff. The issue happens with async turned on or off. I do use YCM but adding that line (which I didn't have before) does not fix the issue. To be clear, using the tags for jumping, completion, etc. is no problem. Generating the tags is when everything hangs.

aktau commented 7 years ago

Yea, the Linux kernel generates a tags file anywhere between 412MiB to 500+MiB (depending on whether you use relative tag paths, which I don't think vim-easytags supports). Without async, this is then loaded into the plugin for two purposes (that I can see):

  1. To combine it with the existing tags file (if any). This is redundant when using the -R option but I believe vim-easytags still does it.
  2. To pass all the tags to Vim for highlighting.

Needless to say, processing half a GiB of a data in VimL is excruciatingly slow, though it could likely be made faster (@xolox has left comments to this effect in the source code).

Honestly, the async options should have fixed it for you. What OS are you on? Do you see a second Vim process spawn? That one is used for async processing and should be soaking up all the CPU.

With async, only the step concerning highlighting of tags could be slow, as that still happens in the main Vim project. Which language are you editing? Anyway, try this option:

let g:easytags_syntax_keyword = 'always'

If highlighting was the problem, this might make it a lot faster.

Are you using Neovim or Vim8? If you're using Neovim, I'd advise installing the Python (3) host if you haven't already. You can see whether it's currently installed by running :CheckHealth. To install the provider, see :help provider-python.