Coder Social home page Coder Social logo

Comments (14)

andymass avatar andymass commented on May 20, 2024

Thanks for the kind words! 😄

I agree, loading could be improved quite a bit. I am curious, have you noticed an unacceptable load time, or is this a "best practices" concern? I'm planning to re-organizing pretty things soon, I'm just looking to gauge priority.

from vim-matchup.

justinmk avatar justinmk commented on May 20, 2024

It's mostly just best-practice, but the current setup does add 5-10 ms to startup.

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

Measuring vim startup time for my vimrc, the plugin matchup is actually the one which adds the most to the startup (and I have installed 81 plugins (right now with some redundancy ctrlp, fzf, denite)

056.626  036.955  007.767: sourcing ~/.vim/vimrc
111.314  018.392  012.465: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/matchup.vim
045.363  014.004  012.723: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/colors/atom.vim
029.608  007.923  007.853: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
079.746  005.129  005.129: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/fugitive.vim
089.315  004.268  002.320: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/lh-project.vim
129.501  003.715  003.715: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/unimpaired.vim
052.073  002.364  001.623: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/autoload/operator/sandwich.vim
092.845  002.259  001.961: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/magit.vim
097.349  001.877  001.877: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/autoload/matchup/delim.vim
125.738  001.557  001.418: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/UltiSnips.vim
121.714  001.297  001.297: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/tagbar.vim
084.072  001.288  001.288: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/indentwise.vim
133.901  001.250  001.250: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
067.755  001.221  000.753: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/ctrlp.vim
080.888  001.089  001.089: sourcing ~/.cache/vim/dein/.cache/vimrc/.dein/plugin/fzf.vim
...

I think for people like me who use many plugins, it would become a problem if all plugins would add a similar time to startup. Therefore I would argue it is too much.

from vim-matchup.

andymass avatar andymass commented on May 20, 2024

I've made substantial changes to the loading which should have brought the time down. Feel free to report if the startup cost is still excessive.

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

Thanks Andy!

Yes, this is a significant improvement. And I would have never called matchup excessive. Anyhow.

Now it looks like:

188.298  015.584  014.392: sourcing ~/.vim/pack/minpac/start/awesome-vim-colorschemes/colors/gruvbox.vim
082.581  013.452  002.127: sourcing ~/.vim/pack/minpac/start/vim-sensible/plugin/sensible.vim
079.191  009.478  009.434: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
062.824  006.856  005.373: sourcing ~/.vim/pack/minpac/start/vim-matchup/plugin/matchup.vim
054.812  003.970  003.970: sourcing ~/.vim/pack/minpac/start/vim-fugitive/plugin/fugitive.vim
088.381  003.928  003.928: sourcing ~/.vim/pack/minpac/start/vim-unimpaired/plugin/unimpaired.vim
124.376  003.469  003.082: sourcing ~/.vim/pack/minpac/start/awesome-vim-colorschemes/autoload/lightline/colorscheme/gruvbox.vim
094.826  002.339  000.817: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
226.959  002.296  001.520: sourcing ~/.vim/pack/minpac/start/vim-sandwich/autoload/operator/sandwich.vim
043.887  001.989  001.810: sourcing ~/.vim/pack/minpac/start/ultisnips/plugin/UltiSnips.vim

Unfortunately, it still is one that adds more than others but is not ahead as the last time. It had been 13ms difference to the next plugin, now the difference is only 3ms. I would call this acceptable.

I have one more question:

If I would not use certain features of matchup, could I improve the startup time further, e.g. using only text objects and motions but no highlighting?

I have tried

let g:matchup_matchparen_enabled = 0

but this did not change much. Could this be improved?

from vim-matchup.

andymass avatar andymass commented on May 20, 2024

I think that should be fixed now.

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

My first check does not confirm that let g:matchup_matchparen_enabled = 0 will improve startup/load time. However, I will have a look into this a second time with minimal vimrc later this week.

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

I did some additional profiling, using a clean .vim directory, measuring full startup time (last entry in --startuptime log) only one plugin or colorscheme in ~/.vim/pack/myplugins/start at a time:

~/.vim
❯ tree
.
├── pack
│   └── myplugins
│       └── start
└── vimrc

3 directories, 1 file
cat vimrc
set nocompatible
syntax on
" let g:matchup_matchparen_enabled = 0 " if measured
" colorscheme apprentice " if measured
" colorscheme base16-gruvbox-dark-hard " if measured

Measurement (100 runs)

❯ for i in {1..100}; do vim --startuptime vim-startup-$i.log -c ":q"; done
❯ tail -q -n 1 vim-startup-*.log | awk '{ x+= $1; y+= $1^2; n++ } END { if (n > 0) print x / n,
sqrt(y/n-(x/n)^2);}'

I have compared vim-matchup to a few non-trivial plugins, i.e. targets.vim, vim-surround, vim-fugitive and two colorschemes:

