Monday, July 17, 2023

Re: Improving vim startuptime

On Mon, Jul 17, 2023 at 01:01:12AM +0200, Dominique Pellé wrote:
> Manas <manas18244@iiitd.ac.in> wrote:
>
> > Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/vim/src=/usr/src/debug/vim -flto=auto -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
> > Linking: gcc -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -L/usr/local/lib -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.36/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.36/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
>
> I see you use:
> * for compilation: -flto=auto ... -O2 (actually also -O1 but last one
> overrides)
> * for linking: -Wl,-O1 -flto=auto
>
> I'm not 100% sure, but since you use LTO (Link Time Optimization),
> the compilation happens at link time, so I suppose that -O1 is used
> instead of -O2. Try to make sure that -Wl,-O2 is also used at link
> time if you use LTO, it may help to speed up Vim significantly.
>
I did two fresh builds,

1. CFLAGS=-O2 -flto=auto; LDFLAGS=-Wl,-O2 -flto=auto
2. Default: CFLAGS=-O2; LDFLAGS=<no-optimizations>

and I didn't find any significant different in startuptimes.

# Benchmarks

1. With LTO and -O2
```
$ hyperfine -w 5 "./vim.lto -N -u NONE -i NONE -X -cq"
Benchmark 1: ./vim.lto -N -u NONE -i NONE -X -cq
Time (mean ± σ): 2.028 s ± 0.004 s [User: 0.012 s, System: 0.010 s]
Range (min … max): 2.024 s … 2.035 s 10 runs


$ time ./vim.lto -u NONE -i NONE -X -cq

real 0m0.021s
user 0m0.011s
sys 0m0.010s
```

2. Without LTO and -O2 (at compile-time)

```
$ hyperfine -w 5 "./vim -N -u NONE -i NONE -X -cq"
Benchmark 1: ./vim -N -u NONE -i NONE -X -cq
Time (mean ± σ): 2.030 s ± 0.009 s [User: 0.011 s, System: 0.011 s]
Range (min … max): 2.023 s … 2.052 s 10 runs


$ time ./vim -u NONE -i NONE -X -cq

real 0m0.024s
user 0m0.010s
sys 0m0.014s
```

--
Manas

--
--
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/bcswrqks64imcsxppybhl62ivdkxggxkgodpjkyeact6jna323%40cqiw4sng4fc7.

No comments: