Skip to content
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

Slow startuptime of Ruby files #624

Closed
3 of 11 tasks
jsborjesson opened this issue Apr 24, 2017 · 5 comments
Closed
3 of 11 tasks

Slow startuptime of Ruby files #624

jsborjesson opened this issue Apr 24, 2017 · 5 comments

Comments

@jsborjesson
Copy link

I experience very slow start times of Vim with files where the filetype is ruby.

Ruby files take over 4 seconds to load, and every other filetype I've tried has been quick. The 4s load time happens the first time a Ruby file is loaded, whether Vim is started with a Ruby file, or at the time you switch to one. If you open a second Ruby file, it is also quick.

Example:

  • $ vim .vimrc
  • :e Rakefile (this takes >4s)
  • :e something.rb (this doesn't)

I was able to reproduce it with only this in my vimrc and all of the plugin folders removed with :PlugClean (AFAIK, this should mean that no plugins are loaded, only vim-plug code):

call plug#begin('~/.vim/plugged')
call plug#end()

I haven't been able to dig deeper than this so I apologise if this is not a problem caused by vim-plug. If anyone does have an idea of what could cause this that would be greatly appreciated.

Cheers!


VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 19 2017 09:57:52)
MacOS X (unix) version
Included patches: 1-567
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +comments        +extra_search    +keymap          +mouse_dec       +path_extra      +smartindent     +title           -xfontset
+arabic          +conceal         +farsi           +lambda          -mouse_gpm       +perl            +startuptime     -toolbar         -xim
+autocmd         +cryptv          +file_in_path    +langmap         -mouse_jsbterm   +persistent_undo +statusline      +user_commands   -xpm
-balloon_eval    +cscope          +find_in_path    +libcall         +mouse_netterm   +postscript      -sun_workshop    +vertsplit       -xsmp
-browse          +cursorbind      +float           +linebreak       +mouse_sgr       +printer         +syntax          +virtualedit     -xterm_clipboard
++builtin_terms  +cursorshape     +folding         +lispindent      -mouse_sysmouse  +profile         +tag_binary      +visual          -xterm_save
+byte_offset     +dialog_con      -footer          +listcmds        +mouse_urxvt     +python          +tag_old_static  +visualextra
+channel         +diff            +fork()          +localmap        +mouse_xterm     -python3         -tag_any_white   +viminfo
+cindent         +digraphs        -gettext         -lua             +multi_byte      +quickfix        -tcl             +vreplace
-clientserver    -dnd             -hangul_input    +menu            +multi_lang      +reltime         +termguicolors   +wildignore
+clipboard       -ebcdic          +iconv           +mksession       -mzscheme        +rightleft       +terminfo        +wildmenu
+cmdline_compl   +emacs_tags      +insert_expand   +modify_fname    +netbeans_intg   +ruby            +termresponse    +windows
+cmdline_hist    +eval            +job             +mouse           +num64           +scrollbind      +textobjects     +writebackup
+cmdline_info    +ex_extra        +jumplist        -mouseshape      +packages        +signs           +timers          -X11
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/
lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.11 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.1/l
ib/perl5/5.24.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.1 -lobjc
  • Type:
    • Bug
    • Enhancement
    • Feature Request
    • Question
  • OS:
    • All/Other
    • Linux
    • OS X
    • Windows
  • Vim:
    • Terminal Vim
    • GVim
    • Neovim
@vheon
Copy link
Contributor

vheon commented Apr 24, 2017

were you able to profile it? :h startuptime

@junegunn
Copy link
Owner

I'm pretty sure that you'll have the same issue without vim-plug but with a minimal vimrc like so:

filetype plugin indent on
syntax enable

You might want to look into --startuptime log like @vheon suggested. Not sure if it's related but I once had an issue with Vim startup time when I was using JRuby.

@jsborjesson
Copy link
Author

@junegunn you are right, that also reproduces it, sorry about that!

@vheon I have used --startuptime yes, this is probably the wrong place for this now, but if you can make more sense out of this than I can I would still appreciate it a lot!

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

