vim-easytags icon indicating copy to clipboard operation
vim-easytags copied to clipboard

very slow for big project

Open lookforit opened this issue 10 years ago • 20 comments

Hi Be sorry to refer to this old topic again, but I can't find the answer in the posted issues. When open a relative big(such as vim source code) project ,easytags makes cursor poor response,except I disable it manually. I noticed that the tag files of the project is about 3Mb, so I wonder how to open a much larger project(eg Linux kernel) with easytags enabled. Thanks.

lookforit avatar Sep 27 '13 01:09 lookforit

are you using vim 7.4? the 7.4 regex engine is very bad for how easytags uses it. see https://groups.google.com/forum/#!topic/vim_dev/cPcMap1BdQw

as suggested replacing syntax match with syntax keyword solves the issue for me.

juliantaylor avatar Oct 10 '13 17:10 juliantaylor

@juliantaylor could you please submit a pull request so that I can test this on my side?

gpakosz avatar Nov 14 '13 10:11 gpakosz

I applied this patch which works for me, not it drops suffix, don't know what its used for:

--- a/misc/easytags/highlight.py
+++ b/misc/easytags/highlight.py
@@ -51,5 +51,5 @@ def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffi
     return ' | '.join(commands)

 def _easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax):
-    template = r'syntax match %s /%s\%%(%s\)%s/ containedin=ALLBUT,%s'
-    return template % (syntaxgroup, prefix, r'\|'.join(patterns), suffix, ignoresyntax)
+    template = r'syntax keyword %s %s containedin=ALLBUT,%s'
+    return template % (syntaxgroup, r' '.join(patterns), ignoresyntax)

you can also switch back to the old regex engine with:

set regexpengine=1

juliantaylor avatar Nov 14 '13 12:11 juliantaylor

The patch seems to work nicely on vim 7.4, the speed was crippling before this but now it's fine.

aktau avatar Feb 27 '14 15:02 aktau

I have to add though: after adding the patch, nothing is highlighted anymore. So the patch has the effect of disabling the highlighter somehow. Yet it's better than not being able to move my cursor around...

aktau avatar Feb 27 '14 15:02 aktau

hm the highlighter is still working for me with the patch, what kind of files are you looking at?

juliantaylor avatar Feb 27 '14 17:02 juliantaylor

Just plain C files :)

On Thu, Feb 27, 2014 at 6:30 PM, Julian Taylor [email protected]:

hm the highlighter is still working for me with the patch, what kind of files are you looking at?

Reply to this email directly or view it on GitHubhttps://github.com/xolox/vim-easytags/issues/68#issuecomment-36267814 .

aktau avatar Feb 27 '14 23:02 aktau

@lookforit @juliantaylor my bad, it was a crazy wildignore issue on my part. Everything works perfectly now, thanks for the patch!

aktau avatar Feb 28 '14 09:02 aktau

Patch works perfectly with 7.4.135 thanks @juliantaylor

q6r avatar Mar 02 '14 07:03 q6r

Patch works perfectly with 7.4.135 thanks @juliantaylor

Yes, @xolox perhaps you could merge this with a version check for 7.4? That would be awesome and I wouldn't have to manually patch half of my vim installations :)

aktau avatar Mar 02 '14 10:03 aktau

Was this patched into master?

mikedfunk avatar Mar 18 '14 17:03 mikedfunk

@mikedfunk it was not, unfortunately. @xolox could you merge this please? If not, what still needs to be done?

aktau avatar Apr 29 '14 15:04 aktau

Please try out version 3.6 (see b6f8757d004d5f4ef7280fd111a21821e6bee79a) 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...

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 :-).

xolox avatar Jul 08 '14 23:07 xolox

Ran into some minor issues with the new syntax keyword feature, all of them fixed now (see the commits referenced above this message in the GitHub issue).

xolox avatar Jul 09 '14 19:07 xolox

I'm running 3.9 (075ffe90) on Vim 7.4.473.

@aktau commented on 28 Feb

The patch seems to work nicely on vim 7.4, the speed was crippling before this but now it's fine.

@aktau commented on 28 Feb

I have to add though: after adding the patch, nothing is highlighted anymore.

I just manually patched this. It does successfully

  1. stop the slowdown,
  2. retain the highlighting.

@xolox commented on 9 Jul

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.

letting g:easytags_python_enabled="always" in a buffer already editting a C file doesn't seem to fix the issue. Re-opening the file with :e doesn't either.

letting g:easytags_python_enabled=0 doesn't seem to work either (scrolling still slow afterwards).

shtrom avatar Nov 19 '14 04:11 shtrom

