Sunday, July 16, 2023

Re: Improving vim startuptime

On 2023-07-17, Manas wrote:
> On Sun, Jul 16, 2023 at 10:55:04AM -0700, Gary Johnson wrote:
> > It depends, of course, on why it is slow. You can start vim with
> > the --startuptime option to get a better idea of where the slowdown
> > is. See ":help --startuptime".
> >
> > For example, starting vim on my Cygwin system was really slow
> > because I wrote my vimrc and some plugins as I would for Unix, where
> > running external programs is really fast. I re-wrote those to make
> > less use of external programs.
> >
> > As another example, starting vim on a remote Linux machine via ssh
> > and X from a local Linux machine can be slow if the connection is
> > slow because vim communicates with the X server and the terminal on
> > the local machine. I don't know what to do in that case other than
> > be patient or start vim with -X and forgo some of the features of X.
> `startuptime` surprisingly shows me a mere 656ms, while hyperfine shows
> me 2.7s. I am not sure how this discrepancy is arising. Here is the full
> log. https://pastebin.mozilla.org/uTrJ7i8N
>
> I see 234ms (out of those 656ms, ~35%) due to VimEnter autocommands. My
> autocommands are just scattered throughout vimrc. Most of them are like:
>
> au FileType <list> [mappings|calls]
>
> Maybe there is a way to organize them better?
>
> And there are a ton of plugins too. Is there any way to only source them
> conditionally?
>
> I can also try removing some of the old plugins. I haven't done a
> cleanup in a while.

All of those things are possible and probably good ideas, but
driving them all to zero would improve the time by only 656 ms and
still leaves you with an annoying 2.1 s unaccounted for.

The output of hyperfine shows only the program name. What command
are you executing? If the command was something like this,

vim -cq

then I can't explain what vim could be doing from the time it
printed "--- VIM STARTED ---" in the log until it exited.

It would be interesting to see what hyperfine measures with the
command

vim -N -u NONE -i NONE -X -cq

Regards,
Gary

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20230716200123.GM6600%40phoenix.

No comments:

Post a Comment