Å·±¦ÓéÀÖ

Jump to ratings and reviews
Rate this book

Java Performance: In-Depth Advice for Tuning and Programming Java 8, 11, and Beyond

Rate this book
Coding and testing are generally considered separate areas of expertise. In this practical book, Java expert Scott Oaks takes the approach that anyone who works with Java should be adept at understanding how code behaves in the Java Virtual Machine--including the tunings likely to help performance. This updated second edition helps you gain in-depth knowledge of Java application performance using both the JVM and the Java platform.

Developers and performance engineers alike will learn a variety of features, tools, and processes for improving the way the Java 8 and 11 LTS releases perform. While the emphasis is on production-supported releases and features, this book also features previews of exciting new technologies such as ahead-of-time compilation and experimental garbage collections.


Understand how various Java platforms and compilers affect performance
Learn how Java garbage collection works
Apply four principles to obtain best results from performance testing
Use the JDK and other tools to learn how a Java application is performing
Minimize the garbage collector's impact through tuning and programming practices
Tackle performance issues in Java APIs
Improve Java-driven database application performance

543 pages, Kindle Edition

First published January 1, 2014

154 people are currently reading
971 people want to read

About the author

Scott Oaks

12Ìýbooks10Ìýfollowers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
170 (55%)
4 stars
99 (32%)
3 stars
30 (9%)
2 stars
6 (1%)
1 star
3 (<1%)
Displaying 1 - 30 of 34 reviews
Profile Image for Rod Hilton.
151 reviews3,117 followers
December 10, 2015
Ever hear of the Baader-Meinhof Phenomenon? It's the name given for that weird feeling you have when you learn a new word you've never seen before, and then all of a sudden you're seeing it absolutely everywhere. It seems like every e-mail and every TV show is using this word, and you wonder to yourself how you managed to never notice it before, since it's all over the place now? Or maybe you start looking at a new car and researching it, and all of a sudden it seems like everyone on the road is driving that same car?

I had a very similar effect with this book. I've been a Java programmer for over a decade, but never really been terribly concerned with performance, or the internals of the JVM. I try to write good code in terms of using hashmaps and whatnot to do lookups in constant time rather than O(n) time, but microoptimizations were never my thing. I never really felt like it was something I needed to care about, I never really noticed any performance ISSUES in the products I've worked on during my career. But then whenever I'd finish a chapter in this book, I'd notice that the error messages the chapter mentioned, or the kind of things you might notice when performance is degraded started popping up. Within days of finishing the chapter on the Java Heap, we started experiencing Out of Memory errors on some nodes in our production cluster. I recognized the error messages from the book, and knew what tools to reach for because of it as well. After reading the sections on Threading and Java SE Optimizations, I immediately noticed us doing some goofy, ill-advised things in our code. But the out of memory errors had been happening for months I think, and the code I was noticing had been in place for over a year. This stuff had been all around me, and I just wasn't seeing it. The Baader-Meinhof Phenomenon in action.

Truth be told, this book was a bit of a slog to get through. I started it over a year ago, and the material is just so insanely dry that it was a battle. I'd rate myself maybe a 7 out of 10 in terms of interest level in stuff like JVM internals, flags, garbage collection algorithms, and so forth. I like systems stuff, I usually attend low-level system JVM type talks at conferences, but I still found the book, especially the first half, so incredibly dry that I could barely push my way through it. While talking to some buddies about this book, I estimated each chapter's length around 60-80 pages, and then when I checked it turned out most were only around 30 pages or so. Like a 1.5-hour movie that feels like 4, this book is almost punishing.

Don't get me wrong, it's full of useful information - in fact the degree to which it is densely, densely packed with information almost contributes to how dry it feels, since you can't read any part of it quickly due to how information-dense the pages are. I learned an absolute ton from this book and highlighted pages and pages worth of notes, but if you wouldn't give yourself a 6 or 7 out of 10 (or higher) on the scale of general-interest-in-JVM-internals, I think you probably stand no chance at making it all the way through the book.

