Vim startup profiling

161 views
Skip to first unread message

Ni Va

unread,
May 23, 2017, 12:09:42 PM5/23/17
to vim_use
Hi,

Profiling vim startup returns the fact that some files are loaded N times.
nivacolors.vim
syncolor.vim

How can I fix that to load those files just one time please ?
Thank you


clock elapsed: other lines

000.000 000.000: --- VIM STARTING ---
000.000 000.000: Allocated generic buffers
001.000 001.000: locale set
003.000 002.000: GUI prepared
003.000 000.000: clipboard setup
003.000 000.000: window checked
004.000 001.000: inits 1
008.000 004.000: parsing arguments
008.000 000.000: expanding arguments
008.000 000.000: shell init
008.000 000.000: inits 2
009.000 001.000: init highlight
217.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\colors\nivacolors.vim
223.000 002.000 002.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
225.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
226.000 007.000 005.000: sourcing D:\Logiciels\Vim\vimfiles\colors\nivacolors.vim
226.000 007.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
243.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\c.vim
244.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\cs.vim
244.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\ldf.vim
245.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\log.vim
245.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\logconfedit.vim
246.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\py.vim
246.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\snippets.vim
247.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\sqllog.vim
247.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\UltiSnips.vim
248.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\vat.vim
248.000 000.000 000.000: sourcing D:\Logiciels\Vim\vimfiles\ftdetect\xaml.vim
249.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\awl\ftdetect\awl.vim
250.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\sonictemplate-vim\ftdetect\stpl.vim
252.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-ps1\ftdetect\ps1.vim
252.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-ps1\ftdetect\ps1xml.vim
253.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-ps1\ftdetect\xml.vim
256.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\lang/menu_fr_fr.latin1.vim
256.000 001.000 000.000: sourcing D:\Logiciels\Vim\vim80\lang\menu_fr.utf-8.vim
258.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\autoload\paste.vim
294.000 040.000 039.000: sourcing D:\Logiciels\Vim\vim80/menu.vim
294.000 068.000 028.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim
294.000 076.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
295.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax/nosyntax.vim
298.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
299.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
300.000 003.000 003.000: sourcing D:\Logiciels\Vim\vimfiles\colors\nivacolors.vim
300.000 004.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
300.000 005.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
301.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim
302.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\ftplugin.vim
303.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\indent.vim
305.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax/nosyntax.vim
307.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
308.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
309.000 003.000 003.000: sourcing D:\Logiciels\Vim\vimfiles\colors\nivacolors.vim
309.000 004.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
309.000 005.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
310.000 300.000 214.000: sourcing $VIM\_vimrc

Marc Weber

unread,
May 23, 2017, 12:14:24 PM5/23/17
to vim_use
> Thank you
Sped up by using a plugin manager supporting lazy loading or as needed
(vim-addon-manager/Neobundle maybe more).

Typically sourcing twice is not a problem, often guard [1] like guard
has been setup which is a quick workraound which immediately saves most
time.

Marc Weber

[1]

if exists("loaded_<name>")
finish
endif
let loaded_<name> = 1

....

Ni Va

unread,
May 23, 2017, 3:46:01 PM5/23/17
to vim_use
Ok this one seems better than vundle and save me 100ms at startup but I dig.
https://github.com/junegunn/vim-plug

Thank you Marc !

Ni Va

unread,
May 24, 2017, 4:39:34 AM5/24/17
to vim_use
Ok I save 100ms using the plugin manager vim-plug but not enough for me.
Is anyone can advise me or explain to me why some files are loaded twice and take twice or more times N msec:
- vim80/menu.vim
- vim80\filetype.vim


Thank you
_____________________________

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

