vim / vim

The official Vim repository
https://www.vim.org
Vim License
36.57k stars 5.46k forks source link

This augroup makes vim startup much slower (5 times) #668

Closed mtglsk closed 8 years ago

mtglsk commented 8 years ago
augroup VimTest
  autocmd!
  autocmd FileType                * setl foldmethod=syntax nofoldenable
  autocmd FileType             ruby setl foldmethod=manual
  autocmd FileType              vim setl foldenable
augroup END

% tail vim.log
723.754  000.007: editing files in windows
4059.553  3336.799: VimEnter autocommands
4059.562  000.009: before starting main loop
4059.943  000.381: first screen update
4059.951  000.008: --- VIM STARTED ---

% tail vim2.log
723.505  000.007: editing files in windows
781.677  058.172: VimEnter autocommands
781.687  000.010: before starting main loop
782.053  000.366: first screen update
782.061  000.008: --- VIM STARTED ---
mattn commented 8 years ago

Could you please show me the benchmark that comment-out the part?

mtglsk commented 8 years ago

Minimal vimrc for testing i used now:

% cat .vimrc
filetype plugin indent on
syntax on
augroup AutoCommands
autocmd!
autocmd FileType                * setl foldmethod=syntax nofoldenable
autocmd FileType             ruby setl foldmethod=manual
autocmd FileType              vim setl foldenable
augroup END

Makes no difference. Below are the test results.

Here is full log with above vimrc and augrup OFF:

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

000.014  000.014: --- VIM STARTING ---
000.210  000.196: Allocated generic buffers
000.283  000.073: locale set
000.315  000.032: GUI prepared
000.325  000.010: clipboard setup
000.335  000.010: window checked
001.229  000.894: inits 1
001.346  000.117: parsing arguments
001.352  000.006: expanding arguments
001.377  000.025: shell init
002.041  000.664: Termcap init
002.148  000.107: inits 2
002.463  000.315: init highlight
003.460  000.707  000.707: sourcing /usr/share/vim/vim74/debian.vim
003.630  001.048  000.341: sourcing $VIM/vimrc
061.350  057.467  057.467: sourcing /usr/share/vim/vim74/filetype.vim
061.776  000.171  000.171: sourcing /usr/share/vim/vim74/ftplugin.vim
062.189  000.156  000.156: sourcing /usr/share/vim/vim74/indent.vim
063.840  000.979  000.979: sourcing /usr/share/vim/vim74/syntax/syncolor.vim
064.264  001.659  000.680: sourcing /usr/share/vim/vim74/syntax/synload.vim
064.423  002.057  000.398: sourcing /usr/share/vim/vim74/syntax/syntax.vim
064.453  060.725  000.874: sourcing $HOME/.vimrc
064.474  000.238: sourcing vimrc file(s)
065.873  000.289  000.289: sourcing /usr/share/vim/vim74/plugin/getscriptPlugin.vim
066.884  000.921  000.921: sourcing /usr/share/vim/vim74/plugin/gzip.vim
068.082  001.094  001.094: sourcing /usr/share/vim/vim74/plugin/logiPat.vim
068.950  000.774  000.774: sourcing /usr/share/vim/vim74/plugin/matchparen.vim
071.188  002.146  002.146: sourcing /usr/share/vim/vim74/plugin/netrwPlugin.vim
071.514  000.177  000.177: sourcing /usr/share/vim/vim74/plugin/rrhelper.vim
071.742  000.121  000.121: sourcing /usr/share/vim/vim74/plugin/spellfile.vim
072.537  000.692  000.692: sourcing /usr/share/vim/vim74/plugin/tarPlugin.vim
073.088  000.426  000.426: sourcing /usr/share/vim/vim74/plugin/tohtml.vim
073.767  000.572  000.572: sourcing /usr/share/vim/vim74/plugin/vimballPlugin.vim
074.772  000.819  000.819: sourcing /usr/share/vim/vim74/plugin/zipPlugin.vim
074.956  002.451: loading plugins
075.002  000.046: inits 3
075.513  000.511: reading viminfo
082.702  007.189: setup clipboard
082.729  000.027: setting raw mode
082.766  000.037: start termcap
082.951  000.185: clearing screen
089.860  000.998  000.998: sourcing /usr/share/vim/vim74/ftplugin/vim.vim
091.531  000.423  000.423: sourcing /usr/share/vim/vim74/indent/vim.vim
120.313  006.911  006.911: sourcing /usr/share/vim/vim74/syntax/lua.vim
123.914  002.467  002.467: sourcing /usr/share/vim/vim74/syntax/pod.vim
138.337  017.310  014.843: sourcing /usr/share/vim/vim74/syntax/perl.vim
150.240  011.216  011.216: sourcing /usr/share/vim/vim74/syntax/ruby.vim
154.864  003.926  003.926: sourcing /usr/share/vim/vim74/syntax/python.vim
160.619  068.445  029.082: sourcing /usr/share/vim/vim74/syntax/vim.vim
161.374  008.557: opening buffers
161.521  000.147: BufEnter autocommands
161.528  000.007: editing files in windows
164.076  001.538  001.538: sourcing /usr/share/vim/vim74/syntax/syncolor.vim
198.346  035.280: VimEnter autocommands
198.356  000.010: before starting main loop
198.690  000.334: first screen update
198.698  000.008: --- VIM STARTED ---

