7 Understanding Java performance

 

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."

7.1 Performance terminology—some basic definitions

7.1.1 Latency

7.1.2 Throughput

7.1.3 Utilization

7.1.4 Efficiency

7.1.5 Capacity

7.1.6 Scalability

7.1.7 Degradation

7.2 A pragmatic approach to performance analysis

7.2.1 Know what you’re measuring

7.2.2 Know how to take measurements

7.2.3 Know what your performance goals are

7.2.4 Know when to stop

7.2.5 Know the cost of achieving higher performance

7.2.6 Know the dangers of premature optimization

7.3 What went wrong? Why do we have to care?

sitemap