If this kind of stuff is your cup of tea, definitely give this book a shot. I think it's the most up-to-date (it talks a lot about Java 7 and 8) of all of the books with the words "Java" and "Performance" in the title (I know of at least 3) and I think it's meant to effectively deprecate the others. If you're experiencing performance problems, or hell even if you're not but you want to be the person on your team who can fix them when they inevitably do arise, it's worth reading for sure. Just, be aware that you'll really have to like this kind of stuff to get through the whole thing.
Profile Image for Tomasz Nurkiewicz.
AuthorÌý1 book47 followers
October 18, 2014
Java Performance: The Definitive Guide is the best Java book I read this year. In about 400 pages Scott Oaks touches every aspect of Java-based applications, from core terminology and methodologies, through tooling, JIT, garbage collection, threading etc., to reach high-level topics, such as Java EE, JDBC/JPA, Java 8 and even... JavaScript and CSS compression. But let's go through this book chapter by chapter.

First the author explains common terms like what is a microbenchmark, measuring throughput versus response time, etc. Surprisingly few sections are devoted solely to statistics and interpretation of inherently varying benchmark results. Oaks goes as far as briefly explaining Student's t-test - important tool in measuring correctness of tests. I found that part very enjoyable (and way too short), but it's just about enough for ordinary purposes. Now it's time to get our hands dirty. Before we start exploring Java performance, author goes through various tool, both available out-of-the-box in JDK and proprietary. A lot is said about different types of profilers - and why they don't show the full picture.

JIT (just-in-time) compiler turns out to be one of the most important tools bringing performance to the JVM. First "real" chapter goes into great details of how JIT works in different modes, how to monitor and tune it. I learnt a lot already, but the best is yet to come. Obviously garbage collection is a major concern, thus Oaks devotes two full chapters to explain all popular GC algorithms. Besides pure description, expect strengths and weaknesses of every algorithm as well as unique tuning options. These two chapters are enough to buy this book, but there's plenty more.

Further into the book, topics are becoming more high-level. We start with assembly and JIT, through GC, heap and native memory, to reach chapters about threading, thread pools and synchronization. There are many, many examples of proper and broken use of multi-threading, including benchmarks - present throughout whole book as well. We also learn how to monitor and tune threads. Later we learn about somewhat related Java EE topics, including XML parsing performance (expect plenty of SAX/StAX/DOM benchmarks!), JSON and Java serialization. Also HTTP sessions and servlets are well covered, with amazing benchmarks how bloated session or incorrectly tuned thread pools affect performance. I was really amazed to see how increasing heap can degrade (!) performance. Last chapter, "Java SE API Tips" is surprisingly interesting, with many good advices about collections, streams and lambdas introduced in Java 8, class loading, I/O, etc. I think you see the overall picture by now - we start almost from hardware level to reach JDBC/JPA and JDK level in the end. Similarly to first chapter, still every concept is accompanied with microbenchmark.

Because this not-so-long book still manages to cover wide range of subjects, I can honestly recommend it to beginners and more experienced Java developers (the former should probably start reading it from back to front). Some aspects are covered only briefly, but in general it was a very enjoyable and thought-provoking lecture. A must buy for every Java developer struggling with performance or lacking understanding of how JVM works. Highly recommended.
Profile Image for Michael Koltsov.
109 reviews69 followers
June 11, 2020
This was one of the hardest book I've read and bear in mind that I've read the first edition many years ago. It took me a few months to read it cover to cover, mostly because I wanted to play with concepts presented and explained in the book. Sorry for whining, but I really enjoyed the proccess of reading, hence this sacrifice of reading one chapter and even less every week was absolutley worth it.

At first I expected it to simply copy concepts from the previous book and add features of more recent JVMs as Joshua Bloch does with "Effective Java". I was utterly wrong.

This book is a complete redesign having not much in common with the first edition. Most basics like explaining how the classloaders work in Java (that are mostly unneccessary for experienced devs but may be needed for the newcomers) are gone now. The book is really condensed and purified now. I was often finding things I had no idea before while reading it. And I'm doing Java for more than a decade now, though I had breaks to work on other languages to learn to see things from another's perspective. It allows me to be multifaceted to a degree where I can choose whether to use Scala, Ruby, Golang, JS or Java to implement a certain feature. Offtopic aside this helps me a lot to understand how the JVM works and I can compare its implementation of certain features with other languages and compilers.

This book is a real pleasure to read though it requires a lot of thoughtwork from the reader if you want to get bang for your buck.

I'd put it on one shelf with "Effective Java", "Java concurrency in Practice". This book is a must have for anyone who wants to advance in his career connected to the JVM.