000.000 000.000: --- VIM STARTING ---
000.000 000.000: Allocated generic buffers
002.000 002.000: locale set
004.000 002.000: GUI prepared
004.000 000.000: clipboard setup
004.000 000.000: window checked
004.000 000.000: inits 1
006.000 002.000: parsing arguments
006.000 000.000: expanding arguments
007.000 001.000: shell init
007.000 000.000: inits 2
008.000 001.000: init highlight
018.000 003.000 003.000: sourcing D:\Logiciels\Vim/awesomeplugins/vim/vim-plug-master/plug.vim
043.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\awl\ftdetect\awl.vim
044.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\sonictemplate-vim\ftdetect\stpl.vim
045.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-ps1\ftdetect\ps1.vim
046.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-ps1\ftdetect\ps1xml.vim
047.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-ps1\ftdetect\xml.vim
052.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\lang/menu_fr_fr.latin1.vim
052.000 002.000 001.000: sourcing D:\Logiciels\Vim\vim80\lang\menu_fr.latin1.vim
054.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\autoload\paste.vim
096.000 047.000 044.000: sourcing D:\Logiciels\Vim\vim80/menu.vim
096.000 072.000 025.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim
097.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\ftplugin.vim
099.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\indent.vim
104.000 002.000 002.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
104.000 003.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
104.000 004.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
119.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax/nosyntax.vim
122.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
122.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
122.000 004.000 003.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
124.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax/nosyntax.vim
127.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
127.000 002.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
127.000 004.000 002.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
128.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim
129.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\ftplugin.vim
130.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\indent.vim
132.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax/nosyntax.vim
134.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
135.000 002.000 002.000: sourcing D:\Logiciels\Vim\vim80\syntax\synload.vim
135.000 004.000 001.000: sourcing D:\Logiciels\Vim\vim80\syntax\syntax.vim
138.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
140.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
142.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\syntax\syncolor.vim
142.000 005.000 005.000: sourcing D:\Logiciels\Vim\vimfiles\colors\nivacolors.vim
143.000 134.000 038.000: sourcing $VIM\_vimrc
143.000 001.000: sourcing vimrc file(s)
144.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\awl\plugin\awl.vim
145.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\backup\plugin\backup.vim
146.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\codi.vim-master\plugin\codi.vim
147.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\comfortable-motion.vim\plugin\comfortable_motion.vim
150.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\ctrlp.vim-master\autoload\ctrlp\mrufiles.vim
150.000 002.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\ctrlp.vim-master\plugin\ctrlp.vim
152.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\DirDiff.vim\plugin\dirdiff.vim
154.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\Execute-selection-in-Python-and-append-master\plugin\pythonExecuteAppendOrReplace.vim
156.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\L9-master\autoload\l9.vim
156.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\L9-master\plugin\l9.vim
158.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\limelight.vim\plugin\limelight.vim
159.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\matchit.zip-master\plugin\matchit.vim
163.000 003.000 003.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\mru.vim-master\plugin\mru.vim
165.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\sonictemplate-vim\plugin\sonictemplate.vim
166.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\tabular-master\plugin\Tabular.vim
170.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\unite.vim\autoload\unite\custom.vim
170.000 002.000 002.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\unite.vim\plugin\unite\bookmark.vim
171.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\unite.vim\plugin\unite\buffer.vim
172.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\unite.vim\plugin\unite\window.vim
173.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\unite.vim\plugin\unite.vim
176.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline.vim
178.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\init.vim
180.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\parts.vim
180.000 006.000 005.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\plugin\airline.vim
181.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-themes\plugin\airline-themes.vim
183.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-easy-align\plugin\easy_align.vim
189.000 005.000 005.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-fugitive\plugin\fugitive.vim
190.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-interestingwords-master\plugin\interestingwords.vim
191.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vimfiler.vim-master\plugin\vimfiler.vim
193.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vimproc\plugin\vimproc.vim
195.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\getscriptPlugin.vim
196.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\gzip.vim
198.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\plugin\logiPat.vim
198.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\manpager.vim
199.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\matchparen.vim
200.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\netrwPlugin.vim
201.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\plugin\rrhelper.vim
201.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\spellfile.vim
202.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\tarPlugin.vim
203.000 000.000 000.000: sourcing D:\Logiciels\Vim\vim80\plugin\tohtml.vim
204.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\plugin\vimballPlugin.vim
205.000 001.000 001.000: sourcing D:\Logiciels\Vim\vim80\plugin\zipPlugin.vim
205.000 035.000: loading plugins
205.000 000.000: loading packages
208.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\tabular-master\autoload\tabular.vim
210.000 004.000 004.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\tabular-master\after\plugin\TabularMaps.vim
210.000 001.000: loading after plugins
210.000 000.000: inits 3
211.000 001.000 001.000: sourcing $VIMRUNTIME\menu.vim
247.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions.vim
250.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\quickfix.vim
252.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\unite.vim
253.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\ctrlp.vim
255.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\branch.vim
257.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\whitespace.vim
261.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\wordcount.vim
268.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\section.vim
269.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\highlighter.vim
274.000 001.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\themes.vim
274.000 002.000 001.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-themes\autoload\airline\themes\cool.vim
284.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\util.vim
287.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\builder.vim
289.000 000.000 000.000: sourcing D:\Logiciels\Vim\awesomeplugins\vim\vim-airline-master\autoload\airline\extensions\default.vim
323.000 108.000: starting GUI
324.000 001.000: reading viminfo
325.000 001.000: GUI delay
325.000 000.000: setting raw mode
325.000 000.000: start termcap
325.000 000.000: clearing screen
332.000 007.000: opening buffers
332.000 000.000: BufEnter autocommands
332.000 000.000: editing files in windows
334.000 002.000: VimEnter autocommands
334.000 000.000: before starting main loop
335.000 001.000: first screen update
335.000 000.000: --- VIM STARTED ---

