Return-Path: Delivered-To: new-httpd-archive@hyperreal.org Received: (qmail 17931 invoked by uid 6000); 22 Dec 1999 01:58:08 -0000 Received: (qmail 17496 invoked from network); 22 Dec 1999 01:57:51 -0000 Received: from stortek.stortek.com (129.80.22.249) by taz.hyperreal.org with SMTP; 22 Dec 1999 01:57:51 -0000 Received: from swmail-atm6.StorTek.COM (swmail.stortek.com [129.80.120.123]) by stortek.stortek.com (8.9.3/8.9.3) with ESMTP id SAA18852 for ; Tue, 21 Dec 1999 18:57:24 -0700 (MST) Received: from sanitas (sanitas.stortek.com [129.80.60.133]) by swmail-atm6.StorTek.COM with ESMTP (8.7.6/8.7.3) id SAA25109 for ; Tue, 21 Dec 1999 18:57:23 -0700 (MST) From: pg@sweng.stortek.com Received: by sanitas (8.8.8+Sun/rem1.3) id SAA24108; Tue, 21 Dec 1999 18:57:22 -0700 (MST) Message-id: <199912220157.SAA24108@sanitas> Subject: [PATCH] mkshadow.sh accelerator To: new-httpd@apache.org (Apache Developers List) Date: Tue, 21 Dec 1999 18:57:22 -0700 (MST) X-Mailer: ELM [version 2.5 PL0] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org Status: O On OS/390 the overhead for fork and exec is extremely high. this make "configure" painfully slow. Most of the time is consumed by "mkshadow.sh", which executes 2 or 3 "sed"s and an "ln -s" for each symbolic link created. This patch replaces mkshadow.sh (except for a few comments). Much of the filtering by "sed" is replaced by predicates in the "find". An "awk" script then batches the commands so a single "ln -s" is issued for each directory. This roughly halves the time taken by "configure" on OS/390, and slightly improves performance on Solaris. Furthermore, this fixes a bug that was manifest when the path to the shadow directory contains a rootward segment ("/../"). Directory levels were counted incorrectly, causing creation of invalid symbolic links. Tested in builds on OS/390 and Solaris, and unit tested (no build) on MkLinux. -- gil -- StorageTek INFORMATION made POWERFUL ======================================================================== diff -bru orig/apache-1.3/configure apache-1.3/configure --- orig/apache-1.3/configure Wed Dec 8 15:04:15 1999 +++ apache-1.3/configure Wed Dec 8 13:10:54 1999 @@ -534,7 +534,8 @@ echo " + creating external package shadow tree ($shadow)" fi rm -rf $shadow 2>/dev/null - $aux/mkshadow.sh . $shadow + ( export SHELL AWK + $aux/mkshadow.sh . $shadow ) for file in $mkf $sedsubst $addconf $tplconf $pldconf $configstatus; do rm -f $shadow/$file 2>/dev/null done @@ -580,7 +581,8 @@ echo " + creating internal platform shadow tree ($shadowsrc)" fi rm -rf $shadowsrc - $aux/mkshadow.sh $src $shadowsrc + ( export SHELL AWK + $aux/mkshadow.sh $src $shadowsrc ) # delegate us to the shadow paths mkf=$shadowmkf src=$shadowsrc diff -bru orig/apache-1.3/src/helpers/mkshadow.sh apache-1.3/src/helpers/mkshadow.sh --- orig/apache-1.3/src/helpers/mkshadow.sh Tue Jun 29 13:12:58 1999 +++ apache-1.3/src/helpers/mkshadow.sh Wed Dec 8 15:02:14 1999 @@ -6,24 +6,27 @@ ## for the shadow tree generation option (--shadow) of ## Apache's Autoconf-style Interface (APACI) ## +# Heavily modified by Paul Gilmartin +# for OS/390 performance and for correct operation when +# $src or $dst contains "/../" or involve symbolic links. # # This script falls under the Apache License. # See http://www.apache.org/docs/LICENSE -# default IFS -DIFS=' -' - # source and destination directory -src=`echo $1 | sed -e 's:/$::'` -dst=`echo $2 | sed -e 's:/$::'` +src="$1" +dst="$2" +: ${SHELL=/bin/sh} # check whether source exists -if [ ! -d $src ]; then +SOURCE=`cd $src && unset PWD && $SHELL -c pwd` || { echo "mkshadow.sh:Error: source directory not found" 1>&2 exit 1 -fi + } + +SHADOW=`mkdir -p $dst && cd $dst && + unset PWD && $SHELL -c pwd` || exit $? # determine if one of the paths is an absolute path, # because then we have to use an absolute symlink @@ -35,76 +38,61 @@ /* ) oneisabs=1 ;; esac -# determine reverse directory for destination directory -dstrevdir='' -if [ "x$oneisabs" = "x0" ]; then - # (inlined fp2rp) - OIFS2="$IFS"; IFS='/' - for pe in $dst; do - dstrevdir="../$dstrevdir" - done - IFS="$OIFS2" -else - src="`cd $src; pwd`"; -fi - -# create directory tree at destination -if [ ! -d $dst ]; then - mkdir $dst -fi -DIRS="`cd $src; \ - find . -type d -print |\ - sed -e '/\/CVS/d' \ - -e '/^\.$/d' \ - -e 's:^\./::'`" -OIFS="$IFS" IFS="$DIFS" -for dir in $DIRS; do - mkdir $dst/$dir -done -IFS="$OIFS" - -# fill directory tree with symlinks to files -FILES="`cd $src; \ - find . -depth -print |\ - sed -e '/\.o$/d' \ - -e '/\.a$/d' \ - -e '/\.so$/d' \ - -e '/\.so-o$/d' \ - -e '/\.cvsignore$/d' \ - -e '/\/CVS/d' \ - -e '/\.indent\.pro$/d' \ - -e '/\.apaci.*/d' \ - -e '/Makefile$/d' \ - -e '/\/\.#/d' \ - -e '/\.orig$/d' \ - -e 's/^\.\///'`" -OIFS="$IFS" IFS="$DIFS" -for file in $FILES; do - # don't use `-type f' above for find because of symlinks - if [ -d "$src/$file" ]; then - continue - fi - basename=`echo $file | sed -e 's:^.*/::'` - dir=`echo $file | sed -e 's:[^/]*$::' -e 's:/$::' -e 's:$:/:' -e 's:^/$::'` - from="$src/$file" - to="$dst/$dir$basename" - if [ "x$oneisabs" = "x0" ]; then - if [ "x$dir" != "x" ]; then - subdir=`echo $dir | sed -e 's:/$::'` - # (inlined fp2rp) - revdir='' - OIFS2="$IFS"; IFS='/' - for pe in $subdir; do - revdir="../$revdir" - done - IFS="$OIFS2" - # finalize from - from="$revdir$from" - fi - from="$dstrevdir$from" - fi - echo " $to" - ln -s $from $to -done -IFS="$OIFS" - +( cd $src && find . -name CVS -prune \ + -o ! -name '*.o' \ + ! -name '*.so' \ + ! -name '*.so-o' \ + ! -name '*.cvsignore' \ + ! -name '*.indent.pro' \ + ! -name '*.apaci*' \ + ! -name '*Makefile' \ + ! -name '.#*' \ + ! -name '*.orig' \ + ! -name '*.rej' \ + ! -name '*~' \ + ! -type d \ + -print ) | + "${AWK-awk}" \ + ' BEGIN{ } + { if ( ! Back ) { + Relative = ( ! oneisabs ) + nSrc = split( SOURCE, Src, "/" ) + nShd = split( SHADOW, Shd, "/" ) + nSame = 0; + if ( Relative ) for ( I = 1; I <= nSrc; I++ ) { + if ( Src[ I ] != Shd [ I ] ) break + nSame = I } + + Back = "" + if ( Relative ) + for ( I = nSame + 1; I<=nShd; I++ ) Back = "../"Back + else Back = "" + for ( I = nSame + 1; I<=nSrc; I++ ) Back = Back Src[ I ]"/" + print( "# Back: " Back "\n" ) } + + match( $0, "[^/]*$" ) + Base = substr( $0, RSTART ) + Dir = substr( $0, 1, RSTART-2 )"/" + sub( "^\\.//*", "", Dir ) + Levels = split( Dir, Junk, "/" ) + + Dots = Back + if ( Relative ) + for ( I = 1; I < Levels; I++ ) Dots = "../"Dots + XDir = SHADOW"//"Dir + ln[ XDir ] = ln[ XDir ] " "Dots""Dir""Base" \\\n" + rm[ XDir ] = rm[ XDir ] " "Base" \\\n" + ## lv[ XDir ] = " Levels: " Levels " Dots: " Dots " Dir: " Dir + } + END{ + for ( Dir in ln ) { + print( "echo \"\n: ========= Creating links in:\n: "Dir"\"" ) + printf( "mkdir -p %s//. || exit $?\n", Dir ) + printf( "( cd "Dir" && rm -f \\\n%s%s", rm[ Dir ], ")\n" ) + print( "set -v" ) + printf( "ln -s \\\n%s%s", ln[ Dir ], " "Dir"//.\n" ) + print( "set +v\n" ) + } + }' "SOURCE=$SOURCE" "SHADOW=$SHADOW" "oneisabs=$oneisabs" | +## cat; exit $? +"$SHELL"