[Haskell-cafe] "GHC from source" makes a great hardware test

Dave Bayer bayer at cpw.math.columbia.edu
Sun Aug 26 00:33:25 EDT 2007


I recently did the classic "push a shopping cart down the aisle at
Fry's" to build a Core 2 Quad computer, with Linux swap and a soft
raid array spread across three 750 GB sata hard disks. I had some
potential "first build" issues, notably a mishap with the lawn of
copper grass that passes for a 775 cpu socket, followed by an hour of
brain-surgery with a magnifying glass and a tiny screwdriver. I was
very curious to test the stability of this system when it booted up
after all; the best hardware test I could think of was multiple
processes building GHC from source, with each iteration using the
previous GHC binary as the compiler for the new build.

Four iterating GHC builds in parallel is enough to peg all four cores
at 100% indefinitely, with considerable disk activity to the soft raid
array. The most I had going at once was 30 GHC builds; the system
remained responsive enough for me to gracefully change my mind in the
morning.

Building multiple copies of GHC generates a lot of heat; going full
tilt, the computer was drawing 220 watts at the wall. I don't use air
conditioning for my summer office, so I ended up taping a small
bathroom exhaust fan and dimmer switch into the back of a cardboard
box, to collect the hot air from the back of the computer and send it
out the window through a dryer hose. This kept the cores at 40 C (the
enclosure itself has all possible fans) and my office cooler. A
previous passive dryer hose arrangement kept the computer at 50 C,
which is cooler than my MacBook cpu at full tilt, but I like to build
things. Cardboard is an awesome quick prototyping material.

Someone else in the same boat might save some time by modifying my
Bash script. I ran hundreds of GHC builds without a mishap, and
concluded that my system is stable.

 > #!/bin/bash
 >
 > # ghc-test.sh
 >
 > # Bash script to iteratively build ghc from source
 > # http://www.haskell.org/ghc
 >
 > # usage:
 > #   ghc-test iters [ghc]
 >
 > # Bash scripting reference: Advanced Bash-Scripting Guide
 > # http://tldp.org/LDP/abs/html/index.html
 >
 > # Customize these parameters to local installation:
 >
 > sourcedir="/home/me/ghc-6.6.1"
 > src1="${sourcedir}/ghc-6.6.1-src.tar.bz2"
 > src2="${sourcedir}/ghc-6.6.1-src-extralibs.tar.bz2"
 >
 > testdir="/media/raid/ghc-test"
 > log="${testdir}/log.txt"
 > ghcdir="ghc-6.6.1"
 > binarypath="driver/ghc/ghc"
 >
 >
 > # determine build directory
 > time=$(date +'%Y%m%d-%H%M%S')
 > builddir="${testdir}/${time}"
 >
 >
 > # determine number of iterations
 > if [[ -z "$1" ]]
 > then
 >     iters=2
 > else
 >     iters=$1
 > fi
 >
 >
 > # choose ghc binary to use
 > if [[ -n "$2" && -f $2 && -x $2 ]]
 > then
 >     ghc=$2
 > else
 >     ghc=$(which ghc)
 > fi
 >
 >
 > # check ghc binary for pulse
 > fib=`${ghc} -e 'let x = 0 : 1 : zipWith (+) x (tail x) in x !! 99'`
 > if [[ ${fib} != "218922995834555169026" ]]
 > then
 >     echo "** bad ** ${ghc} ${iters} ${time}" >> ${log}
 >     ghc=$(which ghc)
 > else
 >     echo "ok        ${ghc} ${iters} ${time}" >> ${log}
 > fi
 >
 >
 > # do an iteration if $iters > 0
 > let iters=iters-1
 > if [[ ${iters} -gt 0 ]]
 > then
 >
 >     # build new copy of ghc from source
 >     mkdir -p ${builddir}
 >     cd ${builddir}
 >     tar -jxf ${src1}
 >     tar -jxf ${src2}
 >     cd ${ghcdir}
 >     ./configure --with-ghc=${ghc}
 >     make
 >
 >     # delete previous build directory, now that we're done with $ghc
 >     if [[ -n "$3" && -d "$3" ]]
 >     then
 >         rm -rf $3
 >     fi
 >
 >     # iterate
 >     newghc="${builddir}/${ghcdir}/${binarypath}"
 >     ${sourcedir}/ghc-test.sh ${iters} ${newghc} ${builddir}
 >
 > else
 >
 >     # delete previous build directory
 >     if [[ -n "$3" && -d "$3" ]]
 >     then
 >         rm -rf $3
 >     fi
 >
 > fi



More information about the Haskell-Cafe mailing list