aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2008-07-19 17:59:41 +0000
committerKris Kennaway <kris@FreeBSD.org>2008-07-19 17:59:41 +0000
commit54e565eedc284b13fe7c03fe05bd8a0ab3ff4fbf (patch)
tree2ed7567a9ca335eb974587ebb66efb39c72d218f /Makefile
parenta8c31a5d50a9322cdb62c0e24337d7e5cd2585ca (diff)
downloadports-54e565eedc284b13fe7c03fe05bd8a0ab3ff4fbf.tar.gz
ports-54e565eedc284b13fe7c03fe05bd8a0ab3ff4fbf.zip
Major optimizations for 'make index' and other recursive traversal
targets. * Use /rescue/sh for index builds instead of /bin/sh, when it exists. The former is statically linked and faster to execute, which becomes significant when executing it tens of thousands of times. This trick can be used with other recursive targets by passing in __MAKE_SHELL. * Get rid of make variable assignments that use != command invocations in the critical path, using several methods: - rewriting logic to use shell or make builtins instead of external command executions - macroizing commands and executing them in the targets where they are needed instead of with every invocation of make - precomputing the results of invariant commands in bsd.port.subdir.mk and passing them in explicitly to child makes, and using this to avoid recalculation in all the children. NB: the commands are still run one per top-level subdirectory but this does not currently seem to be a major issue. They could be moved further up into the top-level Makefile at the cost of some cleanliness. - Committers are strongly discouraged from adding further "bare" != assignments to the ports tree, even in their own ports. One of the above strategies should be used to avoid future bloat. * Rewrite the core 'describe' target to work entirely within a single shell process using only builtin commands. The old version is retained as a backup for use on systems older than 603104, which does not have the make :u modifier. This cuts down the number of processes executed during the course of a 'make index' by an order of magnitude, and we are essentially now amortized to the minimum of a single make + sh instance per port, plus whatever commands the port makefile itself executes (which are usually unnecessary and bogus). * Less validation of the WWW: target is performed; this can become policed at a port level by portlint. Specifically we look at the second word of the first line beginning with "WWW:" in pkg-descr, and append "http://" to it unless it already begins with "http://", "https://" or "ftp://". Thanks to dougb for the idea of how to extract WWW: using shell builtins. * Use the "true" shell builtin instead of echo > /dev/null for a measurable decrease in CPU use. * Add a note about dubious escaping strategy in bsd.port.subdir.mk * Minor change in output of 'make describe': it no longer strips trailing CR characters from pkg-descr files with MSDOS CR/LF termination. Instead the makeindex perl script that post-processes make describe into the INDEX is tweaked to strip on input. The bottom line is that on my test hardware INDEX builds are now faster by more than a factor of 2 and with a reduction in system time by a factor of 4-8 depending on configuration.
Notes
Notes: svn path=/head/; revision=217132
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 11 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index ec4a7cf26fbf..fe96c3dbdea0 100644
--- a/Makefile
+++ b/Makefile
@@ -86,13 +86,22 @@ FETCHINDEX?= ${SETENV} ${FETCH_ENV} fetch -am -o
INDEX_JOBS?= 2
.if !defined(INDEX_VERBOSE)
-INDEX_ECHO_MSG= echo > /dev/null
+INDEX_ECHO_MSG= true
INDEX_ECHO_1ST= echo -n
.else
INDEX_ECHO_MSG= echo 1>&2
INDEX_ECHO_1ST= echo
.endif
+# /rescue/sh is statically linked and much faster to execute than the
+# dynamically linked /bin/sh. This is significant for targets like
+# make index that execute the shell tens of thousands of times.
+.if exists(/rescue/sh)
+INDEX_SHELL= /rescue/sh
+.else
+INDEX_SHELL= /bin/sh
+.endif
+
${INDEXDIR}/${INDEXFILE}:
@${INDEX_ECHO_1ST} "Generating ${INDEXFILE} - please wait.."; \
if [ "${INDEX_PRISTINE}" != "" ]; then \
@@ -103,6 +112,7 @@ ${INDEXDIR}/${INDEXFILE}:
tmpdir=`/usr/bin/mktemp -d -t index` || exit 1; \
trap "rm -rf $${tmpdir}; exit 1" 1 2 3 5 10 13 15; \
( cd ${.CURDIR} && make -j${INDEX_JOBS} INDEX_TMPDIR=$${tmpdir} BUILDING_INDEX=1 \
+ __MAKE_SHELL=${INDEX_SHELL} \
ECHO_MSG="${INDEX_ECHO_MSG}" describe ) || \
(rm -rf $${tmpdir} ; \
if [ "${INDEX_QUIET}" = "" ]; then \