Antony Scriven

unread,
May 24, 2017, 5:00:28 AM5/24/17
to vim users
Your colorscheme or vimrc or both appears to be causing
syncolor.vim to go bananas. I'd take a look at the code
there to find out what's going on. filetype.vim and menu.vim
are just big. You can disable loading menu.vim with `set
guioptions+=M` if you don't need it. --Antony
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Dominique Pellé

unread,
May 24, 2017, 5:01:31 AM5/24/17
to Vim List
Ni Va <niva...@gmail.com>:

> Le mardi 23 mai 2017 21:46:01 UTC+2, Ni Va a écrit :
>> Le mardi 23 mai 2017 18:14:24 UTC+2, MarcWeber a écrit :
>> > > Thank you
>> > Sped up by using a plugin manager supporting lazy loading or as needed
>> > (vim-addon-manager/Neobundle maybe more).
>> >
>> > Typically sourcing twice is not a problem, often guard [1] like guard
>> > has been setup which is a quick workraound which immediately saves most
>> > time.
>> >
>> > Marc Weber
>> >
>> > [1]
>> >
>> > if exists("loaded_<name>")
>> > finish
>> > endif
>> > let loaded_<name> = 1
>> >
>> > ....
>>
>> Ok this one seems better than vundle and save me 100ms at startup but I dig.
>> https://github.com/junegunn/vim-plug
>>
>> Thank you Marc !
>
> Ok I save 100ms using the plugin manager vim-plug but not enough for me.
> Is anyone can advise me or explain to me why some files are loaded twice and take twice or more times N msec:
> - vim80/menu.vim
> - vim80\filetype.vim


I did not have the time to analyze your problem,
but I recall vaguely that if your ~/.vimrc contains
the "colorscheme" command, it should be at the
end of the .vimrc otherwise some scripts are sourced
twice. Sorry if this is vague, I don't remember the
details and I don't have the time to look at it now.
But perhaps it helps anyway.

Dominique

Marc Weber

unread,
May 24, 2017, 5:14:54 AM5/24/17
to vim_use

> Ok I save 100ms using the plugin manager vim-plug but not enough for me.
> Is anyone can advise me or explain to me why some files are loaded twice and take twice or more times N msec:
> - vim80/menu.vim
> - vim80\filetype.vim

I never compared vimplug vs VAM, but I'd be interested in it.
AFAIK parsing commands such as Plug takes time, you may want to lookup
its definition and call that code in .vimrc instead - maybe it saves you 1 ms.


VAM is only 770 lines - because we split the 'everyday runtime code' and
the 'update/install' code. This eventually could be done for VimPlug as
well.

If you want to give VAM a try you can create dictionaries like this:

{'filetype_regex': '\%(rb)$', 'names': ['vim-ruby', 'vim-addon-rdebug', 'vim-addon-ruby-debug-ide', 'textobj-rubyblock' ]}
{'name': 'matchit.zip'}

and write such a file and load by

call vam#Scripts(expand('~/.vim-scripts'), {})

github:repo/name can be used as names.

I don't say use VAM, but it could shed some light into whether you can be
faster and wheter VimPlug can be improved. It has features VAM does not
have - such as fixing version.

VAM has had an experimental mode 'merging all plugin/*' files into one
to seed things up - but its likely to break code such as did_load or
similar.

See vam#install#MergePluginFiles( ..

But as far as I remember I stopped using it myself even before switching
to SSD / getting a faster machine.

Marc Weber

Ni Va

unread,
May 24, 2017, 5:15:10 AM5/24/17
to vim_use
Ok thank you for your advices Dominique And Anthony.
Good Journey

Christian Brabandt

unread,
May 24, 2017, 3:54:12 PM5/24/17
to vim users

On Mi, 24 Mai 2017, Antony Scriven wrote:

