From owner-freebsd-current@FreeBSD.ORG Mon Nov 24 12:16:04 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 58C0616A4CE for ; Mon, 24 Nov 2003 12:16:04 -0800 (PST) Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 533EC43F3F for ; Mon, 24 Nov 2003 12:16:03 -0800 (PST) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.12.10/8.12.10) with ESMTP id hAOKG25g002861 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 24 Nov 2003 15:16:02 -0500 (EST) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.11.6/8.9.1) id hAOKFvL19209; Mon, 24 Nov 2003 15:15:57 -0500 (EST) (envelope-from gallatin@cs.duke.edu) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16322.26365.159173.946033@grasshopper.cs.duke.edu> Date: Mon, 24 Nov 2003 15:15:57 -0500 (EST) To: freebsd-current@freebsd.org X-Mailer: VM 6.75 under 21.1 (patch 12) "Channel Islands" XEmacs Lucid Subject: 40% slowdown with dynamic /bin/sh X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: freebsd-current@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Nov 2003 20:16:04 -0000 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