help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about parallel optimzation


From: Paul Smith
Subject: Re: question about parallel optimzation
Date: Wed, 13 Apr 2011 08:45:56 -0400

On Wed, 2011-04-13 at 13:24 +0200, Toralf Förster wrote:
> related to the parallel build capabilities I'm wondering how make does 
> optimize the build process.

It doesn't.

> Considering 2 make processes in parallel and 3 independend directories, 2 
> should have 100 and 1 should have 200 source files. In this case make should 
> start with the bigger directory with one build process and with one of the 
> other 2 (smaller) directories with another process, right ?

I don't think you're understanding the model.  Make doesn't spawn
"worker processes" like that.  If you have a recipe that runs a
sub-make, then make spawns a new make.  If your recipe doesn't run a new
make, then your entire build will be managed by a single make process.

Also why would it matter which directory make built first if they are
independent?

> Or doesn't make looks forward in this way and simple works with the 3
> directory in another (alphabetical) sorted order ?

Make always walks the dependency tree in the same basic order (although
parallelism can cause things to be started at different times).  Make
never knows the future: it has no way of knowing even how many more
steps there are in the current make invocation before it's done, much
less how many there may be in some other make process.

It's not that make first scans the entire dependency tree and computes
all the steps needed first then runs them; that would be impossible
because the completion of one step can impact multiple other steps in
non-deterministic ways.  Instead, after make reads in all the makefiles
and finishes creating the full dependency tree, it simply starts walking
the tree, building things as needed.  It stops when there's nothing left
to build (when the starting goal is up to date).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]