lyuts / vim-rtags

Vim bindings for rtags, llvm/clang based c++ code indexer.
BSD 2-Clause "Simplified" License
282 stars 56 forks source link

vim-rtags plugin is slow at startup #128

Open dpelle opened 3 years ago

dpelle commented 3 years ago

Using vim --startup startup.log, I see that the plugin vim-rtags takes quite some time at startup. I have several plugins installed and vim-rtags is the slowest.

Is there a reason for not moving functions from plugin/rtags.vim into autoload/… in order to speedup startup?

Below is my startup log, showing that vim-rtags takes much more time than other plugins at startup. For example, YouCompleteMe plugin only takes 0.418ms whereas vim-rtags takes 41.541ms (so 100 times slower):

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.003  000.003: --- VIM STARTING ---
000.089  000.086: Allocated generic buffers
000.129  000.040: locale set
000.138  000.009: GUI prepared
000.142  000.004: clipboard setup
000.145  000.003: window checked
000.432  000.287: inits 1
000.447  000.015: parsing arguments
000.448  000.001: expanding arguments
000.470  000.022: shell init
000.917  000.447: xsmp init
001.186  000.269: Termcap init
001.220  000.034: inits 2
001.357  000.137: init highlight
003.097  001.553  001.553: sourcing /home/pel/.vim/autoload/plug.vim
013.238  000.021  000.021: sourcing /home/pel/.vim/plugged/csv.vim/ftdetect/csv.vim
013.444  000.014  000.014: sourcing /home/pel/.vim/plugged/vim-fugitive/ftdetect/fugitive.vim
013.601  006.088  006.053: sourcing /usr/local/share/vim/vim82/filetype.vim
013.810  000.040  000.040: sourcing /usr/local/share/vim/vim82/ftplugin.vim
014.006  000.033  000.033: sourcing /usr/local/share/vim/vim82/indent.vim
015.175  000.749  000.749: sourcing /usr/local/share/vim/vim82/syntax/syncolor.vim
015.297  001.054  000.305: sourcing /usr/local/share/vim/vim82/syntax/synload.vim
015.327  001.266  000.212: sourcing /usr/local/share/vim/vim82/syntax/syntax.vim
015.971  000.383  000.383: sourcing /usr/local/share/vim/vim82/syntax/nosyntax.vim
016.485  000.165  000.165: sourcing /usr/local/share/vim/vim82/syntax/syncolor.vim
016.588  000.445  000.280: sourcing /usr/local/share/vim/vim82/syntax/synload.vim
016.616  001.063  000.235: sourcing /usr/local/share/vim/vim82/syntax/syntax.vim
016.786  000.011  000.011: sourcing /usr/local/share/vim/vim82/filetype.vim
016.955  000.008  000.008: sourcing /usr/local/share/vim/vim82/ftplugin.vim
037.587  000.178  000.178: sourcing /usr/local/share/vim/vim82/syntax/syncolor.vim
038.104  000.159  000.159: sourcing /usr/local/share/vim/vim82/syntax/syncolor.vim
038.804  001.707  001.370: sourcing /home/pel/.vim/plugged/rastafari/colors/rastafari.vim
038.809  037.330  025.561: sourcing $HOME/.vimrc
038.813  000.126: sourcing vimrc file(s)
041.144  002.206  002.206: sourcing /home/pel/.vim/plugged/vim-devicons/plugin/webdevicons.vim
041.427  000.220  000.220: sourcing /home/pel/.vim/plugged/csv.vim/plugin/csv.vim
042.488  001.001  001.001: sourcing /home/pel/.vim/plugged/vim-alternate/plugin/a.vim
042.645  000.078  000.078: sourcing /home/pel/.vim/plugged/vim-Grammalecte/plugin/Grammalecte.vim
042.776  000.067  000.067: sourcing /home/pel/.vim/plugged/vim-LanguageTool/plugin/LanguageTool.vim
043.005  000.165  000.165: sourcing /home/pel/.vim/plugged/vim-asterisk/plugin/asterisk.vim
043.305  000.238  000.238: sourcing /home/pel/.vim/plugged/CommandlineComplete.vim/plugin/commandline_complete.vim
044.145  000.772  000.772: sourcing /home/pel/.vim/plugged/fzf/plugin/fzf.vim
045.181  000.963  000.963: sourcing /home/pel/.vim/plugged/fzf.vim/plugin/fzf.vim
045.510  000.123  000.123: sourcing /home/pel/.vim/plugged/vim-signature/autoload/signature/utils.vim
046.549  001.291  001.168: sourcing /home/pel/.vim/plugged/vim-signature/plugin/signature.vim
046.907  000.287  000.287: sourcing /home/pel/.vim/plugged/vim-interestingwords/plugin/interestingwords.vim
088.581  041.541  041.541: sourcing /home/pel/.vim/plugged/vim-rtags/plugin/rtags.vim  <------------- SLOW!
088.857  000.165  000.165: sourcing /home/pel/.vim/plugged/undotree/plugin/undotree.vim
089.016  000.079  000.079: sourcing /home/pel/.vim/plugged/vim-plugin-AnsiEsc/plugin/AnsiEscPlugin.vim
089.425  000.391  000.391: sourcing /home/pel/.vim/plugged/vim-plugin-AnsiEsc/plugin/cecutil.vim
090.169  000.676  000.676: sourcing /home/pel/.vim/plugged/vim-clang-format/plugin/clang_format.vim
090.426  000.194  000.194: sourcing /home/pel/.vim/plugged/vim-illuminate/plugin/illuminate.vim
090.581  000.099  000.099: sourcing /home/pel/.vim/plugged/vim-minimap/plugin/minimap.vim
091.165  000.514  000.514: sourcing /home/pel/.vim/plugged/vim-multiple-cursors/plugin/multiple_cursors.vim
093.054  001.823  001.823: sourcing /home/pel/.vim/plugged/vim-fugitive/plugin/fugitive.vim
093.723  000.575  000.575: sourcing /home/pel/.vim/plugged/vim-surround/plugin/surround.vim
094.775  000.979  000.979: sourcing /home/pel/.vim/plugged/quick-scope/plugin/quick_scope.vim
095.430  000.585  000.585: sourcing /home/pel/.vim/plugged/taglist.vim/plugin/taglist.vim
098.287  002.531  002.531: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcscommand.vim
098.339  002.768  000.237: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcsbzr.vim
098.458  000.100  000.100: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcscommand.vim
098.554  000.080  000.080: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcscvs.vim
098.794  000.224  000.224: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcsgit.vim
098.888  000.072  000.072: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcshg.vim
098.971  000.067  000.067: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcssvk.vim
099.055  000.066  000.066: sourcing /home/pel/.vim/plugged/vcscommand.vim/plugin/vcssvn.vim
099.278  000.053  000.053: sourcing /home/pel/.vim/plugged/killersheep/plugin/killersheep.vim
099.754  000.418  000.418: sourcing /home/pel/.vim/plugged/YouCompleteMe/plugin/youcompleteme.vim
100.058  000.074  000.074: sourcing /usr/local/share/vim/vim82/plugin/getscriptPlugin.vim
100.298  000.222  000.222: sourcing /usr/local/share/vim/vim82/plugin/gzip.vim
100.557  000.241  000.241: sourcing /usr/local/share/vim/vim82/plugin/logiPat.vim
100.608  000.030  000.030: sourcing /usr/local/share/vim/vim82/plugin/manpager.vim
100.861  000.236  000.236: sourcing /usr/local/share/vim/vim82/plugin/matchparen.vim
101.498  000.615  000.615: sourcing /usr/local/share/vim/vim82/plugin/netrwPlugin.vim
101.572  000.039  000.039: sourcing /usr/local/share/vim/vim82/plugin/rrhelper.vim
101.628  000.029  000.029: sourcing /usr/local/share/vim/vim82/plugin/spellfile.vim
101.832  000.180  000.180: sourcing /usr/local/share/vim/vim82/plugin/tarPlugin.vim
101.958  000.100  000.100: sourcing /usr/local/share/vim/vim82/plugin/tohtml.vim
102.239  000.260  000.260: sourcing /usr/local/share/vim/vim82/plugin/vimballPlugin.vim
102.492  000.216  000.216: sourcing /usr/local/share/vim/vim82/plugin/zipPlugin.vim
102.497  002.685: loading plugins
102.555  000.058: loading packages
102.694  000.050  000.050: sourcing /home/pel/.vim/plugged/vim-signature/after/plugin/signature.vim
102.709  000.104: loading after plugins
103.282  000.573: inits 3
103.636  000.354: reading viminfo
105.399  001.763: setup clipboard
105.417  000.018: setting raw mode
105.426  000.009: start termcap
105.464  000.038: clearing screen
105.918  000.454: opening buffers
106.287  000.223  000.223: sourcing /home/pel/.vim/plugged/vim-signature/autoload/signature/sign.vim
106.822  000.231  000.231: sourcing /home/pel/.vim/plugged/vim-signature/autoload/signature/mark.vim
112.698  002.411  002.411: sourcing /home/pel/.vim/plugged/taglist.vim/plugin/taglist.vim
112.823  004.040: BufEnter autocommands
112.825  000.002: editing files in windows
114.103  000.872  000.872: sourcing /home/pel/.vim/plugged/YouCompleteMe/autoload/youcompleteme.vim
176.765  063.068: VimEnter autocommands
176.769  000.004: before starting main loop
177.112  000.171  000.171: sourcing /home/pel/.vim/plugged/vim-illuminate/autoload/illuminate.vim
184.955  006.811  006.811: sourcing /home/pel/.vim/plugged/vim-fugitive/autoload/fugitive.vim
186.667  002.916: first screen update
186.669  000.002: --- VIM STARTED ---

I'm using the latest version of the plugin i.e.:

commit 3ef48de532c2e875f0fc3c33b34befed2bf37016 (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: lyuts <lyuts@users.noreply.github.com>
Date:   Sun Jul 22 17:55:50 2018 -0700

    Merge pull request #107 from flackr/show-hierarchy

    Add <Leader>rh command to show class hierarchy

with vim-8.2.2311 (huge) on Linux x86_64:

:version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan  7 2021 22:31:14)
Included patches: 1-2311
Compiled by pel@pel-cirrus7
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +dnd               +listcmds          +postscript        +textobjects
+arabic            -ebcdic            +localmap          +printer           +textprop
+autocmd           +emacs_tags        +lua               +profile           +timers
+autochdir         +eval              +menu              -python            +title
-autoservername    +ex_extra          +mksession         +python3           +toolbar
+balloon_eval      +extra_search      +modify_fname      +quickfix          +user_commands
+balloon_eval_term -farsi             +mouse             +reltime           +vartabs
+browse            +file_in_path      +mouseshape        +rightleft         +vertsplit
++builtin_terms    +find_in_path      +mouse_dec         +ruby              +virtualedit
+byte_offset       +float             +mouse_gpm         +scrollbind        +visual
+channel           +folding           -mouse_jsbterm     +signs             +visualextra
+cindent           -footer            +mouse_netterm     +smartindent       +viminfo
+clientserver      +fork()            +mouse_sgr         +sound             +vreplace
+clipboard         +gettext           -mouse_sysmouse    +spell             +wildignore
+cmdline_compl     -hangul_input      +mouse_urxvt       +startuptime       +wildmenu
+cmdline_hist      +iconv             +mouse_xterm       +statusline        +windows
+cmdline_info      +insert_expand     +multi_byte        -sun_workshop      +writebackup
+comments          +ipv6              +multi_lang        +syntax            +X11
+conceal           +job               -mzscheme          +tag_binary        -xfontset
+cryptv            +jumplist          +netbeans_intg     -tag_old_static    +xim
+cscope            +keymap            +num64             -tag_any_white     +xpm
+cursorbind        +lambda            +packages          +tcl               +xsmp_interact
+cursorshape       +langmap           +path_extra        +termguicolors     +xterm_clipboard
+dialog_con_gui    +libcall           +perl              +terminal          -xterm_save
+diff              +linebreak         +persistent_undo   +terminfo
+digraphs          +lispindent        +popupwin          +termresponse
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/in
clude/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus
-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pan
go-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/u
sr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/inc
lude/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x
86_64-linux-gnu/glib-2.0/include -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-expor
t-dynamic -Wl,-E -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -l
atk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lX
t -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2
-Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl
-lm -lpthread -lcrypt -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lut
il -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcry
pt -lm -L/usr/lib
mckellygit commented 3 years ago

Hi. Just some info I see: If I comment out the: call rtags#InitPython() my startup time goes down to about 40 ms. This line is required, but I was just looking for where some time is spent. And if I comment out the rdm daemon check/start: let g:rtagsAutoLaunchRdm = 0 my startup time goes down to about 1 ms. I've been trying to maintain a version of vim-rtags if its any help.