Here is with augroup ON:

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

000.015  000.015: --- VIM STARTING ---
000.199  000.184: Allocated generic buffers
000.271  000.072: locale set
000.297  000.026: GUI prepared
000.308  000.011: clipboard setup
000.317  000.009: window checked
001.196  000.879: inits 1
001.316  000.120: parsing arguments
001.322  000.006: expanding arguments
001.348  000.026: shell init
001.956  000.608: Termcap init
002.059  000.103: inits 2
002.383  000.324: init highlight
003.402  000.731  000.731: sourcing /usr/share/vim/vim74/debian.vim
003.572  001.069  000.338: sourcing $VIM/vimrc
061.764  057.923  057.923: sourcing /usr/share/vim/vim74/filetype.vim
062.191  000.171  000.171: sourcing /usr/share/vim/vim74/ftplugin.vim
062.576  000.154  000.154: sourcing /usr/share/vim/vim74/indent.vim
064.242  000.975  000.975: sourcing /usr/share/vim/vim74/syntax/syncolor.vim
064.667  001.656  000.681: sourcing /usr/share/vim/vim74/syntax/synload.vim
064.826  002.078  000.422: sourcing /usr/share/vim/vim74/syntax/syntax.vim
065.065  061.378  001.052: sourcing $HOME/.vimrc
065.088  000.258: sourcing vimrc file(s)
066.494  000.281  000.281: sourcing /usr/share/vim/vim74/plugin/getscriptPlugin.vim
067.457  000.873  000.873: sourcing /usr/share/vim/vim74/plugin/gzip.vim
068.624  001.065  001.065: sourcing /usr/share/vim/vim74/plugin/logiPat.vim
069.493  000.778  000.778: sourcing /usr/share/vim/vim74/plugin/matchparen.vim
071.755  002.171  002.171: sourcing /usr/share/vim/vim74/plugin/netrwPlugin.vim
072.078  000.176  000.176: sourcing /usr/share/vim/vim74/plugin/rrhelper.vim
072.315  000.121  000.121: sourcing /usr/share/vim/vim74/plugin/spellfile.vim
073.109  000.691  000.691: sourcing /usr/share/vim/vim74/plugin/tarPlugin.vim
073.667  000.428  000.428: sourcing /usr/share/vim/vim74/plugin/tohtml.vim
074.345  000.572  000.572: sourcing /usr/share/vim/vim74/plugin/vimballPlugin.vim
075.334  000.829  000.829: sourcing /usr/share/vim/vim74/plugin/zipPlugin.vim
075.518  002.445: loading plugins
075.567  000.049: inits 3
076.119  000.552: reading viminfo
083.387  007.268: setup clipboard
083.413  000.026: setting raw mode
083.451  000.038: start termcap
083.635  000.184: clearing screen
090.515  000.971  000.971: sourcing /usr/share/vim/vim74/ftplugin/vim.vim
092.190  000.415  000.415: sourcing /usr/share/vim/vim74/indent/vim.vim
120.903  006.917  006.917: sourcing /usr/share/vim/vim74/syntax/lua.vim
124.488  002.449  002.449: sourcing /usr/share/vim/vim74/syntax/pod.vim
138.919  017.302  014.853: sourcing /usr/share/vim/vim74/syntax/perl.vim
150.828  011.219  011.219: sourcing /usr/share/vim/vim74/syntax/ruby.vim
155.438  003.915  003.915: sourcing /usr/share/vim/vim74/syntax/python.vim
161.174  068.342  028.989: sourcing /usr/share/vim/vim74/syntax/vim.vim
161.985  008.622: opening buffers
162.128  000.143: BufEnter autocommands
162.135  000.007: editing files in windows
164.684  001.537  001.537: sourcing /usr/share/vim/vim74/syntax/syncolor.vim
3446.990  3283.318: VimEnter autocommands
3446.999  000.009: before starting main loop
3447.351  000.352: first screen update
3447.359  000.008: --- VIM STARTED ---

