Tuesday, October 24, 2017

Re: Vim startup profiling

Hi Bram,

2017/10/24 Tue 5:45:40 UTC+9 Bram Moolenaar wrote:
> Ken Takata wrote:
>
> > 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
>
> 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"?

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

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment