Reworked Makefiles to allow for parallel builds via make -j
#76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before, builds couldn't be done with more than one Make job because of race conditions on the library files (i.e. multiple jobs trying to write to the same .a file at the same time). In order to prevent this, the compilation and the archiving phases of the build process were broken into two separate phases. The first, compilation, can be done as concurrently as desired because there are no dependencies. The second phase, archiving, must be done sequentially though because the files related to each library are nicely separated into subdirectories of src/, the Makefiles for those subdirectories (both phases) can be run concurrently to each other.
I did some very crude benchmarking of these changes. I used the Linux time(1) utility and averaged the values for three runs.
Current Build Process (
make
):real 5m20.482s
user 0m6.782s
sys 0m9.327s
New Build Process (
make -j 4
):real 2m28.016s
user 0m7.1297s
sys 0m11.431s
So in my environment, I am getting more than a 50% speedup from these changes. You'll notice that both the user and sys time went up after the changes though. I would venture to say that this is because of the additional overhead related to my method of splitting up the two build phases. Regardless, the real time improvement is significant.
Additionally, I compared the libraries generated using the old build process and the new build process using the procedure described in this Gist. In addition to the shell commands, a tar.gz file containing the outputs is attached. As you can see, the generated libraries are identical (disregarding ordering of object files within the libraries).