My score 5/5
Profile Image for Stephen.
AuthorÌý7 books14 followers
July 31, 2014
I got a copy of this book through the Amazon Vine program, thinking that it might be time to brush up on some nuts-and-bolts Java information. I'm glad that I did. For me a good technical book sets the context for the problem and gives you enough information to apply what you learned to harder problems that the book covers, but which also gives you information you can apply immediately. java performance the definitive guide does a good job of both.

This book will be useful for both those new to programming in Java (since performance and resource use area rarely emphasized who you are learning to program) and those who have been programming a while but have not spent as much time thinking about performance as one might like.
Profile Image for Michael Koltsov.
109 reviews69 followers
June 11, 2020
This was one of the hardest book I've read and bear in mind that I've read the first edition many years ago. It took me a few months to read it cover to cover, mostly because I wanted to play with concepts presented and explained in the book. Sorry for whining, but I really enjoyed the proccess of reading, hence this sacrifice of reading one chapter and even less every week was absolutley worth it.

At first I expected it to simply copy concepts from the previous book and add features of more recent JVMs as Joshua Bloch does with "Effective Java". I was utterly wrong.

This book is a complete redesign having not much in common with the first edition. Most basics like explaining how the classloaders work in Java (that are mostly unneccessary for experienced devs but may be needed for the newcomers) are gone now. The book is really condensed and purified now. I was often finding things I had no idea before while reading it. And I'm doing Java for more than a decade now, though I had breaks to work on other languages to learn to see things from another's perspective. It allows me to be multifaceted to a degree where I can choose whether to use Scala, Ruby, Golang, JS or Java to implement a certain feature. Offtopic aside this helps me a lot to understand how the JVM works and I can compare its implementation of certain features with other languages and compilers.

This book is a real pleasure to read though it requires a lot of thoughtwork from the reader if you want to get bang for your buck.

I'd put it on one shelf with "Effective Java", "Java concurrency in Practice". This book is a must have for anyone who wants to advance in his career connected to the JVM.

My score 5/5
Profile Image for Sumit.
65 reviews8 followers
August 8, 2016
This book covers multiple areas of improvement in great detail, including garbage collection heap memory, native memory, threading and synchronization. A very useful for those looking to tune the performance of their Java application
103 reviews5 followers
January 10, 2016
Excellent introduction to understanding Java performance. Well paced and informative without being overly dry.
Profile Image for Leo.
300 reviews25 followers
February 23, 2025
Can I really put anything except 5 stars here? I don't think so. Is this ideal book - probably not. But it's unique, you just have no chance of finding this information in systematic way anywhere else.
Would any Java developer benefit from reading it? Also probably not. Performance optimizations, GC tuning etc is a niche thing, in most cases implementing business logic quickly and writing understandable / maintainable code would be much more important, when startup is looking for a PMF performance is not a priority. When starting optimizations, you'll probably get much more from removing unnecessary operations, checking algorithms and data structures you're using etc.
But at certain scale you'll have to start looking at how GC performs, when your code gets compiled etc, and that's when you'll reach for that book, or be grateful that you've read it before just out of curiosity.
Profile Image for Prakash.
153 reviews88 followers
March 8, 2017
Excellent book to read if you are looking to tune your java application.

Not an absolute marvel if you are a software developer looking to learn more about the internals of JVM. Obviously, that doesn't seem to be the target audience of this book, but I guess the latter demographic eclipses the former (even among the buyers).

The book covers almost all aspects of JVM but can get a little sluggish due to the focus on tuning. I was certainly expecting more theoretical information especially around garbage collection. The author doesn't dive too deep in certain concepts.

For comparison, if you look at the JRockit book, that book doesn't hold back.

But all in all, it is still useful to read and you will obviously learn a lot.
Profile Image for Manzur.
28 reviews1 follower
May 30, 2017
This book is for adults.. adult developers, who are ready to think about software performance not in theoretical big-O notation, but in terms of processor caches, memory pages, garbage collection, JIT and etc, which means a lot in a production environment. So this book introduces you to the techniques of developing performant Java code; tools for profiling and troubleshooting your code; and, of course, 1001 ways of tuning JVM. All in all, it contains a lot of Java development wisdom, and I can assume that even advanced Java devs will find something useful.
Profile Image for Bugzmanov.
230 reviews89 followers
October 13, 2021
As a book on JVM internals - it is one the best (if not the best) I've read.
As a book on perf engineering - it's ok-ish but not great. I liked that it covers why benchmarks are hard and how to avoid getting garbage results, I just wish the book spent more time on this to drive points home.
In the second part (right after chapter on threading) the book degrades a bit. The last chapters can be skimmed over.

