I have a Maven profile for a Java project that is activated when doing a final build on a Hudson CI server.
Currently this profile's only customization is to the Maven compiler plugin as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>false</debug>
<optimize>true</optimize>
</configuration>
</plugin>
Are there any other tweaks or optimizations to the Java compiler that a final build should be doing to maximize performance?
The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.
The JVMs JIT compiler is one of the fascinating mechanisms on the Java platform. It optimizes your code for performance, without giving away its readability. Not only that, beyond the “static” optimization methods of inlining, it also makes decisions based on the way that the code performs in practice.
<annotationProcessorPaths>The detection itself depends on the configuration of annotationProcessors. Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, type). Transitive dependencies are added automatically.
Assuming that you're running on the Sun (Hotspot) JVM, all optimization happens in the JVM.
So specifying <optimize>true</optimize>
does nothing.
And specifying <debug>false</debug>
simply removes debugging symbols. Which will slightly decrease your JARfile size, but make it much harder to track down production problems, because you won't have line numbers in your stack traces.
One thing that I would specify is JVM compatibility settings:
<source>1.6</source>
<target>1.6</target>
You shouldn't even do that - optimization in javac
has been disabled for quite a while, IIRC. Basically the JIT is responsible for almost all the optimization, and the javac optimizations actually hurt that in some cases.
If you're looking to tune performance you should look elsewhere:
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