|
S
ince
the early days of Java, performance has been an area of concern for Java
developers. In order to address this concern, many of today's Java books
contain one or two chapters that discuss certain aspects of Java performance
and how to achieve a good or decent performance in Java programs. Examples
are
Practical
Java
by Peter Haggar (Addison-Wesley, 2000), which deals mostly
with low-level programming tricks, and
Java
2 Performance and Idiom Guide
by Craig Larman, et al., which takes
a somewhat broader look at this issue.
Java
Platform Performance
is completely devoted to this matter. Because it is published in Addison-Wesley's
Sun Java series, it is also in some ways Sun's semi-official statement
related to this critical issue.
Any
book that deals with performance and Java has to narrow its focus in certain
respects; the whole issue of Java performance is too much for a single
book. For example, think of general language and environment-independent
performance techniques (such as the use of buffering instead of single
element processing). Also consider the huge field of Java programming:
GUI programming, multithread programming, and distribution with different
programming models. Think of the different Java technologies like Jini
and EJB. While all of this is "Java," each of these areas has its own specific
performance issues and tricks.
Because
Java
Platform Performance
contains only 230 pages, it must be very focused;
let's see on what.
The
first part of the book is called "Strategies." These three chapters (amounting
to fewer than 40 pages) each deal with one of the following issues:
-
What performance
is (runtime performance, RAM footprint, etc.)
-
How achieving
good performance is linked to the complete software development process
-
How to
benchmark and profile a software system
The second
part, called "Tactics," is where it gets concrete: nine chapters (roughly
150 pages) each deal with a specific Java performance issue:
-
I/O
performance.
Mostly discusses buffering and the tricky business of
object serialization.
-
RAM
footprint.
Discusses how to measure and optimize object size.
-
Class
loading.
Discusses when classes are really loaded and encourages programmers
to run multiple threads in one VM instead of multiple VMs.
-
Object
mutability.
Discusses different aspects related to this issue: e.g.,
String
versus
StringBuffer
performance, how immutable objects or immutable interfaces to mutable objects
can prevent the expensive invocation of
clone()
,
etc.
-
Algorithms
and data structures.
Discusses choosing the right algorithms (iteration,
recursion) with the help of benchmarking, and selecting the appropriate
data structure type from the JDK 1.2 collection framework.
-
Using
native code.
Discusses performance advantages (and disadvantages) using
JNI.
-
Swing
programming
(two chapters on this). One chapter discusses renderers
and the Swing model; the other deals with more general Swing design and
implementation techniques to achieve a responsive user interface.
-
Deployment.
Discusses how JAR files can help you save download time.
Java
Platform Performance
closes with two appendices about the two most
import Java functionalities related to performance. One is Java garbage
collection and the other is the relatively new
Java
HotSpot VM
. Steve Wilson and Jeff Kesselman discuss in detail what
the Java HotSpot VM does and to a certain degree how it works.
The
discussion of garbage collection, in contrast, does not go into the direction
of how garbage collection is implemented in Java. Instead, the authors
discuss how references are logically maintained in Java: How does an object
become unreachable? What is the process of garbage collection (finalization,
freeing of memory, etc.)? What is the idea behind the reference abstractions
introduced with the Java 2 platform?
As
you can see,
Java Platform Performance
focuses on those Java performance
issues that are relevant to all Java programmers. The only exception are
the two chapters about Swing programming, which might be not so interesting
for Java server-side programmers.
There
is one issue that should have been covered: how well Java performs when
it is compiled to machine code. Perhaps this is not included because compiled
Java is at odds with Sun's official policy of "compile once, run everywhere."
Perhaps you shouldn't expect this issue to be raised in a book published
in the Sun Java series.
Java
Platform Performance
is a good book that addresses all relevant issues
in a way that is easy to follow for someone new to Java performance. An
advanced Java programmer might find it a little disappointing, however,
because he or she might have already heard most of the issues. There are
no radically new ideas in this book. But then, new ideas regarding Java
performance improvements might not even exist.
Angelika
Langer
develops and teaches classes on Java, C++, multithreading, and
internationalization. She is an internationally recognized speaker and
served on the ANSI/ISO C++ Committee from 1993 to 1998.
Klaus Kreft
is a software architect and senior consultant with 15+ years of experience
in industrial software development. He currently works for Siemens Business
Services in Germany. Langer and Kreft are authors of "Standard C++ IOStreams
and Locales" (Addison-Wesley, 2000) and are columnists for the C/C++ Users
Journal.
|