COMPILER FLAGS ARE DIFFERENT
Unlike most Java flags, the flags to select a compiler are different: most of them do not use -XX .
The standard compiler flags are simple words: -client , -server , or -d64 .
The exception here is tiered compilation, which is enabled with a flag in the common format: -
XX:+TieredCompilation . Tiered compilation implies that the server compiler must be used. The
following command silently turns off tiered compilation, because it conflicts with the choice of
the client compiler:
% java -client -XX:+TieredCompilation other_args
The primary difference between the two compilers is their aggressiveness in compiling code.
The client compiler begins compiling sooner than the server compiler does. This means that
during the beginning of code execution, the client compiler will be faster, because it will
have compiled correspondingly more code than the server compiler.
The engineering trade-off here is the knowledge the server compiler gains while it waits: that
knowledge allows the server compiler to make better optimizations in the compiled code. Ul-
timately, code produced by the server compiler will be faster than that produced by the client
compiler. From a user's perspective, the benefit to that trade-off is based on how long the
program will run, and how important the startup time of the program is.
The obvious question here is why there needs to be a choice at all: couldn't the JVM start
with the client compiler, and then use the server compiler as code gets hotter? That technique
is known as tiered compilation . With tiered compilation, code is first compiled by the client
compiler; as it becomes hot, it is recompiled by the server compiler.
Experimental versions of tiered compilation are available in early releases of Java 7. It turns
out that there are a number of technical difficulties here (notably in the different architectures
of the two compilers), and as a result, tiered compilation didn't perform well in those experi-
mental versions. Starting in Java 7u4, those difficulties have largely been solved, and tiered
compilation usually offers the best performance for an application.
In Java 7, tiered compilation has a few quirks, and so it is not the default setting. In particu-
lar, it is easy to exceed the JVM code cache size, which can prevent code from getting optim-
ally compiled (though it is easy enough to address that, as is discussed in Intermediate Tun-