Register your product to gain access to bonus material or receive a coupon.
This book was written with one goal in mind: to provide Java programmers with the expertise needed to build efficient, scalable Java code. The author shares his experience in server-side performance tuning through measured performance assessments, called optimizations. Each optimization discusses techniques to improve the performance and scalability of your code. Every claim is substantiated with hard numbers and an experience-based evaluation. Java Performance and Scalability, Volume 1, provides invaluable advice that you will, no doubt, find useful in your coding.
Presented in 48 concise lessons that target the most common and critical performance pitfalls, this book offers a plethora of practical tips and solutions for boosting the performance of your programs. These lessons cover performance-critical areas such as memory management, garbage collection, caching, and multithreading.
Specific lessons include:
In addition to providing hard numbers that quantify the optimizations, the author concludes the book with an application demonstrating the effectiveness of the performance optimizations. The exercise takes a typical program and increases its performance fourfold through a series of steps that tie together the lessons learned throughout the book. He offers both the means and the proof to better coding.
List of Figures.
Preface.
Introduction.
1 Java Strings.
Optimization 1: String Concatenation.2 Pure Overhead.
Optimization 9: Useless Computations.3 Vectors and Hashtables.
Optimization 17: Vector Add and Remove.4 Caching.
Optimization 25: Cache File Contents.5 I/O Streams.
Example I/O Code.6 Recycling.
Optimization 36: Object Recycling.7 Scalability and Multithreading.
Scalability Basics.8 JNI.
Optimization 46: JNI Surprise.9 RMI.
The RMI Network Plumbing.10 Servlets.
Servlets Using PrintWriter.11 A Java Web Server.
Version 1: The Original Server.CacheDriver.java.
CacheConnection.java.
CacheStatement.java.
CacheCallableStatement.java.
CachePreparedStatement.java.
CacheDriver.properties.
B Simple Java Web Server.Server.java.
FileInfo.java.
UrlCache.java.
LazyDate.java.
MyGetBytes.java.
server.properties.
Bibliography.
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.