Subject: Re: Extreme lethargy when dependencies are missing (part 2)
To: Charles M. Hannum <abuse@spamalicious.com>
From: Urban Boquist <urban@boquist.net>
List: tech-pkg
Date: 10/07/2001 23:36:34
Charles> While I appreciate Todd's intent here, there *has* to be a
Charles> way to do this without making pkgsrc ungodly slow.

I think the basic problem that has to be attacked is that each
dependency is visited over and over again. This quickly leads to
combinatorial explosion, and not just in theory, as x11/gnome clearly
shows.

For me, on a relatively fast Athlon a "make fetch-list" in x11/gnome
takes nearly 2 and a half hours. With the quick hack patch below the
time goes down to 13 seconds.

I also did some statistics. Libtool-base seemed to be the most popular
dependency for gnome, it was visited 28575 times! Kind of cool... ;-)

But the patch below is not a nice and general solution, and it also
uses a temporary file, which I don't think is "allowed" in pkgsrc (or
is it)?

I would like to see some more general solution, something along the
lines of a "visit all dependencies and do XYZ"-target.

Regards,

        -- Urban

Quick hack below, visit each dependency once (or at most twice)
instead of MANY times.

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.823
diff -u -r1.823 bsd.pkg.mk
--- bsd.pkg.mk	2001/10/05 21:33:00	1.823
+++ bsd.pkg.mk	2001/10/07 21:11:55
@@ -2406,7 +2406,8 @@
 
 .if !target(fetch-list)
 fetch-list:
-	@${MAKE} ${MAKEFLAGS} fetch-list-recursive RECURSIVE_FETCH_LIST=${RECURSIVE_FETCH_LIST} | ${SORT} -u
+	@TMPFILE=`mktemp /tmp/pkg.XXXXXX` &&				\
+	${MAKE} ${MAKEFLAGS} fetch-list-recursive RECURSIVE_FETCH_LIST=${RECURSIVE_FETCH_LIST} TMPFILE=$$TMPFILE | ${SORT} -u ; ${RM} -f $$TMPFILE
 .endif # !target(fetch-list)
 
 .if !target(fetch-list-recursive)
@@ -2417,8 +2418,11 @@
 	for dir in `${ECHO} ${BUILD_DEPENDS:C/^[^:]*://:C/:.*//}	\
 				  ${DEPENDS:C/^[^:]*://:C/:.*//} |	\
 		    ${TR} '\040' '\012' | ${SORT} -u` ; do		\
-		cd ${.CURDIR}/$$dir &&					\
-		${MAKE} ${MAKEFLAGS} fetch-list-recursive;		\
+		if ! grep -q $$dir ${TMPFILE}; then			\
+			echo $$dir >> ${TMPFILE} &&			\
+			cd ${.CURDIR}/$$dir &&				\
+			${MAKE} ${MAKEFLAGS} TMPFILE=${TMPFILE} fetch-list-recursive; \
+		fi;							\
 	done
 .  endif # ${RECURSIVE_FETCH_LIST} != "NO"
 .endif # !target(fetch-list-recursive)