40% slowdown with dynamic /bin/sh
Andrew Gallatin
gallatin at cs.duke.edu
Mon Nov 24 12:16:04 PST 2003
Here is a simple test which times the execution of a null
shell script. It basically times fork/exec of the chosen shell.
% cat harness.sh
#!/bin/sh
sh=$1
cnt=$2
i=0
while [ $i -le $cnt ]; do
$sh ./foo
i=`expr $i + 1`
done
#eof
%cat foo
exit
#eof
% ldd sh.dynamic
sh.dynamic:
libedit.so.4 => /lib/libedit.so.4 (0x2808c000)
libncurses.so.5 => /lib/libncurses.so.5 (0x280a1000)
libc.so.5 => /lib/libc.so.5 (0x280e1000)
% ldd sh.static
ldd: sh.static: not a dynamic executable
Here are some timings taken from ref5.freebsd.org:
% /usr/bin/time ./harness.sh ./sh.dynamic 100
1.55 real 0.27 user 1.11 sys
% /usr/bin/time ./harness.sh ./sh.dynamic 100
1.55 real 0.28 user 1.10 sys
% /usr/bin/time ./harness.sh ./sh.dynamic 100
1.60 real 0.21 user 1.18 sys
% ./harness.sh ./sh.static 100
1.12 real 0.08 user 0.87 sys
% ./harness.sh ./sh.static 100
1.12 real 0.08 user 0.87 sys
% ./harness.sh ./sh.static 100
1.12 real 0.11 user 0.84 sys
So.. forking a dynamic sh is roughly 40% more expensive than
forking a static copy of sh. This is embarrassing.
I propose that we at least make /bin/sh static. (and not add a
/sbin/sh; if we must have a dynamic sh, import pdksh, or put a
dynamically linked sh in /usr/bin/sh).
I'd greatly prefer that the the dynamic root default be backed out
until a substantial amount of this performance can be recovered.
Drew
More information about the freebsd-current
mailing list