Monday, 13 September 2010
On Maven 3 Parallel builds and why smaller modules are good for you
Default maven:
mvn clean install ... [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7:05.842s [INFO] Finished at: Mon Sep 13 19:23:29 CEST 2010 [INFO] Final Memory: 193M/1216M [INFO] ------------------------------------------------------------------------Using the parallel builds feature:
mvn clean install -T 4 ... [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5:04.982s (Wall Clock) [INFO] Finished at: Mon Sep 13 19:29:02 CEST 2010 [INFO] Final Memory: 135M/1326M [INFO] ------------------------------------------------------------------------
This is on my quad core I7 system. The amount of parallelism you can achieve depends on the structure of your project. If you have a project where C depends on B depends on A, you will not get a speedup since nothing can be build in parallel. If on the other hand, C and B just depend on A,you can now build B and C in parallel.
There's also an option (Weave Mode) to run different phases of different modules in parallel (for example compiling B while still running tests of A), but that doesn't yet work reliably on this project. I guess it could allow for an even greater speedup, since even dependency trees like C depends on B depends on A could then be parallelized.
The largest and slowest module of this project takes about 2 minutes to build (it has more than 800 scenario tests). Now, since that module actually implements 2 different taxes, it can be further split up into three parts (one common and 2 for the specific taxes). Doing that, I can now build those three parts in parallel, taking only 1.40 minutes instead of two. That's why multiple smaller modules are better than one larger as far as build speed is concerned (and you want multiple modules to enforce your modularity anyway).
This kind of feature, and the ease with witch you can use it out of the box, is what I absolutely love about Maven. Ok, the strict Maven model limits you in some ways at times, and the pom.xmls can become very verbose, but you gain so much back.
P.S.
Does anyone know whether any other build systems (Gradle, SBT, ...) have anything like this? (I can't imagine trying to do anything like this by myself in an Ant build.)
Posted by at 9:28 PM in Java





