Java Performance Optimization Tools and Techniques for Turbocharged Apps–reference
Java Performance Optimization
Java is among the most widely used programming languages in the software development world today. Java applications are used within many verticals (banking,telecommunications,healthcare,etc.),and in some cases each vertical suggests a particular set of design optimizations. Many performance-related best practices are common to applications of all kinds. The purpose of this Refcard is to help developers improve application performance in as many business contexts as possible by focusing on the JVM internals,performance tuning principles and best practices,and how to make use of available monitoring and troubleshooting tools.
It is possible to define “optimal performance” in different ways,but the basic elements are: the ability of a Java program to perform its computing tasks within the business response time requirements,and the ability of an application to fulfill its business functions under high volume,in a timely manner,with high reliability and low latency. Sometimes the numbers themselves become patternized: for some major websites,a page response time of 500ms maximum per user function is considered optimal. This Refcard will include target numbers when appropriate,but in most cases you will need to decide these on your own,based on business requirements and existing performance benchmarks.
JVM INTERNALS
Foundations
Code compilation and JIT
Java byte code interpretation is clearly not as fast as native code executed directly from the host. In order to improve performance,the Hotspot JVM looks for the busiest areas of byte code and compiles these into native,more efficient,machine code (adaptive optimization). Such native code is then stored in the code cache in non-heap memory.
Note: most JVM implementations offer ways to disable the JIT compiler (Djava.compiler=NONE). You should only consider disabling such crucial optimization in the event of unexpected JIT problems such as JVM crashes.
The following diagram illustrates the Java source code,just-in-time compilation processes and life cycle.
Memory spaces
The HotSpot Java Virtual Machine is composed of the following memory spaces.