Things I liked:
- solid description of main parts of jvm
- coverage of jdk tools
- explanation of jvm logging formats and tools output
Profile Image for Cristian Stan.
27 reviews2 followers
November 21, 2016
I really recommend this book. I touches a lot of important topics about Java language and the JVM. Achieving high performance is not an easy task because a lot of knowledge is needed but this books covers the most important aspects and also teaches the basics about the methodology of performance testing, in itself a not trivial challenge.
Profile Image for Hussein Elsayed.
19 reviews8 followers
January 20, 2019
I totally recommend every java developer “who is eager to write performant applications� to read this book .. its very useful and covers alot of performance tunings and testing tricks .. the best chapters for me were the ones covering GC tuning and of course the last 3 chapters were very interesting.
27 reviews10 followers
October 5, 2022
There is lot of useful information in this book to understand nitty gritty details of different garbage collectors. Taking away 2 stars because
- It throws around lot of numbers and let reader figure out how those numbers are calculated.
- Kirk Pepperdine's talks are much more practical and useful.
2 reviews
December 29, 2024
Book is good and informative for someone who want to understand jvm internals impact on performance. Only thing that really bothered me is that there are a lot of errata which should be corrected and updated atleast in digitial versions (I had oreilly subscription and read book on oreilly platform).
Profile Image for Lojza Tran.
34 reviews1 follower
July 29, 2018
Must-read book for everybody who wants to be a better Java developer. The topics are also interesting for developers of different languages, as some principles apply in general - e.g. JIT, garbage collection.
Profile Image for Vahid .
16 reviews
February 20, 2022
This is one of the best books on Java Performance out there.
It has significantly shifted (and upgraded) my knowledge in this critical area. It has been a definite level-up for me.
Kudos to Scott Oaks for this masterpiece!
Profile Image for Vzh.
27 reviews1 follower
April 16, 2021
Cool stuff.
Many general topics discussed.
As a non-Java dev, I've got surprised of how thorough the platform is presented. Definitely recommend.
Profile Image for Aaron Decker.
20 reviews2 followers
March 20, 2017
Best Java book I have encountered other than Effective Java.
1 review
April 19, 2023
"Java Performance, 2nd Edition" by Scott Oaks is a highly informative and thought-provoking resource for Java developers. With its dense coverage of various performance aspects, the book delivers a wealth of insightful material that helps readers build a solid foundation in Java performance optimization.

While the book alone won't make you an expert in performance, it serves as an excellent starting point for understanding the complexities of the Java runtime environment, garbage collection, and profiling tools. Author's concise writing and practical examples make it easy for readers to grasp and apply the concepts to their own projects.

In summary, "Java Performance, 2nd Edition" is a must-read for those looking to enhance their skills in Java performance optimisation.
Profile Image for Franck Chauvel.
119 reviews5 followers
March 14, 2015
This book describes both best programming practices that will secure the performance of your Java code as well as how to finely tune the underlying Java virtual machine to get best possible performance. Performance here is mainly understood as the trade-off between memory consumption and execution time. Covered topics include garbage collection, JavaEE configuration, multi-threading, micro-benchmarking, and recent new Java8 features to name a few.
Yet the book assumes some fluency in Java programming and a good understanding of how programs work in general. It helped me profiile and change Java applications and to get noticeable performance increases.
87 reviews5 followers
November 5, 2016
The rare book dedicated to performance topic of java, decent level of choosing subject to discuss and quality of explanation.
I found the how I can improve my level of understanding and memorizing any book read - writing extracts in parallel with reading,
Profile Image for Zbyszek Sokolowski.
291 reviews16 followers
May 18, 2015
This is one of the best books on the market. Second one on performance topic but it is good. I would like to be a second part. It gives good insight about what is going on in the JVM. How different things behaves etc. I will come back to it frequently.
Displaying 1 - 30 of 34 reviews

Can't find what you're looking for?

Get help and learn more about the design.