I recently finished the book Java Performance: The Definitive Guide* by Scott Oaks and I really liked it!
The book is very well written and Scott gives a lot of in-depth explanations about complex topics like JIT compilation, garbage collector algorithms and thread synchronization. I learned a lot about different ways to analyze the performance of an application and how to optimize it. And I am sure that this book will be very useful when I have to analyze the next performance issue.
I recommend it to every experienced Java developer who likes to learn more about performance optimization.
But lets get into more details …
About the author
Scott is working as an architect at Oracle. He is working on the performance of their middleware software.
About the book
The first and current edition of the book was released in 2014. It has 425 pages and is divided into 12 chapters.
The first three chapters provide lots of introductory and methodically content. Chapter 1 gives a short introduction into the book. In chapter 2 and 3 Scott explains how to do performance tests and recommends several tools for it.
This is followed by a good explanation of the JIT Compiler in chapter 4. After reading this chapter, you really know how the JIT compiler decides which code to compile and which to deoptimize. You also learn what you can do to tune it.
I liked the following 4 chapters the most. They focus heavily on several memory related topics. Chapter 5 and 6 provide very detailed information about garbage collection in Java, the different garbage collection algorithms and how to tune them. After that Scott discusses several best practices for the heap and native memory in the chapters 7 and 8.
After the memory related topics are covered, Scott has a detailed look at threads in chapter 9. He shows how to define good pool sizes, explains the synchronization costs that occur in a multi-threaded environment and introduces some tools to monitor the threads of an application.
Performance tuning in the Java EE environment is explained in chapter 10. He talks about performance of the web container, EJBs, XML and JSON processing, object serialization and networking APIs. This chapter contains solid information but it is the weakest from my point of view. The performance and the tuning options are highly depend on the implementation of the application server and its components. Therefore this book covers only a few, general tuning options and concepts. You should have a look at an application server specific tuning guide, if you need more detailed, server specific information.
Chapter 11 covers JDBC and JPA related best practices. Scott has a look at several options to tune applications your application.
Java SE related tuning options are explained in chapter 12. Some of the 11 different topics discussed in this chapter are Classloading, the Java Collection API, Lambdas and Streams.
Who should read it?
Would I recommend it?
Where to get it?
Disclaimer: I got this book from o’reilly for free to write a review.
* affiliate link