This chapter covers
- Why performance matters
- The G1 garbage collector
- Just-in-time compilation
- JFR - the JDK Flight Recorder
Poor performance kills applications—it’s bad for your customers and your application’s reputation. Unless you have a totally captive market, your customers will vote with their feet—they’ll already be out of the door, heading to a competitor. To stop poor performance harming your project, you need to understand performance analysis and how to make it work for you.
Performance analysis and tuning is a huge subject, and there are too many treatments out there that focus on the wrong things. So we’re going to start by telling you the big secret of performance tuning.
Here it is—the single biggest secret of performance tuning: You have to measure. You can’t tune properly without measuring.
And here’s why: The human brain is pretty much always wrong when it comes to guessing what the slow parts of systems are. Everyone’s is. Yours, mine, James Gosling’s—we’re all subject to our subconscious biases and tend to see patterns that may not be there.
In fact, the answer to the question, "Which part of my Java code needs optimizing?" is quite often, "None of it."