> Your colorscheme or vimrc or both appears to be causing
> syncolor.vim to go bananas. I'd take a look at the code
> there to find out what's going on. filetype.vim and menu.vim
> are just big. You can disable loading menu.vim with `set
> guioptions+=M` if you don't need it.

Yes, and it must be set before the menu vim script is loaded, so before
any filetype or :syn on commands in your vimrc, so it should be done
relatively early in

Best,
Christian
--
Das X ist der Klappstuhl des Alphabets.
-- Ramòn Gómez de la Serna
Message has been deleted

Ken Takata

unread,
May 26, 2017, 9:36:40 AM5/26/17
to vim_use
Hi,

2017/5/24 Wed 17:39:34 UTC+9 Ni Va wrote:
> Le mardi 23 mai 2017 21:46:01 UTC+2, Ni Va a écrit :
> > Le mardi 23 mai 2017 18:14:24 UTC+2, MarcWeber a écrit :
> > > > Thank you
> > > Sped up by using a plugin manager supporting lazy loading or as needed
> > > (vim-addon-manager/Neobundle maybe more).
> > >
> > > Typically sourcing twice is not a problem, often guard [1] like guard
> > > has been setup which is a quick workraound which immediately saves most
> > > time.
> > >
> > > Marc Weber
> > >
> > > [1]
> > >
> > > if exists("loaded_<name>")
> > > finish
> > > endif
> > > let loaded_<name> = 1
> > >
> > > ....
> >
> > Ok this one seems better than vundle and save me 100ms at startup but I dig.
> > https://github.com/junegunn/vim-plug
> >
> > Thank you Marc !
>
> Ok I save 100ms using the plugin manager vim-plug but not enough for me.
> Is anyone can advise me or explain to me why some files are loaded twice and take twice or more times N msec:
> - vim80/menu.vim
> - vim80\filetype.vim

> 096.000 047.000 044.000: sourcing D:\Logiciels\Vim\vim80/menu.vim
> 096.000 072.000 025.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim

menu.vim uses `globpath()` to search some kind of files under the runtimepath.
If you search `globpath` in menu.vim, you may find the following lines:

let s:n = globpath(&runtimepath, "colors/*.vim")
let s:n = globpath(&runtimepath, "keymap/*.vim")
let s = globpath(&rtp, "spell/*." . enc . ".spl")
let s:n = globpath(&runtimepath, "compiler/*.vim")

Color schemes, keymaps, spell files and compiler plugins are searched when
menu.vim is loaded.
This is why it takes long time to be loaded.

Unlike those items, file types are not listed automatically. If a user
selects "Syntax" -> "Show File Types in Menu", they will be listed.
If we use a similar way for color schemes etc., the startup time would be
reduced.

Regards,
Ken Takata

Christian Brabandt

unread,
May 31, 2017, 1:55:41 PM5/31/17
to vim_use, Bram Moolenaar

On Fr, 26 Mai 2017, Ken Takata wrote:

> > Ok I save 100ms using the plugin manager vim-plug but not enough for me.
> > Is anyone can advise me or explain to me why some files are loaded twice and take twice or more times N msec:
> > - vim80/menu.vim
> > - vim80\filetype.vim
>
> > 096.000 047.000 044.000: sourcing D:\Logiciels\Vim\vim80/menu.vim
> > 096.000 072.000 025.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim
>
> menu.vim uses `globpath()` to search some kind of files under the runtimepath.
> If you search `globpath` in menu.vim, you may find the following lines:
>
> let s:n = globpath(&runtimepath, "colors/*.vim")
> let s:n = globpath(&runtimepath, "keymap/*.vim")
> let s = globpath(&rtp, "spell/*." . enc . ".spl")
> let s:n = globpath(&runtimepath, "compiler/*.vim")
>
> Color schemes, keymaps, spell files and compiler plugins are searched when
> menu.vim is loaded.
> This is why it takes long time to be loaded.
>
> Unlike those items, file types are not listed automatically. If a user
> selects "Syntax" -> "Show File Types in Menu", they will be listed.
> If we use a similar way for color schemes etc., the startup time would be
> reduced.

I took a brief look into that. First, I don't think it would be easily
possible to avoid the globpath() for the colorschemes and other scripts.

The syntax script seems to be compile time dependent, so while this
works, I assume it does not work correctly for filetypes/syntax scripts
you installed as extra package and I guess this is not what we want for
colorschemes and the other script types.

I think, it could be beneficial, if globpath() and glob() did allow for
e.g. OR'ing the script, e.g. something like this should be a lot faster:

