Section A.2. Scaling of Build Tools


A.2. Scaling of Build Tools

A.2.1. Comparing Recursive and Included make

There are two different ways that projects using make generally set up their makefiles. The first way, known as recursive make, is probably still the more common of the two ways. With recursive make, a top-level makefile contains a list of subdirectories, each of which has its own makefile. During a build, make recursively descends into each subdirectory and executes the instructions in the makefile there.

The other model, called included or nonrecursive make, was popularized by Peter Miller's classic paper "Recursive Make Considered Harmful," which suggests that the overhead of the time spent starting make with all the different makefiles becomes substantial as the project grows. A different idea is to create one large makefile before you start the build that includes all the makefiles that exist in each subdirectory. Debate over the two approaches still continues, and their results for a simple project are compared in Table A-1. The build state names are the ones that were defined in Chapter 5.

Table A-1. Recursive make and included make

Build state

Recursive duration (seconds)

Included duration (seconds)

Virgin

10.2

10.1

Changed

1.1

0.4

Up-to-date

1.1

0.3

Clean

2.5

1.5


These results were obtained on matt-laptop, the same machine that was used for the results in Section A.1.1, earlier in this appendix. In each case a virgin version of the same generated project with 10 subdirectories, each of which had 10 leaf subdirectories (i.e., subdirectories that have no subdirectories), was used. In each leaf subdirectory, there was one C source file with just one function defined in it. The recursive makefiles each had calls to each subdirectory's makefile with $(MAKE) -C dirname. The included top-level makefile had 100 include statements, one per leaf subdirectory. Each of the leaf source files was compiled into a static library, producing 100 such libraries in total. At the top level, a C source file used each of the 100 functions, and thus was linked with all 100 libraries. The changed build involved changing the modification time of the leaf file that was built last in a virgin build.

Table A-1 shows that virgin builds take about the same time with either scheme, since compile time is the dominant factor, but all other kinds of builds take approximately half the time if you use the included makefile approach.

There are other, similar results by Boris Kolpackov, available from http://kolpackov.net/projects/build/benchmark.xhtml.




Practical Development Environments
Practical Development Environments
ISBN: 0596007965
EAN: 2147483647
Year: 2004
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net