Performance has been an important issue for Java developers ever since the first version hit the streets. Over the years, Java performance has improved dramatically, but tuning is essential to get the best results, especially for J2EE applications. You can never have code that runs too fast.Java Peformance Tuning, 2nd edition provides a comprehensive and indispensable guide to eliminating all types of performance problems. Using many real-life examples to work through the tuning process in detail, JPT shows how tricks such as minimizing object creation and replacing strings with arrays can really pay off in improving your code's performance.Tuning J2EE applications bears many similarities to tuning J2SE apps, but important and specific considerations apply. For this reason, Java Performance Tuning, Second Edition includes four new chapters: a new chapter on J2EE application tuning in general followed by chapters on tuning JDBC, servlets and JSPs, and EJBs.Java Performance Tuning offers common-sense advice about what to tune and what to leave alone, emphasizing techniques that provide big performance gains with minimal code restructuring. It gives you crucial guidance that helps you tune without destroying your program's architecture. Blindly changing things in an effort to make a program run faster is a great way to create buggy, unmaintainable code. Java Performance Tuning teaches you to work efficiently and effectively, resulting in code that is robust, maintainable, and fast.Java Performance Tuning, Second Edition shows you how to:

Create a performance plan

Glean information about your program's behavior from profiling tools

Identify bottlenecks before tuning

Minimize the number of objects your program creates, particularly critical for J2EE applications

Optimize the use of strings

Avoid performance penalties from inefficient code

Improve the behavior of loops and switches

Optimize I/O behavior

Use appropriate algorithms for sorting and other common tasks

Use threads effectively

Optimize the performance of distributed systems

Speed up servlets and JSPs

Structure JDBC usage efficiently

Use effective design patterns to optimize EJB performance

Covers JDK 1.4

Chapter 1 Introduction

Why Is It Slow?

The Tuning Game

System Limitations and What to Tune

A Tuning Strategy

Perceived Performance

Starting to Tune

What to Measure

Don't Tune What You Don't Need to Tune

Performance Checklist

Chapter 2 Profiling Tools

Measurements and Timings

Garbage Collection

Method Calls

Object-Creation Profiling

Monitoring Gross Memory Usage

Client/Server Communications

Performance Checklist

Chapter 3 Underlying JDK Improvements

Garbage Collection

Tuning the Heap

Gross Tuning

Fine-Tuning the Heap

Sharing Memory

Replacing JDK Classes

Faster VMs

Better Optimizing Compilers

Sun's Compiler and Runtime Optimizations

Compile to Native Machine Code

Native Method Calls

Uncompressed ZIP/JAR Files

Performance Checklist

Chapter 4 Object Creation

Object-Creation Statistics

Object Reuse

Reference Objects

Avoiding Garbage Collection

Initialization

Early and Late Initialization

Performance Checklist

Chapter 5 Strings

The Performance Effects of Strings

Compile-Time Versus Runtime Resolution of Strings

Conversions to Strings

Strings Versus char Arrays

String Comparisons and Searches

Sorting Internationalized Strings

Performance Checklist

Chapter 6 Exceptions, Assertions, Casts, and Variables

Exceptions

Assertions

Casts

Variables

Method Parameters

Performance Checklist

Chapter 7 Loops, Switches, and Recursion

Loops

Tuning a Loop

Exception-Terminated Loops

Switches

Recursion

Recursion and Stacks

Performance Checklist

Chapter 8 I/O, Logging, and Console Output

Replacing System.out

Logging

From Raw I/O to Smokin' I/O

Serialization

Clustering Objects and Counting I/O Operations

Compression

NIO

Performance Checklist

Chapter 9 Sorting

Avoiding Unnecessary Sorting Overhead

An Efficient Sorting Framework

Better Than O(nlogn) Sorting

Performance Checklist

Chapter 10 Threading

User-Interface Thread and Other Threads

Race Conditions

Deadlocks

Synchronization Overhead

Timing Multithreaded Tests

Atomic Access and Assignment

Thread Pools

Load Balancing

Threaded Problem-Solving Strategies

Performance Checklist

Chapter 11 Appropriate Data Structures and Algorithms

Collections

Java 2 Collections

Hashtables and HashMaps

Optimizing Queries

Comparing LinkedLists and ArrayLists

The RandomAccess Interface

Cached Access

Caching Examples

Finding the Index for Partially Matched Strings

