Parallel builds in tinderd

Tim Bishop tim-lists at bishnet.net
Sun Dec 17 18:17:20 EST 2006


My tinderbox machine is a dual core box, so I figured there'd be
some benefit to being able to do multiple compiles in parallel using
tinderd. I looked at the -jobs flag to tinderbuild, but it doesn't
seem to do anything useful (in fact, it breaks the build).

So what I've done is hack tinderd so multiple instances can be run
at once. Obviously only one tinderbuild can be run per build, so
I've done some very crude locking to make sure the tinderds don't
collide. There's plenty of scope for race conditions here :-)

The biggest benefit comes when testing a single port across multiple
build environments. It doesn't help in the slightest when doing
lots of ports in one build.

I've also tweaked the tinder.sh startup script to be able to start
a given number of tinderd instances.

Unless the race conditions become a reality I probably won't fix
them, but I'm more than happy if a more experienced shell hacker
wants to take on that little challenge ;-)

Patch attached.

Tim.

-- 
Tim Bishop
http://www.bishnet.net/tim/
PGP Key: 0x5AE7D984
-------------- next part --------------
diff -ruN /usr/local/tinderbox/scripts/etc/rc.d/tinderd.sh scripts/etc/rc.d/tinderd.sh
--- /usr/local/tinderbox/scripts/etc/rc.d/tinderd.sh	Thu Nov 30 13:01:18 2006
+++ scripts/etc/rc.d/tinderd.sh	Sun Dec 17 23:00:29 2006
@@ -24,6 +24,7 @@
 : ${tinderd_enable="NO"}
 : ${tinderd_directory="/space/scripts"}
 : ${tinderd_flags=""}
+: ${tinderd_instances="1"}
 
 # path to your executable, might be libxec, bin, sbin, ...
 command="${tinderd_directory}/tinderd"
@@ -33,5 +34,14 @@
 
 # extra required arguments
 command_args=">/dev/null &"
+
+start_cmd="${name}_start"
+
+tinderd_start()
+{
+	for i in `jot - 1 ${tinderd_instances}`; do
+		${command} ${tinderd_flags} >/dev/null 2>&1 &
+	done
+}
 
 run_rc_command "$1"
diff -ruN /usr/local/tinderbox/scripts/tinderd scripts/tinderd
--- /usr/local/tinderbox/scripts/tinderd	Thu Nov 30 13:01:18 2006
+++ scripts/tinderd	Sun Dec 17 22:08:04 2006
@@ -15,7 +15,23 @@
 main_loop() {
 	while true ; do
     		trap "" 1
-		ENTRY=$(${pb}/scripts/tc listBuildPortsQueue -s ENQUEUED -r | head -1)
+		ENTRY=""
+
+		if [ ! -f /tmp/tinderdlock ]; then
+			touch /tmp/tinderdlock
+			${pb}/scripts/tc listBuildPortsQueue -s ENQUEUED -r > /tmp/tinderd.$$
+			while read line; do
+				BUILD=$(echo ${line} | cut -d: -f3)
+				if [ ! -f $pb/builds/$BUILD/tinderdlock ]; then
+					touch $pb/builds/$BUILD/tinderdlock
+					ENTRY=$line
+					break
+				fi
+			done < /tmp/tinderd.$$
+			rm /tmp/tinderd.$$
+			rm /tmp/tinderdlock
+		fi
+
 		ID=$(echo ${ENTRY} | cut -d: -f1)
 		USER=$(echo ${ENTRY} | cut -d: -f2)
 		BUILD=$(echo ${ENTRY} | cut -d: -f3)
@@ -37,6 +53,8 @@
 			fi
 
 			${pb}/scripts/tc reorgBuildPortsQueue
+
+			rm $pb/builds/$BUILD/tinderdlock
 		else
 			tinder_echo "INFO: Nothing to do. Sleeping ${TINDERD_SLEEPTIME} seconds."
 			trap main_loop 1


More information about the tinderbox-list mailing list