globpath(&runtimepath, "{colors,spell,keymap,compiler}/*.vim")

Because we could then manually filter the resulting list. Unfortunately,
this syntax is not supported by glob()/globpath(). That could be a
worthwhile addition.

Mit freundlichen Grüßen
Christian
--
Machen Sie sich erst einmal unbeliebt, dann werden Sie auch ernst
genommen.
-- Konrad Adenauer

Ken Takata

unread,
Oct 23, 2017, 11:25:35 AM10/23/17
to vim_use
Hi,

2017/5/26 Fri 22:36:40 UTC+9 Ken Takata wrote:
> > 096.000 047.000 044.000: sourcing D:\Logiciels\Vim\vim80/menu.vim
> > 096.000 072.000 025.000: sourcing D:\Logiciels\Vim\vim80\filetype.vim
>
> menu.vim uses `globpath()` to search some kind of files under the
runtimepath.
> If you search `globpath` in menu.vim, you may find the following lines:
>
> let s:n = globpath(&runtimepath, "colors/*.vim")
> let s:n = globpath(&runtimepath, "keymap/*.vim")
> let s = globpath(&rtp, "spell/*." . enc . ".spl")
> let s:n = globpath(&runtimepath, "compiler/*.vim")
>
> Color schemes, keymaps, spell files and compiler plugins are searched when
> menu.vim is loaded.
> This is why it takes long time to be loaded.
>
> Unlike those items, file types are not listed automatically. If a user
> selects "Syntax" -> "Show File Types in Menu", they will be listed.
> If we use a similar way for color schemes etc., the startup time would be
> reduced.

I wrote a patch for reduce the loading the of menu.vim by skip using
globpath().

https://bitbucket.org/k_takata/vim-ktakata-mq/src/bf92d701bca2ef46f6caa64aae89438e039370bb/improve-loading-menu.vim.patch?at=default&fileviewer=file-view-default