Search Trees

Performance Checklist

Chapter 12 Distributed Computing

Tools

Message Reduction

Comparing Communications Layers

Caching

Batching I

Application Partitioning

Batching II

Low-Level Communication Optimizations

Distributed Garbage Collection

Databases

Web Services

Performance Checklist

Chapter 13 When to Optimize

When Not to Optimize

Tuning Class Libraries and Beans

Analysis

Design and Architecture

Tuning After Deployment

More Factors That Affect Performance

Performance Planning

Performance Checklist

Chapter 14 Underlying Operating System and Network Improvements

Hard Disks

CPU

RAM

Network I/O

Performance Checklist

Chapter 15 J2EE Performance Tuning

Performance Planning

J2EE Monitoring and Profiling Tools

Measurements: What, Where, and How

Load Testing

User Perception

Clustering and Load Balancing

Tuning JMS

Performance Checklist

Chapter 16 Tuning JDBC

Measuring JDBC Performance

Tuning JDBC

Performance Checklist

Chapter 17 Tuning Servlets and JSPs

Don't Use SingleThreadModel

Efficient Page Creation and Output

Body Tags

Cache Tags

HttpSession

Compression

More Performance Tips

Case Study: Ace's Hardware SPECmine Tool

Performance Checklist

Chapter 18 Tuning EJBs

Primary Design Guidelines

Performance-Optimizing Design Patterns

The Application Server

More Suggestions for Tuning EJBs

Case Study: The Pet Store

Case Study: Elite.com

Performance Checklist

Chapter 19 Further Resources

The Primary Resource

Books

Magazines

URLs

Profilers

Optimizers

Colophon

Jack Shirazi

Jack Shirazi is an independent consultant. He was an early adopter of Java, and for the last few years has consulted mainly for the financial sector, focusing on Java performance. Before using Java, Jack spent many years tuning Smalltalk applications. Jack's early career involved research in theoretical physics and bioinformatics. Jack has publications in the field of protein structure and is proud to have contributed to some of the core Perl5 modules.

Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal on the cover of Java Performance Tuning is a serval (Leptailarus serval). This long-legged cat is found in most parts of Africa, except for very dry areas of the continent, such as the northern regions around the Sahara Desert. Servals range in color from light brown to a darker reddish brown (some servals are entirely black); their coats are covered with dark spots that merge into stripes along the upper part of their backs. The pattern of their markings varies geographically; servals from wetter areas have smaller, finer spots, while those from drier areas have larger marks. Servals can grow up to 3 feet long and 20 inches tall at the shoulder, making their legs very long in proportion to their bodies. They use this height to their advantage, as they are able to see movement in the tall grass in which they hunt for the hares, rodents, and small birds they like to eat. Their big ears and highly developed auditory systems enable them to hear the high-pitched, ultrasonic sounds made by rodents-- they are even able to hear them tunneling underground -- and they can also leap up to 10 feet into the air to catch birds. Emily Quill was the production editor and proofreader for Java Performance Tuning, Second Edition. Ann Schirmer was the copyeditor. Linley Dolby and Philip Dangler provided quality control. Ellen Troutman wrote the index.Emma Colby designed the cover of this book, based on a series design by Edie Freedman. The cover image is a 19th-century engraving from the Couvier Pictorial Archive. Emma Colby produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.David Futato designed the interior layout. This book was converted to FrameMaker 5.5.6 by Joe Wizda and Judy Hoer with a format conversion tool created by Erik Ray, Jason McIntosh, Neil Walls, and Mike Sierra that uses Perl and XML technologies. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia FreeHand 9 and Adobe Photoshop 6. The tip and warning icons were drawn by Christopher Bing. This colophon was written by Leanne Soylemez.

I read this book and have to say that it was really good. Bad thing is that it is about quite dated and only one JVM. I bought the book after being inspired by Stan who wrote interesting article with different approach When optimizing - don't forget the Java Virtual Machine (JVM) (http://bigdatamatters.com/bigdatamatters/2009/08/jvm-performance.html) . I wanted to tune my application as much as possible and this book was very helpful in this task. Oh by read I mean, read and tune!

Java Performance Tuning would be a good book to have if you have a seriously performance intensive application or for someone who just really dug performance issues. But it wouldn't be of interest to most people. Most programmers should be able to do all the performance tuning they need to do with a program like Optomizeit.