So we can see the difference is even more dramatic with minimal vimrc.

Just as a note i'm testing with vimscript file, but i've seen similar results with ruby files.

mattn commented 8 years ago

Strange. I don't reproduce. Could you please try it again with --noplugin?

mtglsk commented 8 years ago
% tail vim-noplug.log 
144.680  003.727  003.727: sourcing /usr/share/vim/vim74/syntax/python.vim
150.429  068.836  029.820: sourcing /usr/share/vim/vim74/syntax/vim.vim
151.233  008.415: opening buffers
151.254  000.021: BufEnter autocommands
151.260  000.006: editing files in windows
153.694  001.524  001.524: sourcing /usr/share/vim/vim74/syntax/syncolor.vim
3685.929  3533.145: VimEnter autocommands
3685.938  000.009: before starting main loop
3685.977  000.039: first screen update
3685.984  000.007: --- VIM STARTED ---

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 18 2015 04:44:13)
Included patches: 1-963

I'm going to test later against master and report my findings.

mtglsk commented 8 years ago

Ok, i got to test build 1460 & 1467 with similar results (mind you i am using a desktop here, so it is much more powerful machine than last tests):

    % tail noaugroup.log
    219.018  001.036: BufEnter autocommands
    219.021  000.003: editing files in windows
    230.899  011.878: VimEnter autocommands
    230.904  000.005: before starting main loop
    231.025  000.121: first screen update
    231.026  000.001: --- VIM STARTED ---

    % tail augroup.log
    216.684  000.997: BufEnter autocommands
    216.687  000.003: editing files in windows
    910.801  694.114: VimEnter autocommands
    910.805  000.004: before starting main loop
    910.917  000.112: first screen update
    910.918  000.001: --- VIM STARTED ---

I've run another compilation, this time with this (somewhat minimal) configure flags:

% ./configure --with-features=huge --enable-multibyte --enable-gui=no --prefix=/usr

And it seems that the slowdown no longer persists with this configure!

Then i run another compile, this time with gvim enabled:

% ./configure --with-features=huge --enable-multibyte --prefix=/usr

Still doesn't trigger the slowdown.

And then i decided to compile with ruby support, and the issue came back!

% ./configure --with-features=huge --enable-multibyte --enable-rubyinterp --prefix=/usr

So i narrowed down the slowdown to ruby interpreter in vim.

In fact when i remove syntax and ftplugin files for ruby the issue is not there.

Btw, there is a definitely a regression in syntax/vim.vim, over 50ms slower read than neovim's bundled syntax file (which is much older and dated: "Last Change: Apr 02, 2015").

dpelle commented 8 years ago

I see above that you used: configure --prefix=/usr