Instead of searching colors/*.vim and other files, the following menuitems are
added in the menu:

Edit > Show Color Schemes in Menu
Edit > Show Keymaps in Menu
Tools > Show Compiler Settings in Menu

If these menuitems are selected, all available colorschemes etc. are shown
in the menu. If a user want to load them at startup, the following line
can be added in .vimrc:
:let do_globpath_menus = 1
(This is similar to `:let do_syntax_sel_menu = 1`.)


In my environment, the loading time of menu.vim is:
Without this patch: 30 - 50 ms
Skip using globpath: 15 - 20 ms

Regards,
Ken Takata

Bram Moolenaar

unread,
Oct 23, 2017, 4:45:40 PM10/23/17
to vim...@googlegroups.com, Ken Takata
Not a very big difference. But still worth it if you never use those
menus.

I wonder if we can do this lazily. Thus fill in the missing entries
when we start waiting for the user to type. Should be around the same
place where timers may be triggered. Not sure if we can do it with an
actual timer from the menu.vim script though. Might need a special kind
of timer. Perhaps an "idle timer"?

--
With sufficient thrust, pigs fly just fine.
-- RFC 1925

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Ken Takata

unread,
Oct 24, 2017, 8:59:32 AM10/24/17
to vim_use
Hi Bram,

How about this additional patch, then?
https://bitbucket.org/k_takata/vim-ktakata-mq/src/938cf6a5e03ef2ccbc131ca2a3eb5bae364beb7b/improve-loading-menu.vim-cursorhold.patch?at=default&fileviewer=file-view-default

This uses CursorHold to load the menuitems when idle.

Regards,
Ken Takata

Bram Moolenaar

unread,
Oct 24, 2017, 5:20:09 PM10/24/17
to vim...@googlegroups.com, Ken Takata
I like the idea. I'll wait for a few people to try it out.

--
Trees moving back and forth is what makes the wind blow.

Ken Takata

unread,
Oct 25, 2017, 8:04:35 AM10/25/17
to vim_use
Hi,

I have updated the patches:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/c58b17bb22261436910d77dcda76409edd962ad5/improve-loading-menu.vim.patch?at=default&fileviewer=file-view-default

Changes are:
* Merge the two patches into one.
* Update the document.
* Rename the global variable `do_globpath_menus` to `do_lazyload_menus`.
I'm still wondering what is the best name for this variable.
* Remove `has('win16')`. Not needed anymore.
* Add <silent> to the "Show File Types in Menu" item. Showing the command
of this item is not so useful.

Regards,
Ken Takata

Christian Brabandt

unread,
Oct 25, 2017, 8:28:50 AM10/25/17
to vim_use

Hi Ken,
I briefly looked at your patch and have some feedback.

On Mi, 25 Okt 2017, Ken Takata wrote:

> Changes are:
> * Merge the two patches into one.
> * Update the document.
> * Rename the global variable `do_globpath_menus` to `do_lazyload_menus`.
> I'm still wondering what is the best name for this variable.
> * Remove `has('win16')`. Not needed anymore.
> * Add <silent> to the "Show File Types in Menu" item. Showing the command
> of this item is not so useful.

+If you want to have all these items already present at startup, add: >
+ :let do_lazyload_menus = 1

I think this variable should either be called `do_no_lazyload_menus` or
the value should be 0, since by default the menus will be lazy loaded.

+ let n = globpath(&runtimepath, "colors/*.vim")

I think that should be

+ let n = globpath(&runtimepath, "colors/*.vim", 1, 1)

So you have a list available already and don't need to split later on
manually and you probably do want to ignore the suffixes and wildignore
options, if only the user having set them to bad values.

The same holds for the keymap and compiler runtime files.

+ augroup SetupLazyloadMenus
+ au!
+ au CursorHold,CursorHoldI * call <SID>SetupLazyloadMenus() | au! SetupLazyloadMenus
+ augroup END

Is this actually a good idea to delete the augroup from within itself?

BTW: there are many runtime file variables. Perhaps we should start to
document internal runtime file variables in a help file at a central
place.

Also I am starting to wonder, whether it would make sense to start using
a common prefix, so that the names are more consistent and less likely
to clash with user variables, e.g. something like
vim_ftplugin_undo
vim_indent_undo
vim_menu_init_immediate

Christian
--
Neuer MS-Slogan:
Speicherst Du noch oder fluchst Du schon?

Ken Takata

unread,
Oct 26, 2017, 9:22:37 AM10/26/17
to vim_use
Hi,

2017/10/25 Wed 21:28:50 UTC+9 Christian Brabandt wrote:
> Hi Ken,
> I briefly looked at your patch and have some feedback.
>
> On Mi, 25 Okt 2017, Ken Takata wrote:
>
> > Changes are:
> > * Merge the two patches into one.
> > * Update the document.
> > * Rename the global variable `do_globpath_menus` to `do_lazyload_menus`.
> > I'm still wondering what is the best name for this variable.
> > * Remove `has('win16')`. Not needed anymore.
> > * Add <silent> to the "Show File Types in Menu" item. Showing the command
> > of this item is not so useful.
>
> +If you want to have all these items already present at startup, add: >
> + :let do_lazyload_menus = 1
>
> I think this variable should either be called `do_no_lazyload_menus` or
> the value should be 0, since by default the menus will be lazy loaded.

Okay, I changed it to `do_no_lazyload_menus`:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/cda66cbfc90b98a5ca6c16229ee129fd448c1bad/improve-loading-menu.vim.patch?fileviewer=file-view-default

Actually, menu.vim only checks the existence of the global variable, the value
is not checked. This is the same as other variable in menu.vim.


> + let n = globpath(&runtimepath, "colors/*.vim")
>
> I think that should be
>
> + let n = globpath(&runtimepath, "colors/*.vim", 1, 1)
>
> So you have a list available already and don't need to split later on
> manually and you probably do want to ignore the suffixes and wildignore
> options, if only the user having set them to bad values.
>
> The same holds for the keymap and compiler runtime files.

It makes the code simpler. Updated.


> + augroup SetupLazyloadMenus
> + au!
> + au CursorHold,CursorHoldI * call <SID>SetupLazyloadMenus() | au! SetupLazyloadMenus
> + augroup END
>
> Is this actually a good idea to delete the augroup from within itself?

Deleting autocommands in the group is a usual usage. The similar usage can be
found in `augroup LoadBufferMenu` in menu.vim. Moreover, just using `au!`
in an augroup is a normal usage. Deleting an autogroup within itself by
`augroup!` doesn't work in contrast. It causes W19 or E936.
Actually, I want to delete the group here...


> BTW: there are many runtime file variables. Perhaps we should start to
> document internal runtime file variables in a help file at a central
> place.
>
> Also I am starting to wonder, whether it would make sense to start using
> a common prefix, so that the names are more consistent and less likely
> to clash with user variables, e.g. something like
> vim_ftplugin_undo
> vim_indent_undo
> vim_menu_init_immediate

Regards,
Ken Takata

Reply all
Reply to author
Forward
0 new messages