Maven builds 3x slower on OSX
I recently got a new Macbook Pro at work and noticed that building our codebase in Maven2 takes about 15 minutes, while others on my team with slightly older Macbooks (but similar / same specs) build in about 5 minutes. After asking around, I found another person on my team whose builds take 15 minutes. I'm talking about a new code check and we are all in the same Maven version (2.2.1) and Java version: 1.6.0_29, run "mvn clean install" from the project root. We are both with slow builds on Lion (10.7.3), and people with 5 minute builds are on Lion or Snow Leopard. My machine has 8GB of 2.3GHz i7 ram so it doesn't seem like it should be an issue. AFAIK, the car came with Lion (versus updated from Snow Leopard) so I don't thinkthat it was updated in-place with Snow Leopard, which seems to have been a problem for some people. We have 5400 RPM drives with slow builds while most others have 7200 RPM drives, but alas, one of the other guys with 5 minute builds has the same 5400 RPM drive that we do ... so some rules from this theory.
I ran a memory test (tested perfectly), ran a disk check and allowed repairs in Disk Utility (fixed some resolution issues but didn't change build times), disabled sharing, made sure filevault was disabled, from a different directory, all to no avail. A few interesting points that lead me to suspect an OS problem:
- I have an Ubuntu VM on the specified machine and doing "mvn clean install" is even significantly faster than natively on OSX (10 minutes versus 15 minutes)! FYI, the local Ubuntu guys on our team also take about 5 minutes to build. And when I ran Ubuntu in a virtual machine on my Windows box a few months ago, it averaged 15-20 minutes.
- Building the slowest component of our project itself takes about 3-4 minutes. The interesting thing about this component is that there is very little code in it. In fact, this is all one test case and 135MB of resource files. From 3-4 minutes I calculated about 100 seconds sitting on "Copy 63 resources".
- Running in OSX safe mode, building the aforementioned slowest component took only 42 seconds, of which about 7 seconds was spent copying 63 resources.
I'm not sure what else to try at this point, but I feel like I'm so close to nailing it down. If it wasn't for such a noticeable difference, I wouldn't bother so much about it, but in 15 minutes versus 5 minutes in my workflow. I don't feel completely comfortable giving my work computer to the Apple Genius guys and our IT guy is not a Mac person. Reinstalling the OS is the answer I've seen on the internet, but it seems a little over the top and intrusive. (I realize this is more an OSX question than a Maven question, perhaps, but Maven was my reference. I don't notice any other slowness, but it's hard to tell without using other computers)
Has anyone come across something like this? Any ideas on what to try? Thanks to
source to share
Run the command mvn -X ...
on your computer and quickly and compare the time with the log files which tasks / plugins are taking the most time. This should give you a starting point. The two slowest parts are file system scanning and network access to check for artifacts / dependencies / plugin updates.
The former can be improved by adjusting disk access (like caching or switching to an SSD).
The latter can be improved by adding a Maven repository manager such as Nexus or Artifactory that will cache and optimize access to all remote Maven repositories.
source to share