This is bad. Never install anything in /usr/... without using the package management (apt-get or whatever your system uses). By using --prefix=/usr you're going mess up packages on your Linux distribution.

You should instead use something like this: configure --prefix=/usr/local (which happens to be the default location).

mtglsk commented 8 years ago

I've used checkinstall which allows to easily remove later. But this is a good catch, thanks.

chrisbra commented 8 years ago

can you please show :version output?

mtglsk commented 8 years ago

The last one I compiled (ie +ruby):

    :version
    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar  1 2016 19:00:32)
    Included patches: 1-1467
    Compiled by root@pc
    Huge version with GTK2 GUI.  Features included (+) or not (-):
    +acl             +cmdline_info    +eval            +insert_expand   +modify_fname    -mzscheme        +rightleft       +terminfo        +wildmenu
    +arabic          +comments        +ex_extra        +job             +mouse           +netbeans_intg   +ruby            +termresponse    +windows
    +autocmd         +conceal         +extra_search    +jumplist        +mouseshape      +packages        +scrollbind      +textobjects     +writebackup
    +balloon_eval    +cryptv          +farsi           +keymap          +mouse_dec       +path_extra      +signs           +title           +X11
    +browse          +cscope          +file_in_path    +langmap         -mouse_gpm       -perl            +smartindent     +toolbar         -xfontset
    ++builtin_terms  +cursorbind      +find_in_path    +libcall         -mouse_jsbterm   +persistent_undo +startuptime     +user_commands   +xim
    +byte_offset     +cursorshape     +float           +linebreak       +mouse_netterm   +postscript      +statusline      +vertsplit       +xsmp_interact
    +channel         +dialog_con_gui  +folding         +lispindent      +mouse_sgr       +printer         -sun_workshop    +virtualedit     +xterm_clipboard
    +cindent         +diff            -footer          +listcmds        -mouse_sysmouse  +profile         +syntax          +visual          -xterm_save
    +clientserver    +digraphs        +fork()          +localmap        +mouse_urxvt     -python          +tag_binary      +visualextra     +xpm
    +clipboard       +dnd             +gettext         -lua             +mouse_xterm     -python3         +tag_old_static  +viminfo
    +cmdline_compl   -ebcdic          -hangul_input    +menu            +multi_byte      +quickfix        -tag_any_white   +vreplace
    +cmdline_hist    +emacs_tags      +iconv           +mksession       +multi_lang      +reltime         -tcl             +wildignore
       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"
        system menu file: "$VIMRUNTIME/menu.vim"
      fall-back for $VIM: "/usr/share/vim"
    Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/inclu
    de/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng
    12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2
    .0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
    Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.2-Ijw7O4/ruby2.2-2.2.4/debian/lib -fstack-protector -rdynamic -Wl,-export-dynami
    c  -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -l
    pango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux -ldl       -lrub
    y-2.2 -lpthread -lgmp -ldl -lcrypt -lm
chrisbra commented 8 years ago

Can you also show the other version please? I'd like to see, if there are other features enabled.

mtglsk commented 8 years ago

