Java performance tuning
-
Upload
shivaji-chelladurai -
Category
Technology
-
view
599 -
download
4
description
Transcript of Java performance tuning
![Page 1: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/1.jpg)
Java Performance TuningTop Down Approach
![Page 2: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/2.jpg)
Symptoms Memory CPU I/O
Devices Network
![Page 3: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/3.jpg)
Indicators - Windows
![Page 4: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/4.jpg)
Indicators - Linux Sar, top, dstat,etc.
![Page 5: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/5.jpg)
Jumping Board - JConsole Study the JVM Args Heap Usage should follow a saw tooth pattern
denoting there is no leak There should not be any anonymous threads like
‘Thread 1’ Look for creation of dynamic classes in large numbers CPU Usage
![Page 6: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/6.jpg)
Heap ? Heap is utilized throughout the Object Lifecycle starting from new object
creation, variable references, dereferences by variables going out of scope and finally till Garbage Collection
Object references can be represented in a tree fashion as we do deep references and the cumulative size retained at each level can be determined using offline utilities
There can multiple top level objects in the current program flow context that can retain individual object tree
A parent node should be shallow in size such that it does not retain memory compared to its child nodes
When there is a large difference in retained size between parent and child node, i.e drops, there is a possibility of memory leak
![Page 7: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/7.jpg)
Deep Dive – Heap Analysis Online
VisualVM, JRockit, IBM Health Center Profilers
Offline IBM Heap Analyzer Eclipse MAT
![Page 8: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/8.jpg)
Deep Dive – Memory Leaks
![Page 9: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/9.jpg)
CPU ? Thread dumps provides thread status, monitors,
number of threads waiting for the monitor and call stack of methods
Comparing thread dumps taken at frequent intervals can reveal as to which tasks (call stack) are being performed across thread dumps
Online profiling tools can provide hotspot methods Snapshots can provide thread wise call tree, along
with response time
![Page 10: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/10.jpg)
Deep Dive – Threads & Call Stack Online
VisualVM, JRockit, IBM Health Center Profilers
Offline IBM Thread and Monitor Dump Analyzer
![Page 11: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/11.jpg)
Deep Dive – Threads & Call Stack
![Page 12: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/12.jpg)
I/O ?
Study the read, writes and response time of the Java process and identify the device that is heavily utilized or not responding
Study the network traffic in terms of number of connections, bytes sent / received and transfer rate
![Page 13: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/13.jpg)
Deep Dive – I/O
Based on the heavy reads / writes look for input and output streams without buffering, multiple reads of same resources, unnecessary serialization, etc
Re-use of connection, file transfer in uncompressed form, releasing network resources (such as result set, statement and connection), etc
![Page 14: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/14.jpg)
Performance Case Study - Heap Source -
http://javaeesupportpatterns.blogspot.in/2012/07/5-tips-for-proper-java-heap-size.html
![Page 15: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/15.jpg)
Performance Case Study - CPU Loading of DTM Manager for every
XPath Evaluation
Source http://stackoverflow.com/questions/6340802/java-xpath-apache-jaxp-implementation-performance
![Page 16: Java performance tuning](https://reader035.fdocuments.us/reader035/viewer/2022081716/5482a788b4af9f175f8b45f7/html5/thumbnails/16.jpg)
Best Practices
Understand your application environment such as firewall, layers (web, app & db), third party data providers if any
Use offline tools and less intrusive tools in production environments
Look for tools provided by the JVM vendor or the Application Server vendor
Use JMeter for recreating production scenario in your environment