Configuration Mean (ms) SD (ms) Relative Increase
vanilla vim 8.0.1633 (mvim -v) 34.61 2.62 reference point
targets.vim 35.76 2.55 +3.3%
vim-surround 36.06 1.55 +4,2%
vim-fugitive 39.84 1.50 +15,1%
vim-matchup without matchparen 43.96 1.66 +27,0%
vim-matchup with matchparen 44.57 1.96 +28,8%
colorscheme apprentice 44.21 1.885 +27,7%
colorscheme base16-gruvbox-dark-hard 55.05 2.24 +59,1%

I would have hoped that vim-matchup with the recent updates would perform even better and is currently the "slowest" plugin I use.
Also disabling let g:matchup_matchparen_enabled = 0 has only a minor impact on the startup of matchup.

The colorscheme adds a bit more than matchup, and fugitive is the second "slowest" plugin I use right now.

Most of my other plugins are in the same region as targets.vim or vim-surround (or even below such as vim-commentary or vim-vinegar). This allows me to use quite a few without a slow vim startup.

Another thing I learned is: colorschemes can be quite slow: I intend now to measure the startup impact as a first step when considering to use a new colorscheme. There are some really slow ones (e.g. https://github.com/rakr/vim-one which increases startup to 122ms without any additional plugin; this has been reported in issue 74; I would call this excessive 😃).

Anyhow, I am no expert in writing vim plugins and can't really make a recommendation how one could minimize startup time further. My expectation was that matchparen functionality would have a larger impact but apparently this is not the case.

from vim-matchup.

andymass avatar andymass commented on May 20, 2024

Thanks so much for the detailed timings! Could you show me an example of a vim-startup-{}.log file? Specifically with and without matchup_matchparen? I also wonder if your installation method has anything to do with it. I've never used or tested pack/myplugins/start.

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

I can certainly show you an example of a vim-startup{}.log file

Default matchup

$ cat vimrc
set nocompatible
syntax on
$ vim --startuptime vim-startup-1.log -c ":q"
$ cat vim-startup-1.log


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

000.009  000.009: --- VIM STARTING ---
000.125  000.116: Allocated generic buffers
000.329  000.204: locale set
000.352  000.023: GUI prepared
000.356  000.004: clipboard setup
000.366  000.010: window checked
010.776  010.410: inits 1
010.793  000.017: parsing arguments
011.538  000.745: expanding arguments
015.040  003.502: shell init
015.464  000.424: Termcap init
015.511  000.047: inits 2
017.674  002.163: init highlight
018.116  000.332  000.332: sourcing $VIM/vimrc
019.029  000.355  000.355: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/syncolor.vim
019.195  000.640  000.285: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/synload.vim
027.373  008.085  008.085: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
027.432  009.005  000.280: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
027.446  009.196  000.191: sourcing ~/.vim/vimrc
027.452  000.250: sourcing vimrc file(s)
028.628  000.104  000.104: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/getscriptPlugin.vim
028.960  000.283  000.283: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/gzip.vim
029.365  000.348  000.348: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/logiPat.vim
029.501  000.083  000.083: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/manpager.vim
029.824  000.265  000.265: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
030.610  000.736  000.736: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
030.755  000.066  000.066: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/rrhelper.vim
030.864  000.048  000.048: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/spellfile.vim
031.127  000.209  000.209: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/tarPlugin.vim
031.317  000.134  000.134: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/tohtml.vim
031.590  000.219  000.219: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
031.911  000.245  000.245: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/zipPlugin.vim
031.922  001.730: loading plugins
032.461  000.027  000.027: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
033.065  000.285  000.285: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup.vim
033.342  000.171  000.171: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/perf.vim
034.311  000.478  000.478: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/loader.vim
034.962  000.366  000.366: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/matchparen.vim
037.577  005.324  003.997: sourcing /Users/kiryph/.vim-configs/minimal/pack/myplugins/start/vim-matchup/plugin/matchup.vim
037.725  000.479: loading packages
037.971  000.013  000.013: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/after/plugin/matchit.vim
037.978  000.240: loading after plugins
037.990  000.012: inits 3
039.952  001.962: reading viminfo
039.996  000.044: setting raw mode
040.003  000.007: start termcap
040.041  000.038: clearing screen
040.459  000.049  000.049: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/re.vim
041.225  000.177  000.177: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/util.vim
044.109  003.842: opening buffers
044.136  000.027: BufEnter autocommands
044.143  000.007: editing files in windows

Matchup without matchparen

$ cat vimrc
set nocompatible
syntax on
let g:matchup_matchparen_enabled = 0
$ vim --startuptime vim-startup-1.log -c ":q"
$ cat vim-startup-1.log


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

000.009  000.009: --- VIM STARTING ---
000.129  000.120: Allocated generic buffers
000.324  000.195: locale set
000.347  000.023: GUI prepared
000.351  000.004: clipboard setup
000.361  000.010: window checked
012.141  011.780: inits 1
012.157  000.016: parsing arguments
013.039  000.882: expanding arguments
016.352  003.313: shell init
016.820  000.468: Termcap init
016.872  000.052: inits 2
018.955  002.083: init highlight
019.399  000.336  000.336: sourcing $VIM/vimrc
020.310  000.357  000.357: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/syncolor.vim
020.512  000.677  000.320: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/synload.vim
029.104  008.494  008.494: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/filetype.vim
029.164  009.457  000.286: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/syntax.vim
029.183  009.655  000.198: sourcing ~/.vim/vimrc
029.190  000.244: sourcing vimrc file(s)
030.329  000.103  000.103: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/getscriptPlugin.vim
030.686  000.310  000.310: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/gzip.vim
031.099  000.353  000.353: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/logiPat.vim
031.194  000.046  000.046: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/manpager.vim
031.483  000.246  000.246: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
032.234  000.704  000.704: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/netrwPlugin.vim
032.361  000.060  000.060: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/rrhelper.vim
032.466  000.047  000.047: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/spellfile.vim
032.722  000.204  000.204: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/tarPlugin.vim
032.904  000.128  000.128: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/tohtml.vim
033.173  000.216  000.216: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/vimballPlugin.vim
033.491  000.243  000.243: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/zipPlugin.vim
033.501  001.651: loading plugins
033.975  000.026  000.026: sourcing /Applications/MacVim.app/Contents/Resources/vim/runtime/plugin/matchparen.vim
034.579  000.280  000.280: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup.vim
034.837  000.159  000.159: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/perf.vim
035.799  000.478  000.478: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/loader.vim
038.807  005.019  004.076: sourcing /Users/kiryph/.vim-configs/minimal/pack/myplugins/start/vim-matchup/plugin/matchup.vim
039.017  000.497: loading packages
039.399  000.020  000.020: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/after/plugin/matchit.vim
039.410  000.373: loading after plugins
039.426  000.016: inits 3
042.074  002.648: reading viminfo
042.134  000.060: setting raw mode
042.144  000.010: start termcap
042.168  000.024: clearing screen
042.648  000.089  000.089: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/re.vim
043.719  000.243  000.243: sourcing /Users/kiryph/.vim/pack/myplugins/start/vim-matchup/autoload/matchup/util.vim
047.424  004.924: opening buffers
047.454  000.030: BufEnter autocommands
047.461  000.007: editing files in windows

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

If I got justinmk right, there should be no autoload/matchup/*.vim files in the startup log. If they are needed for startup, they can probably be moved to plugin/matchup/.

As a further step I will try to use the lazy loading functionality of vim-plug or dein. If they are helpful to improve startup time of matchup, one can at least point people to a currently available possibility to improve startup time (IF someone complains).

from vim-matchup.

andymass avatar andymass commented on May 20, 2024

Well, I could (and may) place them in plugin/ instead of autoload/ but this shouldn't have a large effect on load time (perhaps autoloading adds 1ms total). This is because the files loaded right now are actually required for functionality and I don't know yet where exactly the time is being spent. Currently it looks like around 9ms total is being added for you.

The other thing you could try is let g:matchup_delim_start_plaintext = 0. Obviously, this would disable the functionality at startup, but it might help me narrow down where the loading time is going.

from vim-matchup.

kiryph avatar kiryph commented on May 20, 2024

Using let g:matchup_delim_start_plaintext = 0

~/.vim
$ cat vimrc
set nocompatible
syntax on
let g:matchup_matchparen_enabled = 0
let g:matchup_delim_start_plaintext = 0
$ for i in {1..100}; do vim --startuptime vim-startup-$i.log -c ":q"; done
$ tail -q -n 1 vim-startup-*.log | awk '{ x+= $1; y+= $1^2; n++ } END { if (n > 0) print x / n,
sqrt(y/n-(x/n)^2);}'
39.5439 1.55608

Comparing again to

~/.vim
$ cat vimrc
set nocompatible
syntax on
" let g:matchup_matchparen_enabled = 0
" let g:matchup_delim_start_plaintext = 0

~/.vim
$ for i in {1..100}; do vim --startuptime vim-startup-$i.log -c ":q"; done

~/.vim 7s
$ tail -q -n 1 vim-startup-*.log | awk '{ x+= $1; y+= $1^2; n++ } END { if (n > 0) print x / n,
sqrt(y/n-(x/n)^2);}'
44.7755 1.88373

It looks like let g:matchup_delim_start_plaintext = 0 reduces the startup time by 50% (vanilla was 34.61: difference without matchparen and delim plaintext run: 4.93ms; difference full matchup: 10.17ms).

from vim-matchup.

andymass avatar andymass commented on May 20, 2024

I improved the load time even further for plain text files, so the startup time should differ less between the states of the let g:matchup_delim_start_plaintext option.

from vim-matchup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.