Java Reference
In-Depth Information
server or by ensuring it is the default for the particular Java installation being used), and en-
sure that the Java command line includes the flag -XX:+TieredCompilation (the default
value of which is false ). In Java 8, tiered compilation is enabled by default.
To understand the trade-offs here, let's look at a few examples.
Optimizing Startup
The client compiler is most often used when fast startup is the primary objective. The differ-
ence this makes on various applications is shown in Table 4-1 .
Table 4-1. Startup time of various applications
Application -client
-client -server
-server -XX:+TieredCompilation
HelloWorld 0.08
In a simple HelloWorld application, neither compiler has an advantage because not enough
code is run for either compiler to make any contribution. And for a task that lasts only 80 ms,
we'd be hard-pressed to notice a difference if it did exist.
NetBeans is a fairly typical, moderately sized Java GUI application. On startup, it loads
about 10,000 classes, performs initialization of several graphical objects, and so on. Here, the
client compiler offers a significant advantage on startup: the server compiler starts 38.5%
slower, and the 1-second difference will certainly be noticeable. Note that the tiered compiler
isn't quite as fast, though it is only about 8% slower, a fairly trivial difference.
This is the reason NetBeans—and many GUI programs like it, including the Java plug-in
used by web browsers—uses the client compiler by default. Performance is often all about
perception: if the initial startup seems faster, and everything else seems fine, users will tend
to view the program that has started faster as being faster overall.
Search WWH ::

Custom Search