@shtrom: Please change the setting in your vimrc, restart Vim and see if it helps at all then. If that does indeed help then maybe old highlighting patterns (which are cleared by vim-easytags, just for the record) somehow remain in memory, throwing Vim off?

xolox avatar Nov 19 '14 07:11 xolox

Having restored vim-easytags to 075ffe9, I first tried to set let g:easytags_python_enabled="always", then let g:easytags_python_enabled=0, to no avail. I then created a vimrc from scratch with the minimum to run easytags, and did not notice any slow down. So I started disabling my other plugins.

The problem seems to come from amdt/vim-niji, and is there even when easytags is disabled.

I should have tried that earlier... Sorry for the noise.

shtrom avatar Nov 20 '14 02:11 shtrom

@shtrom: Thanks for the follow up, it's not always easy or obvious to find out what slows Vim down, I know all about this ;-).

xolox avatar Nov 22 '14 11:11 xolox

I just installed easytags, and I am experiencing massive delay. I applied the patch specified earlier in this post to my easytags, but there is no change. I am running vim 7.4. To verify that it is easy tags, here is the result from vim's profiling operation:

list of all functions ran

FUNCTIONS SORTED ON SELF TIME
count   total (s)   self (s)  function
3       36.393659   36.391486 <SNR>99_highlight_with_python()
1       36.416279   0.022375  xolox#easytags#highlight()
43      0.020129    0.014926  <SNR>132_ParseTagline()
2                   0.005630  signature#mark#GetList()
7       0.004975    0.004963  <SNR>132_SortTags()
1       0.043953    0.004553  <SNR>132_ProcessFile()
170                 0.004173  <SNR>132_CompareByKind()
52                  0.003358  signature#sign#Remove()
5       0.003738    0.002010  neobundle#autoload#function()
45                  0.001900  128()
43      0.002157    0.001887  134()
7       0.001889    0.001780  <SNR>132_AddScopedTags()
8       0.001861    0.001770  <SNR>132_GetNearbyTag()
1       0.006560    0.001769  98()
5                   0.001637  neobundle#config#get_autoload_bundles()
2       0.002769    0.001474  xolox#misc#os#can_use_dll()
3                   0.001389  <SNR>99_python_available()
1       0.041292    0.001320  xolox#easytags#update()
1       0.002832    0.001258  <SNR>99_check_cfile()
10      0.002840    0.001253  xolox#misc#path#absolute()

The highlight function

FUNCTION  <SNR>99_highlight_with_python()
Called 3 times
Total time:  36.393659
Self time:  36.391486

count  total (s)   self (s)
    3   0.001514   0.000046   if xolox#misc#option#get('easytags_python_enabled', 1) && s:python_available()
                                " Gather arguments for Python function.
    3              0.000010     let context = {}
    3              0.000359     let context['tagsfiles'] = tagfiles()
    3              0.000016     let context['syntaxgroup'] = a:syntax_group
                                " TODO This doesn't support file type groups!
    3   0.000378   0.000049     let context['filetype'] = xolox#easytags#filetypes#to_ctags(xolox#easytags#filetypes#canonicalize(&filetype))
    3              0.000016     let context['tagkinds'] = get(a:tagkind, 'tagkinds', '')
    3              0.000015     let context['prefix'] = get(a:tagkind, 'pattern_prefix', '')
    3              0.000015     let context['suffix'] = get(a:tagkind, 'pattern_suffix', '')
    3              0.000013     let context['filters'] = get(a:tagkind, 'python_filter', {})
    3   0.000413   0.000037     let context['ignoresyntax'] = xolox#easytags#syntax_groups_to_ignore()
                                " Call the Python function and intercept the output.
    3              0.000005     try
    3              0.000012       redir => commands
    3              0.000149       python import vim
    3             36.389045       silent python print easytags_gensyncmd(**vim.eval('context'))
    3              0.000042       redir END
    3              0.001601       execute commands
    3              0.000010       return 1
                                catch
                                redir END
                                " If the Python script raised an error, don't run it again.
                                let g:easytags_python_enabled = 0
                                endtry
                            endif
                            return 0

FinalFortune avatar Dec 11 '14 11:12 FinalFortune

Is this ticket still being worked on? I've been setting the regexpengine to 1 or 2 and can see a small difference (1 still being faster despite recent vim 7.4.2198). The real difference to make vim workable again other than emptying the .vimtags file is to manually switch to keyword matching as per the patch above. Shouldn't this be merged? The mentioned option g:easytags_syntax_keyword does not seem to do it (i.e. it is still slow after setting it to always).

kjyv avatar Sep 02 '16 11:09 kjyv