000.004  000.004: --- VIM STARTING ---
000.077  000.073: Allocated generic buffers
000.340  000.263: locale set
000.345  000.005: clipboard setup
000.353  000.008: window checked
000.771  000.418: inits 1
000.862  000.091: parsing arguments
000.866  000.004: expanding arguments
003.673  002.807: shell init
003.893  000.220: Termcap init
003.907  000.014: inits 2
004.021  000.114: init highlight
005.867  001.614  001.614: sourcing /Users/alcesleo/.vim/autoload/plug.vim
011.743  000.011  000.011: sourcing /Users/alcesleo/.vim/plugged/vim-slim/ftdetect/slim.vim
012.804  000.107  000.107: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/ftdetect/ruby.vim
012.985  000.136  000.136: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/ftdetect/ruby_extra.vim
013.938  000.044  000.044: sourcing /Users/alcesleo/.vim/plugged/vim-elixir/ftdetect/elixir.vim
014.248  000.049  000.049: sourcing /Users/alcesleo/.vim/plugged/vim-go/ftdetect/gofiletype.vim
036.942  000.132  000.132: sourcing /Users/alcesleo/.vim/plugged/ultisnips/ftdetect/snippets.vim
037.268  000.150  000.150: sourcing /Users/alcesleo/.vim/plugged/vim-toml/ftdetect/toml.vim
037.384  000.051  000.051: sourcing /Users/alcesleo/.vim/plugged/rust.vim/ftdetect/rust.vim
037.958  000.512  000.512: sourcing /Users/alcesleo/.vim/plugged/vim-liquid/ftdetect/liquid.vim
038.126  000.077  000.077: sourcing /Users/alcesleo/.vim/plugged/llvmir-vim/ftdetect/llvm-ir.vim
038.423  000.228  000.228: sourcing /Users/alcesleo/.vim/plugged/vim-coffee-script/ftdetect/coffee.vim
038.527  000.082  000.082: sourcing /Users/alcesleo/.vim/plugged/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim
038.701  022.774  021.542: sourcing /usr/local/share/vim/vim80/filetype.vim
039.036  000.041  000.041: sourcing /usr/local/share/vim/vim80/ftplugin.vim
039.326  000.032  000.032: sourcing /usr/local/share/vim/vim80/indent.vim
043.038  003.094  003.094: sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
043.207  003.529  000.435: sourcing /usr/local/share/vim/vim80/syntax/synload.vim
043.239  003.831  000.302: sourcing /usr/local/share/vim/vim80/syntax/syntax.vim
045.397  000.774  000.774: sourcing /usr/local/Cellar/vim/8.0.0567/share/vim/vim80/pack/dist/opt/matchit/plugin/matchit.vim
045.492  001.948  001.174: sourcing /usr/local/share/vim/vim80/macros/matchit.vim
046.449  000.823  000.823: sourcing /usr/local/Cellar/vim/8.0.0567/share/vim/vim80/syntax/nosyntax.vim
047.971  000.319  000.319: sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
048.260  001.173  000.854: sourcing /usr/local/share/vim/vim80/syntax/synload.vim
048.321  002.763  000.767: sourcing /usr/local/share/vim/vim80/syntax/syntax.vim
049.679  000.278  000.278: sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
050.831  000.402  000.402: sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
051.760  000.172  000.172: sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
052.289  000.159  000.159: sourcing /usr/local/share/vim/vim80/syntax/syncolor.vim
052.515  003.806  002.795: sourcing /Users/alcesleo/.vim/plugged/vim-colorschemes/colors/blackboard.vim
054.487  050.298  013.142: sourcing $HOME/.vimrc
054.559  000.240: sourcing vimrc file(s)
055.500  000.800  000.800: sourcing /Users/alcesleo/.vim/plugged/vim-abolish/plugin/abolish.vim
055.806  000.203  000.203: sourcing /Users/alcesleo/.vim/plugged/vim-commentary/plugin/commentary.vim
056.358  000.453  000.453: sourcing /Users/alcesleo/.vim/plugged/vim-endwise/plugin/endwise.vim
056.975  000.503  000.503: sourcing /Users/alcesleo/.vim/plugged/vim-eunuch/plugin/eunuch.vim
060.812  003.739  003.739: sourcing /Users/alcesleo/.vim/plugged/vim-fugitive/plugin/fugitive.vim
061.119  000.199  000.199: sourcing /Users/alcesleo/.vim/plugged/vim-projectionist/plugin/projectionist.vim
061.508  000.288  000.288: sourcing /Users/alcesleo/.vim/plugged/vim-rsi/plugin/rsi.vim
062.122  000.093  000.093: sourcing /usr/local/share/vim/vim80/indoff.vim
062.420  000.013  000.013: sourcing /usr/local/share/vim/vim80/filetype.vim
062.745  000.037  000.037: sourcing /usr/local/share/vim/vim80/indent.vim
062.787  001.185  001.042: sourcing /Users/alcesleo/.vim/plugged/vim-sleuth/plugin/sleuth.vim
063.468  000.591  000.591: sourcing /Users/alcesleo/.vim/plugged/vim-speeddating/plugin/speeddating.vim
064.113  000.548  000.548: sourcing /Users/alcesleo/.vim/plugged/vim-surround/plugin/surround.vim
066.743  002.532  002.532: sourcing /Users/alcesleo/.vim/plugged/vim-unimpaired/plugin/unimpaired.vim
067.069  000.229  000.229: sourcing /Users/alcesleo/.vim/plugged/vim-vinegar/plugin/vinegar.vim
067.295  000.133  000.133: sourcing /Users/alcesleo/.vim/plugged/vim-sort-motion/plugin/sort_motion.vim
067.600  000.217  000.217: sourcing /Users/alcesleo/.vim/plugged/vim-easy-align/plugin/easy_align.vim
068.437  000.542  000.542: sourcing /Users/alcesleo/.vim/plugged/vim-textobj-user/autoload/textobj/user.vim
073.445  005.724  005.182: sourcing /Users/alcesleo/.vim/plugged/vim-textobj-entire/plugin/textobj/entire.vim
076.156  002.576  002.576: sourcing /Users/alcesleo/.vim/plugged/vim-textobj-indent/plugin/textobj/indent.vim
077.710  001.426  001.426: sourcing /Users/alcesleo/.vim/plugged/vim-textobj-line/plugin/textobj/line.vim
078.315  000.493  000.493: sourcing /Users/alcesleo/.vim/plugged/vim-exchange/plugin/exchange.vim
088.604  010.187  010.187: sourcing /Users/alcesleo/.vim/plugged/targets.vim/plugin/targets.vim
089.829  001.078  001.078: sourcing /usr/local/opt/fzf/plugin/fzf.vim
090.943  000.992  000.992: sourcing /Users/alcesleo/.vim/plugged/fzf.vim/plugin/fzf.vim
091.406  000.352  000.352: sourcing /Users/alcesleo/.vim/plugged/sideways.vim/plugin/sideways.vim
091.909  000.059  000.059: sourcing /Users/alcesleo/.vim/plugged/splitjoin.vim/autoload/sj/settings.vim
092.181  000.626  000.567: sourcing /Users/alcesleo/.vim/plugged/splitjoin.vim/plugin/splitjoin.vim
092.593  000.302  000.302: sourcing /Users/alcesleo/.vim/plugged/switch.vim/plugin/switch.vim
093.223  000.092  000.092: sourcing /Users/alcesleo/.vim/plugged/ultisnips/autoload/UltiSnips/map_keys.vim
093.358  000.667  000.575: sourcing /Users/alcesleo/.vim/plugged/ultisnips/plugin/UltiSnips.vim
094.329  000.142  000.142: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter/highlight.vim
095.159  001.704  001.562: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/plugin/gitgutter.vim
095.724  000.424  000.424: sourcing /Users/alcesleo/.vim/plugged/auto-pairs/plugin/auto-pairs.vim
096.514  000.697  000.697: sourcing /Users/alcesleo/.vim/plugged/gv.vim/plugin/gv.vim
097.401  000.741  000.741: sourcing /Users/alcesleo/.vim/plugged/vim-fetch/plugin/fetch.vim
097.658  000.111  000.111: sourcing /Users/alcesleo/.vim/plugged/ag.vim/plugin/ag.vim
098.315  000.549  000.549: sourcing /Users/alcesleo/.vim/plugged/ReplaceWithRegister/plugin/ReplaceWithRegister.vim
098.725  000.302  000.302: sourcing /Users/alcesleo/.vim/plugged/vim-tmux-navigator/plugin/tmux_navigator.vim
099.536  000.709  000.709: sourcing /Users/alcesleo/.vim/plugged/vim-tmux-runner/plugin/vim-tmux-runner.vim
099.702  000.056  000.056: sourcing /Users/alcesleo/.vim/plugged/rust.vim/plugin/rust.vim
100.788  000.963  000.963: sourcing /Users/alcesleo/.vim/plugged/tagbar/plugin/tagbar.vim
101.229  000.079  000.079: sourcing /usr/local/share/vim/vim80/plugin/getscriptPlugin.vim
101.719  000.465  000.465: sourcing /usr/local/share/vim/vim80/plugin/gzip.vim
102.142  000.398  000.398: sourcing /usr/local/share/vim/vim80/plugin/logiPat.vim
102.186  000.018  000.018: sourcing /usr/local/share/vim/vim80/plugin/manpager.vim
102.409  000.201  000.201: sourcing /usr/local/share/vim/vim80/plugin/matchparen.vim
103.191  000.757  000.757: sourcing /usr/local/share/vim/vim80/plugin/netrwPlugin.vim
103.247  000.020  000.020: sourcing /usr/local/share/vim/vim80/plugin/rrhelper.vim
103.314  000.036  000.036: sourcing /usr/local/share/vim/vim80/plugin/spellfile.vim
103.522  000.179  000.179: sourcing /usr/local/share/vim/vim80/plugin/tarPlugin.vim
103.659  000.105  000.105: sourcing /usr/local/share/vim/vim80/plugin/tohtml.vim
103.904  000.195  000.195: sourcing /usr/local/share/vim/vim80/plugin/vimballPlugin.vim
104.149  000.208  000.208: sourcing /usr/local/share/vim/vim80/plugin/zipPlugin.vim
104.291  000.029  000.029: sourcing /usr/local/Cellar/vim/8.0.0567/share/vim/vim80/pack/dist/opt/matchit/plugin/matchit.vim
104.298  004.750: loading plugins
104.408  000.110: loading packages
104.701  000.173  000.173: sourcing /Users/alcesleo/.vim/plugged/ultisnips/after/plugin/UltiSnips_after.vim
104.762  000.181: loading after plugins
104.768  000.006: inits 3
105.132  000.364: reading viminfo
105.166  000.034: setting raw mode
105.172  000.006: start termcap
105.186  000.014: clearing screen
115.761  001.751  001.751: sourcing /Users/alcesleo/.vim/plugged/vim-textobj-ruby/plugin/textobj/ruby.vim
117.987  001.105  001.105: sourcing /Users/alcesleo/.vim/plugged/vim-rspec/plugin/rspec.vim
121.494  002.870  002.870: sourcing /Users/alcesleo/.vim/plugged/vim-bundler/plugin/bundler.vim
124.085  001.739  001.739: sourcing /Users/alcesleo/.vim/plugged/vim-rake/plugin/rake.vim
126.729  001.660  001.660: sourcing /Users/alcesleo/.vim/plugged/vim-rbenv/plugin/rbenv.vim
131.407  003.713  003.713: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/syntax/ruby.vim
132.773  000.089  000.089: sourcing /Users/alcesleo/.vim/plugged/splitjoin.vim/ftplugin/ruby/splitjoin.vim
136.131  002.617  002.617: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/ftplugin/ruby.vim
136.595  000.048  000.048: sourcing /usr/local/share/vim/vim80/ftplugin/ruby.vim
136.995  000.049  000.049: sourcing /Users/alcesleo/.vim/after/ftplugin/ruby.vim
141.363  003.711  003.711: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/indent/ruby.vim
141.548  000.041  000.041: sourcing /usr/local/share/vim/vim80/indent/ruby.vim
142.591  000.031  000.031: sourcing /Users/alcesleo/.vim/plugged/splitjoin.vim/ftplugin/ruby/splitjoin.vim
146.564  003.478  003.478: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/ftplugin/ruby.vim
147.336  000.082  000.082: sourcing /usr/local/share/vim/vim80/ftplugin/ruby.vim
148.048  000.062  000.062: sourcing /Users/alcesleo/.vim/after/ftplugin/ruby.vim
153.284  003.667  003.667: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/syntax/ruby.vim
153.575  000.059  000.059: sourcing /usr/local/share/vim/vim80/syntax/ruby.vim
156.048  001.099  001.099: sourcing /Users/alcesleo/.vim/plugged/vim-projectionist/autoload/projectionist.vim
2368.134  000.068  000.068: sourcing /Users/alcesleo/.vim/plugged/vim-ruby/indent/ruby.vim
2368.258  000.013  000.013: sourcing /usr/local/share/vim/vim80/indent/ruby.vim
2375.640  000.285  000.285: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter.vim
2376.161  000.269  000.269: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter/utility.vim
2376.666  000.184  000.184: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter/sign.vim
2385.534  008.581  008.581: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter/diff.vim
2386.387  000.293  000.293: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter/async.vim
2388.104  000.422  000.422: sourcing /Users/alcesleo/.vim/plugged/vim-gitgutter/autoload/gitgutter/debug.vim
2388.813  2245.641: opening buffers
2390.050  001.237: BufEnter autocommands
2390.056  000.006: editing files in windows
2390.402  000.346: VimEnter autocommands
2390.408  000.006: before starting main loop
2390.601  000.193: first screen update
2390.603  000.002: --- VIM STARTED ---

@vheon
Copy link
Contributor

vheon commented Apr 25, 2017

@alcesleo looks like projectionist is taking the majority of the time there.

try to launch vim like:

vim --cmd 'profile start profile.log' \
    --cmd 'profile func *' \
    --cmd 'profile file *' \
    -c 'profdel func *' 
    -c 'profdel file *' \
    -c 'qa!'

it will give you a more granular profile.

@jsborjesson
Copy link
Author

jsborjesson commented Apr 25, 2017

Using your command I was able to narrow it down to something called FUNCTION <SNR>80_project_paths(), it actually spends all this time in vim-bundler. There's an open ticket about this: tpope/vim-bundler#38

@vheon Thank you so much for providing tech support on this misplaced ticket! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants