Are there tools that will profile the Maven build process itself so that I can see where the build is spending most time?
We're having issues at work with respect to Maven 3.0.3 and 3.0b1. Our project builds much faster under 3.0b1 (3m30s) compared to 3.0.3 (9m00s). With 3.0b1 the build is approximately 63% faster (if my math is right).
I tried searching for performance comparisons and performance issues regarding Maven 3, but was unable to find anything.
UPDATE
I did some more research by looking at the maven sources and this is what I found out:
While using jconsole, I saw that most of the time (in 3.0.3) is spent inside DefaultProjectDependenciesResolver.java
. So I downloaded the source to both 3.0b1 and 3.0.3 to see what's happening. I noticed that in 3.0.3 there are two versions of the class. One is in org.apache.maven.project
, while the other is in org.apache.maven
. It also appears that in 3.0.3, the former is being used. While stepping through the code, I saw that bulk of the time is spent when it reaches this statement:
node = repoSystem.collectDependencies( session, collect ).getRoot();
In 3.0b1, the code does:
ArtifactResolutionResult result = repositorySystem.resolve( request );
I also noticed that respositorySystem
is of the type RepositorySystem
, and the concrete implementation is LegacyRepositorySystem
. I'm assuming that this was being used while the Maven 3 was in beta until the new implementation was created? Going back to 3.0.3, the collectDependencies
method lives in DefaultRepositorySystem.java
which is part of org.sonatype.aether.impl.internal
. This eventually calls collectDependencies
inside DefaultDependencyCollector.java
which is also part of org.sonatype.aether.impl.internal
. I'm assuming that this is how the dependency graph is built.
I'm now wondering it is because of how our dependencies are structured. Has anyone seen this kind of behavior before?
UPDATE
There is an issue in JIRA about this issue along with a suggested fix. I've posted the details as an answer.
UPDATE
The problem is due to the version of aether that's used in maven 3.0.3 (1.11). Version 1.12 of aether fixes this problem. I checked out the source to maven 3.0.3 and edited the POM to change the version of aether from 1.11 to 1.12. I then built maven from source and replaced my current version with the version I built. The reduction in build-times is dramatic.
If you don't want to build maven from source, you can replace the aether libraries that are in maven's lib directory with 1.12 version. That should work as well.
I'm not sure if this change is going to make it into 3.0.4, because the maven developers said that there are licensing changes going from aether 1.11 to aether 1.12, and so they're still discussing it.
Overview. Maven profiles can be used to create customized build configurations, like targeting a level of test granularity or a specific deployment environment. In this tutorial, we'll learn how to work with Maven profiles.
Rather than right-clicking on a project, going to the Properties > Maven page, then manually (mis)typing a list of active or disabled profile, you just use the Ctrl+Alt+P shortcut to open the new Maven Profile selection interface.
Maven is just a plain Java application, so I suggest that you start it with a profiling tool such as YourKit or JProfiler and analyse its runtime performance. You can also use JVisualVM to extract runtime performance information.
All in all, I believe the Maven developers would be interested to find out about this performance regression. Please open a ticket in the Maven Jira or post on the Maven developers list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With