Chapter 1. Introduction
This is a topic about the art and science of Java performance.
The science part of this statement isn't surprising; discussions about performance include
lots of numbers and measurements and analytics. Most performance engineers have a back-
ground in the sciences, and applying scientific rigor is a crucial part of achieving maximum
What about the art part? The notion that performance tuning is part art and part science is
hardly new, but it is rarely given explicit acknowledgment in performance discussions. This
is partly because the idea of “art” goes against our training.
Part of the reason is that what looks like art to some people is fundamentally based on deep
knowledge and experience. It is said that magic is indistinguishable from sufficiently ad-
vanced technologies, and certainly it is true that a cell phone would look magical to a knight
of the Round Table. Similarly, the work produced by a good performance engineer may look
like art, but that art is really an application of deep knowledge, experience, and intuition.
This topic cannot help with the experience and intuition part of that equation, but its goal is
to help with the deep knowledge—with the view that applying knowledge over time will
help you develop the skills needed to be a good Java performance engineer. The goal is to
give you an in-depth understanding of the performance aspects of the Java platform.
This knowledge falls into two broad categories. First is the performance of the Java Virtual
Machine (JVM) itself: the way in which the JVM is configured affects many aspects of the
performance of a program. Developers who are experienced in other languages may find the
need for tuning to be somewhat irksome, though in reality tuning the JVM is completely ana-
logous to testing and choosing compiler flags during compilation for C++ programmers, or
to setting appropriate variables in a php.ini file for PHP coders, and so on.
The second aspect is to understand how the features of the Java platform affect performance.
Note the use of the word platform here: some features (e.g., threading and synchronization)
are part of the language, and some features (e.g., XML parsing performance) are part of the
standard Java API. Though there are important distinctions between the Java language and