Even though the Java platform (along with JVM) is one of the most ubiquotus software develoment platforms, it was surprisingly difficult to find a self-contained book dedicated to performance aspects of Java platform. “Java Performance” by Charlie Hunt and Binu John can be considered the only solid and contemporary reference in the domain of performance analysis and tuning of Java based systems. No matter which programming language you use to run on JVM, this book is the essential reference until something better comes along.
On the other hand, make no mistake, this is not a lightweight book, or a cookbook which you can consult for a few performance tuning recipes. Reading Java Performance is more like drinking from the firehose. Whether you are a beginner, or a seasoned developer, it will take time to digest the gory details presented. Luckily, the book’s logical organization is close to perfect and some of the chapters are pretty self-contained.
From start to finish, it is not difficult to see that if you want to consider yourself a serious Java performance engineer, you need to master the majority of the book. Chapter 2 starts with an overview of the basics of operating systems performance and monitoring, setting the stage for the upcoming chapters and acting as a refresher. The authors are very careful to explain concepts concretely by giving examples from Linux, Solaris and MS Windows systems, which makes sense given the portability of JVM. Chapter 3 and 4, if taken together, provide the most comprehensive technical explanation of Java Virtual Machine and Just-in Time compilation from a performance perspective. Even if you are not facing performance problems (yet), this two chapters make a very solid and clear reference for understanding JVM and JIT technology. The terminology, concepts and details in these chapters are very important: Without a solid understanding of them, it is not easy to understand the discussions in the following chapters.
Chapters 5 and 6 focus on profiling, which makes sense, because you cannot improve something if you can’t measure it carefully. After introducing the fundamental concepts about profiling, the authors give concrete examples using different profilers, such as Oracle Solaris Studio Performance Anaylzer, and NetBeans profiler.
Chapter 7 can be considered the most critical part of the book. Authors dedicate 70 pages to a detailed discussion on tuning the JVM and the various garbage collectors. They refrain from making bold statements and always stress how these things are very context sensitive and without proper measurement and profiling not many things can be generalized. They have my utmost respect for this scientific and engineering approach.
Chapter 8, “Benchmarking Java Applications” is where the scientific approach is taken to its full potential: The authors explain how to construct hypotheses regarding performance problems, how to conduct experiments to gather data from the system in question, and then how to use statistical methods to interpret the results. If you have a scientific background, especially natural sciences, where you had to use statistical methods to analyze experiment data, then this chapter will be very familiar (but I guess this is also where the brains of the majority of the Java developers will explode).
The remaining chapters continue with the theme of benchmarking, each chapter dedicate to even more specialized domains of benchmarking. For example Chapter 9 focuses on the topic of benchmarking multi-tiered applications and it even dares to touch the topic of Markov chains for modeling realistic interactions and therefore gathering useful synthetic data (taking into account the fact that for most of the enterprise Java developers secondary school arithmetic is more than enough, this chapter can be easily considered as rocket science for the majority of Java developers).
The remaining chapters delve into the details of web application, web services and persistence performance, each one concentrating on the unique analysis, performance and tuning challenges of those domains.
There is not much to critcize in this superb technical book dedicated to the performance enginnering on the Java platform. A few minor criticisms: The authors’ reference to SPECjbb2013, a very detailed benchmark suite that is not freely available. If you want to try out some of the examples in the book, you have to buy that suite. You can alternatively try to come up with similar examples using the freely available SPECjvm2008, but it would be better if the authors used something that is freely available. Apart from that, authors are a little biased towards Oracle, e.g. mentioning only NetBeans and Solaris Studio Performance Anaylzer, without touching on Eclipse. Finally, even though they provide detailed code listings which are used to indicate different techniques for performance anaylsis and profiling, they are not from real world scenarios and this artificial examples might not be very helpful for the majority of the developers (apart from demonstration purposes).
Conclusion: I can wholeheartedly recommend this book to any software engineer who wants to understand the Java platform and Java Virtual Machine from a performance perspective, as well as to engineers who want to tune their applications for better performance.