From owner-freebsd-hackers Sat Dec 31 05:46:04 1994 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id FAA14249 for hackers-outgoing; Sat, 31 Dec 1994 05:46:04 -0800 Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id FAA14243 for ; Sat, 31 Dec 1994 05:46:01 -0800 Received: from beryll.cs.tu-berlin.de (wosch@beryll.cs.tu-berlin.de [130.149.28.11]) by mail.cs.tu-berlin.de (8.6.9/8.6.9) with ESMTP id OAA03815 for ; Sat, 31 Dec 1994 14:45:52 +0100 From: Wolfram Schneider Received: (wosch@localhost) by beryll.cs.tu-berlin.de (8.6.9/8.6.6) id OAA07627; Sat, 31 Dec 1994 14:45:50 +0100 Date: Sat, 31 Dec 1994 14:45:50 +0100 Message-Id: <199412311345.OAA07627@beryll.cs.tu-berlin.de> To: hackers@freebsd.org Subject: optimized mkdep MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: hackers-owner@freebsd.org Precedence: bulk ``make depend'' use to much processes. The following patches save 12 processes for every ``make depend''. ``Make world'' call ``make depend'' ~500x => 6000 processes!!! Tested in /usr/src/usr.sbin/sa Current, without optimization: 20 processes $ make depend rm -f .depend files=""; if [ "$files" != "" ]; then mkdep -a $files; fi files="main.c pdb.c usrdb.c"; if [ "$files" != "" ]; then mkdep -a $files; fi files=" "; if [ "$files" != " " ]; then mkdep -a $files; fi make - w ttyp5 0.53 secs Sat Dec 23 19:57 sh - w ttyp5 0.03 secs Sat Dec 23 19:57 [ - w ttyp5 0.03 secs Sat Dec 23 19:57 sh - w ttyp5 0.05 secs Sat Dec 23 19:57 sh - w ttyp5 0.12 secs Sat Dec 23 19:57 rm - w ttyp5 0.02 secs Sat Dec 23 19:57 cat - w ttyp5 0.03 secs Sat Dec 23 19:57 [ - w ttyp5 0.02 secs Sat Dec 23 19:57 [ - w ttyp5 0.02 secs Sat Dec 23 19:57 sed - w ttyp5 0.17 secs Sat Dec 23 19:57 cc - w ttyp5 0.17 secs Sat Dec 23 19:57 cpp - w ttyp5 0.66 secs Sat Dec 23 19:57 cpp - w ttyp5 0.75 secs Sat Dec 23 19:57 cpp - w ttyp5 0.92 secs Sat Dec 23 19:57 [ - w ttyp5 0.02 secs Sat Dec 23 19:57 [ - w ttyp5 0.05 secs Sat Dec 23 19:57 [ - w ttyp5 0.03 secs Sat Dec 23 19:57 sh - w ttyp5 0.05 secs Sat Dec 23 19:57 [ - w ttyp5 0.02 secs Sat Dec 23 19:57 rm - w ttyp5 0.06 secs Sat Dec 23 19:57 bsd.dep.mk.opt + mkdep: 15 processes $ make depend rm -f .depend; files=""; case "$files" in "");; *) mkdep -a $files;; esac; files="main.c pdb.c usrdb.c"; case "$files" in "");; *) mkdep -a $files; esac; files=" "; case "$files" in " ");; *) mkdep -a $files; esac make - w ttyp5 0.52 secs Sat Dec 23 20:00 sh - w ttyp5 0.08 secs Sat Dec 23 20:00 sh - w ttyp5 0.12 secs Sat Dec 23 20:00 rm - w ttyp5 0.03 secs Sat Dec 23 20:00 cat - w ttyp5 0.02 secs Sat Dec 23 20:00 [ - w ttyp5 0.02 secs Sat Dec 23 20:00 [ - w ttyp5 0.03 secs Sat Dec 23 20:00 sed - w ttyp5 0.16 secs Sat Dec 23 20:00 cc - w ttyp5 0.17 secs Sat Dec 23 20:00 cpp - w ttyp5 0.69 secs Sat Dec 23 20:00 cpp - w ttyp5 0.75 secs Sat Dec 23 20:00 cpp - w ttyp5 0.89 secs Sat Dec 23 20:00 [ - w ttyp5 0.02 secs Sat Dec 23 20:00 [ - w ttyp5 0.06 secs Sat Dec 23 20:00 rm - w ttyp5 0.02 secs Sat Dec 23 20:00 bsd.dep.mk.opt + mkdep.perl: 8 processes $ make depend rm -f .depend; files=""; case "$files" in "");; *) mkdep.perl -a $files;; esac; files="main.c pdb.c usrdb.c"; case "$files" in "");; *) mkdep.perl -a $files; esac; files=" "; case "$files" in " ");; *) mkdep.perl -a $files; esac make - w ttyp5 0.53 secs Sat Dec 23 20:02 sh - w ttyp5 0.03 secs Sat Dec 23 20:02 perl - w ttyp5 0.19 secs Sat Dec 23 20:02 cc - w ttyp5 0.17 secs Sat Dec 23 20:02 cpp - w ttyp5 0.66 secs Sat Dec 23 20:02 cpp - w ttyp5 0.75 secs Sat Dec 23 20:02 cpp - w ttyp5 0.92 secs Sat Dec 23 20:02 rm - w ttyp5 0.03 secs Sat Dec 23 20:02 Gruß Wolfram #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 12/31/1994 13:41 UTC by wosch@beryll # Source directory /tmp_amd/fiesta/export/all3/w/wosch/tmp/send # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 3217 -rwxr-xr-x mkdep.perl # 1061 -rwxr-xr-x bsd.dep.mk.opt # # ============= mkdep.perl ============== if test -f 'mkdep.perl' -a X"$1" != X"-c"; then echo 'x - skipping mkdep.perl (File already exists)' else echo 'x - extracting mkdep.perl (Text)' sed 's/^X//' << 'SHAR_EOF' > 'mkdep.perl' && #!/usr/bin/perl # # Copyright (c) 1994 Wolfram Schneider. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Wolfram Schneider # 4. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # mkdep - construct Makefile dependency list # Email: Wolfram Schneider X $depend=".depend"; # default dependency file is .depend $append=0; # $pflag=0; # X sub usage { X warn <) { X s|\.o:|:|; X s| \./| |g; X push(@array, $_); X } } else { X while() { X s| \./| |g; X push(@array, $_); X } } close CPP; X if(($? >> 8) != 0) { X warn "mkdep: compile failed.\n"; X exit 1; } X if ($append) { X open(D, ">> $depend"); } else { X open(D, "> $depend"); } X print D @array; close D; X Xexit 0; SHAR_EOF chmod 0755 mkdep.perl || echo 'restore of mkdep.perl failed' Wc_c="`wc -c < 'mkdep.perl'`" test 3217 -eq "$Wc_c" || echo 'mkdep.perl: original size 3217, current size' "$Wc_c" fi # ============= bsd.dep.mk.opt ============== if test -f 'bsd.dep.mk.opt' -a X"$1" != X"-c"; then echo 'x - skipping bsd.dep.mk.opt (File already exists)' else echo 'x - extracting bsd.dep.mk.opt (Text)' sed 's/^X//' << 'SHAR_EOF' > 'bsd.dep.mk.opt' && # $Id: bsd.dep.mk,v 1.1 1994/08/04 21:10:07 wollman Exp $ X # some of the rules involve .h sources, so remove them from mkdep line MD=mkdep.perl .if !target(depend) depend: beforedepend .depend afterdepend .if defined(SRCS) .depend: ${SRCS} X rm -f .depend; \ X files="${.ALLSRC:M*.[sS]}"; \ X case "$$files" in "");; *) \ X ${MD} -a ${MKDEP} ${CFLAGS:M-[ID]*} ${AINC} $$files;; esac; \ X files="${.ALLSRC:M*.c}"; \ X case "$$files" in "");; *) \ X ${MD} -a ${MKDEP} ${CFLAGS:M-[ID]*} $$files; esac; \ X files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \ X case "$$files" in " ");; *) \ X ${MD} -a ${MKDEP} ${CXXFLAGS:M-nostd*} ${CXXFLAGS:M-[ID]*} $$files;\ X esac .else .depend: .endif .if !target(beforedepend) beforedepend: .endif .if !target(afterdepend) afterdepend: .endif .endif X .if !target(tags) .if defined(SRCS) tags: ${SRCS} X -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ X sed "s;\${.CURDIR}/;;" > tags .else tags: .endif .endif X .if defined(SRCS) clean: cleandir: cleandepend cleandepend: X rm -f .depend ${.CURDIR}/tags .endif SHAR_EOF chmod 0755 bsd.dep.mk.opt || echo 'restore of bsd.dep.mk.opt failed' Wc_c="`wc -c < 'bsd.dep.mk.opt'`" test 1061 -eq "$Wc_c" || echo 'bsd.dep.mk.opt: original size 1061, current size' "$Wc_c" fi exit 0