SHELL=/bin/sh vs bash performance

Michael Stahl mstahl at redhat.com
Thu Sep 27 04:57:23 PDT 2012


because the topic of shells for the build system came up on IRC:

in [1] it is claimed that dash is faster, that could be relevant to us
given how we spawn boatloads of shells: "The boot speed improvements in
Ubuntu 6.10 were often incorrectly attributed to Upstart ... These
improvements were in fact largely due to the changed /bin/sh."

also man bash says:

> BUGS
>        It's too big and too slow.

following numbers are from my Fedora 17 system, with the toy attachment
that spawns 100k shells running "true" (only one run each):

> [0] ms at bastet:~ > SHELL=/bin/bash time ./a.out 
> /bin/bash
> 92.95user 113.48system 3:45.26elapsed 91%CPU (0avgtext+0avgdata 1276maxresident)k
> 0inputs+0outputs (0major+37438873minor)pagefaults 0swaps

> [0] ms at bastet:~ > ls -l /bin/sh
> lrwxrwxrwx. 1 root root 4  5. Aug 23:25 /bin/sh -> bash
> [0] ms at bastet:~ > SHELL=/bin/sh time ./a.out 
> /bin/sh
> 93.47user 112.89system 3:45.37elapsed 91%CPU (0avgtext+0avgdata 1276maxresident)k
> 0inputs+0outputs (0major+37338986minor)pagefaults 0swaps

> [0] ms at bastet:~ > SHELL=/bin/dash time ./a.out 
> /bin/dash
> 1.11user 9.06system 1:34.89elapsed 10%CPU (0avgtext+0avgdata 608maxresident)k
> 0inputs+0outputs (0major+19148968minor)pagefaults 0swaps

because i couldn't believe the difference i thought perhaps my .bashrc
makes it much slower so i've cleared it and logged in via ssh, which
makes it not that much faster:

> -bash-4.2$ SHELL=/bin/sh time ./a.out
> /bin/sh
> 85.96user 110.53system 3:38.24elapsed 90%CPU (0avgtext+0avgdata 1264maxresident)k
> 0inputs+0outputs (0major+37067614minor)pagefaults 0swaps

so clearly there is a measurable benefit to using /bin/dash as shell.

considering the above i'd like the build system to continue to support
non-bash shells and also it would be great to have a tinderbox using
non-bash /bin/sh to build in order to detect breakage (this does not
require a new tinderbox, at least for Fedora there is a "dash" package,
it would just require symlinking /bin/sh to it).

on a related note it would also be great to have a tinderbox with GNU
make 3.81, because (on non-windows platforms) that is supposed to work
but breaks from time to time because only Debian still ships it by
default AFAIK.

[1] https://wiki.ubuntu.com/DashAsBinSh





More information about the LibreOffice mailing list