This is the one without gui and ruby:

    :version
    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar  1 2016 18:53:43)
    Included patches: 1-1467
    Compiled by root@pc
    Huge version with GTK2 GUI.  Features included (+) or not (-):
    +acl             +cmdline_info    +eval            +insert_expand   +modify_fname    -mzscheme        +rightleft       +terminfo        +wildmenu
    +arabic          +comments        +ex_extra        +job             +mouse           +netbeans_intg   -ruby            +termresponse    +windows
    +autocmd         +conceal         +extra_search    +jumplist        +mouseshape      +packages        +scrollbind      +textobjects     +writebackup
    +balloon_eval    +cryptv          +farsi           +keymap          +mouse_dec       +path_extra      +signs           +title           +X11
    +browse          +cscope          +file_in_path    +langmap         -mouse_gpm       -perl            +smartindent     +toolbar         -xfontset
    ++builtin_terms  +cursorbind      +find_in_path    +libcall         -mouse_jsbterm   +persistent_undo +startuptime     +user_commands   +xim
    +byte_offset     +cursorshape     +float           +linebreak       +mouse_netterm   +postscript      +statusline      +vertsplit       +xsmp_interact
    +channel         +dialog_con_gui  +folding         +lispindent      +mouse_sgr       +printer         -sun_workshop    +virtualedit     +xterm_clipboard
    +cindent         +diff            -footer          +listcmds        -mouse_sysmouse  +profile         +syntax          +visual          -xterm_save
    +clientserver    +digraphs        +fork()          +localmap        +mouse_urxvt     -python          +tag_binary      +visualextra     +xpm
    +clipboard       +dnd             +gettext         -lua             +mouse_xterm     -python3         +tag_old_static  +viminfo
    +cmdline_compl   -ebcdic          -hangul_input    +menu            +multi_byte      +quickfix        -tag_any_white   +vreplace
    +cmdline_hist    +emacs_tags      +iconv           +mksession       +multi_lang      +reltime         -tcl             +wildignore
       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"
        system menu file: "$VIMRUNTIME/menu.vim"
      fall-back for $VIM: "/usr/share/vim"
    Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/inclu
    de/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng
    12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2
    .0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
    Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpan
    goft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux -ldl

I think i removed the no cscope package. i have build, not sure.

Here is one from my distro (Ubuntu 16.04, i have this build on my laptop, which original report came from):

    :version
    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 18 2016 11:54:10)
    Included patches: 1-963
    Modified by pkg-vim-maintainers@lists.alioth.debian.org
    Compiled by pkg-vim-maintainers@lists.alioth.debian.org
    Huge version with GTK2 GUI.  Features included (+) or not (-):
    +acl             +comments        +ex_extra        +jumplist        +mouseshape      +path_extra      +signs           +textobjects     +writebackup
    +arabic          +conceal         +extra_search    +keymap          +mouse_dec       +perl            +smartindent     +title           +X11
    +autocmd         +cryptv          +farsi           +langmap         +mouse_gpm       +persistent_undo -sniff           +toolbar         -xfontset
    +balloon_eval    +cscope          +file_in_path    +libcall         -mouse_jsbterm   +postscript      +startuptime     +user_commands   +xim
    +browse          +cursorbind      +find_in_path    +linebreak       +mouse_netterm   +printer         +statusline      +vertsplit       +xsmp_interact
    ++builtin_terms  +cursorshape     +float           +lispindent      +mouse_sgr       +profile         -sun_workshop    +virtualedit     +xterm_clipboard
    +byte_offset     +dialog_con_gui  +folding         +listcmds        -mouse_sysmouse  -python          +syntax          +visual          -xterm_save
    +cindent         +diff            -footer          +localmap        +mouse_urxvt     +python3         +tag_binary      +visualextra     +xpm
    +clientserver    +digraphs        +fork()          +lua             +mouse_xterm     +quickfix        +tag_old_static  +viminfo
    +clipboard       +dnd             +gettext         +menu            +multi_byte      +reltime         -tag_any_white   +vreplace
    +cmdline_compl   -ebcdic          -hangul_input    +mksession       +multi_lang      +rightleft       +tcl             +wildignore
    +cmdline_hist    +emacs_tags      +iconv           +modify_fname    -mzscheme        +ruby            +terminfo        +wildmenu
    +cmdline_info    +eval            +insert_expand   +mouse           +netbeans_intg   +scrollbind      +termresponse    +windows
       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"
        system menu file: "$VIMRUNTIME/menu.vim"
      fall-back for $VIM: "/usr/share/vim"
    Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/inclu
    de/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng
    12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2
    .0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -Wdate-time  -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-secu
    rity -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      -I/usr/include/tcl8.6  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1
    Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.2-Ijw7O4/ruby2.2-2.2.4/debian/lib -fstack-protector -rdynamic -Wl,-export-dynami
    c -Wl,-E  -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -l
    cairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -l
    ICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-lin
    ux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m -lpthread -ldl -lutil -lm -L/usr
    /lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.2 -lpthread -lgmp -ldl -lcrypt -lm

I'm pretty sure the the ruby interpreter somehow is the cause. I have no idea why removing ruby ftplugin and syntax remedies the slowdown, because it shouldnt be sourced for non ruby files.

chrisbra commented 8 years ago

Okay you are right. it only seems to differ by +ruby. However, can you check the output of :scriptnames in both versions? Perhaps it has sourced more runtime files?

mtglsk commented 8 years ago

With above minimal vimrc and opening vimscript file (.vimrc):

No ruby:

  1: ~/.vimrc
  2: /usr/share/vim/vim74/filetype.vim
  3: /usr/share/vim/vim74/ftplugin.vim
  4: /usr/share/vim/vim74/indent.vim
  5: /usr/share/vim/vim74/syntax/syntax.vim
  6: /usr/share/vim/vim74/syntax/synload.vim
  7: /usr/share/vim/vim74/syntax/syncolor.vim
  8: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
  9: /usr/share/vim/vim74/plugin/gzip.vim
 10: /usr/share/vim/vim74/plugin/logiPat.vim
 11: /usr/share/vim/vim74/plugin/matchparen.vim
 12: /usr/share/vim/vim74/plugin/netrwPlugin.vim
 13: /usr/share/vim/vim74/plugin/rrhelper.vim
 14: /usr/share/vim/vim74/plugin/spellfile.vim
 15: /usr/share/vim/vim74/plugin/tarPlugin.vim
 16: /usr/share/vim/vim74/plugin/tohtml.vim
 17: /usr/share/vim/vim74/plugin/vimballPlugin.vim
 18: /usr/share/vim/vim74/plugin/zipPlugin.vim
 19: /usr/share/vim/vim74/scripts.vim
 20: /usr/share/vim/vim74/ftplugin/vim.vim
 21: /usr/share/vim/vim74/indent/vim.vim
 22: /usr/share/vim/vim74/syntax/vim.vim

This is +ruby:

  1: ~/.vimrc
  2: /usr/share/vim/vim74/filetype.vim
  3: /usr/share/vim/vim74/ftplugin.vim
  4: /usr/share/vim/vim74/indent.vim
  5: /usr/share/vim/vim74/syntax/syntax.vim
  6: /usr/share/vim/vim74/syntax/synload.vim
  7: /usr/share/vim/vim74/syntax/syncolor.vim
  8: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
  9: /usr/share/vim/vim74/plugin/gzip.vim
 10: /usr/share/vim/vim74/plugin/logiPat.vim
 11: /usr/share/vim/vim74/plugin/matchparen.vim
 12: /usr/share/vim/vim74/plugin/netrwPlugin.vim
 13: /usr/share/vim/vim74/plugin/rrhelper.vim
 14: /usr/share/vim/vim74/plugin/spellfile.vim
 15: /usr/share/vim/vim74/plugin/tarPlugin.vim
 16: /usr/share/vim/vim74/plugin/tohtml.vim
 17: /usr/share/vim/vim74/plugin/vimballPlugin.vim
 18: /usr/share/vim/vim74/plugin/zipPlugin.vim
 19: /usr/share/vim/vim74/scripts.vim
 20: /usr/share/vim/vim74/ftplugin/vim.vim
 21: /usr/share/vim/vim74/indent/vim.vim
 22: /usr/share/vim/vim74/syntax/vim.vim
 23: /usr/share/vim/vim74/syntax/ruby.vim

We can see that it ruby syntax file gets sourced?

chrisbra commented 8 years ago

Yes, this is sourced by the vim.vim syntax script.If you add :let g:vimsyn_embed='0' Does it still take that long? (That should prevent including other syntax scripts by the vim.vim script)

mtglsk commented 8 years ago

Indeed let g:vimsyn_embed='0' makes the problem go away.

chrisbra commented 8 years ago

I have no clue however, why it would take 3.5 seconds to source the ruby syntax files. (They are known to be slow because of expansive regular expressions, so perhaps parsing and setting up the syntax rules explains that). I think this can be closed now.