Subject: Re: pkgsrc on SMP machines
To: None <joerg@britannica.bec.de>
From: None <segv@netctl.net>
List: tech-pkg
Date: 12/15/2005 23:44:22
On Fri, 16 Dec 2005 00:08:38 +0100
joerg@britannica.bec.de wrote:

> On Thu, Dec 15, 2005 at 11:43:15PM +0100, Geert Hendrickx wrote:
> > 
> > I asked #gentoo about it.  They told me most packages are thread-safe.  
> 
> From personal experience with subtile breakage of makefiles, I strongly
> disagree. Most packages are not j-save. The real problem is that
> failures are not often enough not even visible -- showing up in
> mysterious problems. They are also normally not reproducable. Both are
> parameters I'd like to avoid having to deal with.
> 
> Joerg

Yes this is a big problem. What do people think of the following workaround:

When building packages, pkgsrc uses a wrapper shell script
under /work/.wrapper/bin/cc So say we set max number of parallel jobs to 8.
Then we initialise CC_JOBS variable to 8. Every time 'cc' script is called, it
calls real compiler in the background, decrements CC_JOBS variable and returns
immediately. When CC_JOBS reaches 0, 'cc' script waits for previous background
jobs to finish and stalls until they're done.

If the Makefile has a race condition, where next jobs, depend on the completion
of the previous jobs, 'cc' script will detect an error, because calling a real
compiler will result in an error (presumably because some object files are
missing, etc). When this happens, 'cc' script stalls the whole pipeline and
executes that batch of jobs in series. After that it can continue as normal.

There are some details to work out, but this seems like a reasonable solution