Date: Mon, 24 Nov 2003 15:15:57 -0500 (EST) From: Andrew Gallatin <gallatin@cs.duke.edu> To: freebsd-current@freebsd.org Subject: 40% slowdown with dynamic /bin/sh Message-ID: <16322.26365.159173.946033@grasshopper.cs.duke.edu>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16322.26365.159173.946033>