Written for the working programmer who wants to get more speed out of Java, Java Performance and Scalability, Volume 1
bundles several dozen tips for faster and smaller Java code. Backed up by benchmarks of what works and what doesn't, this book provides essential wisdom for eliminating some common bottlenecks to Java performance.
The 48 optimizations for various aspects of the Java API make up the heart of this text. Early sections look at a particularly tricky subject--string processing--giving you several techniques for increasing speed and reducing object creation. The in-depth examination of the costs and benefits of string concatenation and the immutability of Java String objects will help you uncover possible hot spots that cause lagging performance with strings.
Subsequent sections look at more general strategies for faster programs, like purging obsolete code, and the well-known 80-20 rule (optimizing the 20 percent of your code that consumes 80 percent of processing time, allowing you to create faster software; this book shows you how). Short tips on such APIs as Java collections and the Java Native Interface (JNI) come next.
The second half of the book zeros in on better server-side performance with tips on caching and file I/O. The guide to multithreading and synchronization is a standout here. You'll get several smart tips for speeding up servlets, such as precomputing your standard strings for headers and other boilerplate HTML. The book closes with a valuable custom class for JDBC database connection pooling and a custom HTTP server. Both samples make use of the techniques presented earlier in the text. Even if you don't adopt every suggestion, the ideas here can get you thinking about performance in new ways. (One of the main points of this book is that you can write faster custom code, instead of always relying on built-in Java classes and APIs.)
Clearly, Java performance is not something that happens by accident; it must be engineered into your code. This compilation of useful techniques and tips deserves a close look by anyone who wants to squeeze more performance out of Java. --Richard Dragan
- Introduction to Java performance
- More efficient Java string handling (optimizing String, StringBuffer, and StringTokenizer objects)
- Reducing Java overhead
- Faster initialization
- The 80-20 rule for optimization
- Getting rid of obsolete code
- Speeding up the JDK 1.1 Vector and Hashtable collection classes
- Caching techniques
- Optimizing file I/O and buffering
- Object recycling and object pools
- Techniques for multithreading and synchronization
- Amdahl's law and scalability basics
- Pros and cons of using the Java Native Interface (JNI)
- Hints for optimizing Remote Invocation Method (RIM) calls
- Performance hints for servlets and JavaServer Pages (JSPs)
- Custom sample code for JDBC database connection pooling and a Java HTTP server
From the Inside Flap
Performance has been one of the dominant concerns hovering around Java from its infancy. Regardless of an order of magnitude speedup resulting from just-in-time (JIT) compilers, HotSpot, and other advances in JVM technology, the performance issue is still a legitimate concern. The reality facing Java programmers is that it is very easy to write slow Java programs. Java is a performance mine field and expert guidance is a must.
Given the importance of performance to Java developers, it is somewhat surprising that no book has been dedicated to this important topic. Almost any other Java-related issue has had multiple books dedicated to it--RMI, JNI, JDBC, threads, networking, and the list goes on. Conspicuously absent has been Java performance. It has been mentioned in passing by many authors but, to my knowledge, rarely has there been more than a chapter discussing it. This book is aiming to fill that gaping hole. It is entirely focused on Java performance issues from start to finish.
This book is written for Java programmers by a Java programmer. This is an important fact. It is very likely that the Java performance issues that I have dealt with in my code will surface in your code as well. The Java optimization techniques that you will find here will significantly elevate the performance and scalability of your Java programs.
There's plenty of material to cover. Let's get started.