40% slowdown with dynamic /bin/sh

From: Andrew Gallatin <gallatin_at_cs.duke.edu>
Date: Mon, 24 Nov 2003 15:15:57 -0500 (EST)
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
Received on Mon Nov 24 2003 - 11:16:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:30 UTC