Re: Improving startup time for autocommands

44 views
Skip to first unread message

Manas

unread,
Feb 13, 2021, 5:50:08 AM2/13/21
to v...@vim.org
Hi everyone, I am facing some delay in startup time and doing
`--startuptime`, I can see that autocommands are the reason for the
delay. Specifically those autocmds where I am using BufEnter etc. type
events. I have quite a number of autocmds for various FileType(s)
and various events.

Can I get some suggestions on how to improve upon these or whether
I should switch autocmds with something else to improve upon
startuptime?

Thank you
--
Manas
CSAM Undergraduate | 2022
IIIT-Delhi, India

Paul

unread,
Feb 13, 2021, 6:33:30 AM2/13/21
to v...@vim.org
On Sat, Feb 13, 2021 at 04:19:44PM +0530, Manas wrote:
>Hi everyone, I am facing some delay in startup time and doing
>`--startuptime`, I can see that autocommands are the reason for the
>delay. Specifically those autocmds where I am using BufEnter etc. type
>events. I have quite a number of autocmds for various FileType(s)
>and various events.
>
>Can I get some suggestions on how to improve upon these or whether
>I should switch autocmds with something else to improve upon
>startuptime?

See if you can use the FileType event instead of BufEnter.
signature.asc

Gary Johnson

unread,
Feb 13, 2021, 4:51:46 PM2/13/21
to vim...@googlegroups.com
On 2021-02-13, Manas wrote:
> Hi everyone, I am facing some delay in startup time and doing
> `--startuptime`, I can see that autocommands are the reason for the
> delay. Specifically those autocmds where I am using BufEnter etc. type
> events. I have quite a number of autocmds for various FileType(s)
> and various events.
>
> Can I get some suggestions on how to improve upon these or whether
> I should switch autocmds with something else to improve upon
> startuptime?

When I run vim with --startuptime, I see only two autocommand
events, "BufEnter autocommands" and "VimEnter autocommands", and
they each consume only a few milliseconds.

If you are seeing significantly longer times than these, I would
suspect one or two of your autocommands are taking an
extraordinarily long time to run. Since --startuptime doesn't
resolve individual autocommands, and since -V doesn't include times,
your best bet for finding the problem may be some sort of binary
search for the offending autocommand(s). That is, comment-out half
of your autocommands, check --startuptime times again, see how much
they improved, then comment-out or un-comment-out half of the
appropriate set and repeat.

Once you find the one(s) taking a long time, you can post them here
for some advice on improving those times.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages