Performance Improvement In Java Application

Similar documents
NetBeans Profiler is an

Trace-Based and Sample-Based Profiling in Rational Application Developer

Tool - 1: Health Center

An Oracle White Paper September Advanced Java Diagnostics and Monitoring Without Performance Overhead

Holly Cummins IBM Hursley Labs. Java performance not so scary after all

How To Use Java On An Ipa (Jspa) With A Microsoft Powerbook (Jempa) With An Ipad And A Microos 2.5 (Microos)

Instrumentation Software Profiling

Holistic Performance Analysis of J2EE Applications

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

IBM Software Group. SW5706 JVM Tools IBM Corporation 4.0. This presentation will act as an introduction to JVM tools.

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

Practical Performance Understanding the Performance of Your Application

How To Improve Performance On An Asa 9.4 Web Application Server (For Advanced Users)

Essentials of Java Performance Tuning. Dr Heinz Kabutz Kirk Pepperdine Sun Java Champions

HP NonStop JDBC Type 4 Driver Performance Tuning Guide for Version 1.0

Performance Analysis of Web based Applications on Single and Multi Core Servers

IBM Tivoli Composite Application Manager for WebSphere

CSE 403. Performance Profiling Marty Stepp

Garbage Collection in the Java HotSpot Virtual Machine

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

FileNet System Manager Dashboard Help

Java Virtual Machine Locks

THE BUSY DEVELOPER'S GUIDE TO JVM TROUBLESHOOTING

Zing Vision. Answering your toughest production Java performance questions

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

Garbage Collection in NonStop Server for Java

JProfiler: Code Coverage Analysis Tool for OMP Project

Spring 2011 Prof. Hyesoon Kim

What s Cool in the SAP JVM (CON3243)

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Toad for Oracle 8.6 SQL Tuning

Debugging Java performance problems. Ryan Matteson

Profiling and Testing with Test and Performance Tools Platform (TPTP)

Fundamentals of Java Programming

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

IT Best Practices Audit TCS offers a wide range of IT Best Practices Audit content covering 15 subjects and over 2200 topics, including:

Understand Performance Monitoring

Performance Measurement of Dynamically Compiled Java Executions

Java Coding Practices for Improved Application Performance

Oracle JRockit Mission Control Overview

Java Interview Questions and Answers

Effective Java Programming. measurement as the basis

B M C S O F T W A R E, I N C. BASIC BEST PRACTICES. Ross Cochran Principal SW Consultant

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Enterprise Performance Tuning: Best Practices with SQL Server 2008 Analysis Services. By Ajay Goyal Consultant Scalability Experts, Inc.

Java Troubleshooting and Performance

Java in Virtual Machines on VMware ESX: Best Practices

MS SQL Performance (Tuning) Best Practices:

Analyzing IBM i Performance Metrics

2015 ej-technologies GmbH. All rights reserved. JProfiler Manual

sql server best practice

ProfBuilder: A Package for Rapidly Building Java Execution Profilers Brian F. Cooper, Han B. Lee, and Benjamin G. Zorn

Java Garbage Collection Basics

MONITORING PERFORMANCE IN WINDOWS 7

picojava TM : A Hardware Implementation of the Java Virtual Machine

Tomcat Tuning. Mark Thomas April 2009

Performance Testing. Based on slides created by Marty Stepp

Top 10 reasons your ecommerce site will fail during peak periods

Best Practices for Deploying SSDs in a Microsoft SQL Server 2008 OLTP Environment with Dell EqualLogic PS-Series Arrays

J2EE-JAVA SYSTEM MONITORING (Wily introscope)

Crash Course in Java

Java's garbage-collected heap

DB2 for i. Analysis and Tuning. Mike Cain IBM DB2 for i Center of Excellence. mcain@us.ibm.com

Introduction to Java

2013 OTM SIG CONFERENCE Performance Tuning/Monitoring

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Throughput Capacity Planning and Application Saturation

Java Virtual Machine: the key for accurated memory prefetching

TDA - Thread Dump Analyzer

An Overview of Java. overview-1

IBM Tivoli Composite Application Manager for WebSphere

WebSphere Performance Monitoring & Tuning For Webtop Version 5.3 on WebSphere 5.1.x

A Practical Method to Diagnose Memory Leaks in Java Application Alan Yu

Restraining Execution Environments

Modifying Colors and Symbols in ArcMap

11.1 inspectit inspectit

CS11 Java. Fall Lecture 7

PRODUCT OVERVIEW SUITE DEALS. Combine our award-winning products for complete performance monitoring and optimization, and cost effective solutions.

Web Services Performance: Comparing Java 2 TM Enterprise Edition (J2EE TM platform) and the Microsoft.NET Framework

How To Manage An Sap Solution

Explain the relationship between a class and an object. Which is general and which is specific?

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Replication on Virtual Machines

Chapter 1 Fundamentals of Java Programming

1 The Java Virtual Machine

Contents. 2. cttctx Performance Test Utility Server Side Plug-In Index All Rights Reserved.

An Oracle White Paper August, Oracle JDBC Memory Management

Get an Easy Performance Boost Even with Unthreaded Apps. with Intel Parallel Studio XE for Windows*

Monitoring Software using Sun Spots. Corey Andalora February 19, 2008

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Monitoring Agent for PostgreSQL Fix Pack 10. Reference IBM

SmartArrays and Java Frequently Asked Questions

Each of the advisory has a health level indicating severity of the issue found, pattern, name, keyword and related advice.

Chapter 5 Names, Bindings, Type Checking, and Scopes

Discovering Performance Bottlenecks with the SAP JVM Profiler and SAP Memory Analyzer

HeapStats: Your Dependable Helper for Java Applications, from Development to Operation

Transcription:

Performance Improvement In Java Application Megha Fulfagar Accenture Delivery Center for Technology in India Accenture, its logo, and High Performance Delivered are trademarks of Accenture.

Agenda Performance Analysis of Java Application Performance Bottlenecks Performance Tuning in Java Java Performance Tuning Tools Developing High Performance Java Application Checklist Q&A

Performance Analysis of Java Application The goal of performance analysis in JAVA application is to determine which parts of a program require optimization to increase its execution speed or lower its memory usage. Primarily used for pro-active bottleneck identification. "fixing" Scenarios that are not meeting requirements/slas

Performance Bottleneck A Bottleneck can be any factor that prevents the system in meeting the performance target It is a resistance to the flow of data Bottleneck can be within any layer of the technology stack or the infrastructure Bottleneck? Bottleneck?

Performance Bottleneck In a given time instance only one bottleneck cause the system to under perform Strength of the chain is equal to the weakest link

Bottleneck Classification Software Application Layer Objects Methods Database Layer Query Locks Hardware Processor I/O Layer Memory Network Layer

Performance Problems In Java Two major performance problem in Java Application Excess Creation of Objects Excess Garbage Collection How to avoid these problems to eliminate performance bottlenecks?

Performance Tuning in Java Excess Object Creation Objects need to be created before they can be used, and garbage-collected when they are finished with. The more objects you use, the more garbage-cycling happens, the CPU cycle wasted. Each object creation is roughly as expensive as a malloc in C, or a new in C++, and there is no easy way of creating many objects together, so you cannot take advantage of efficiencies you get using bulk allocation.

Performance Tuning in Java Excess Object Creation Example : A Person object that holds a Name object, consisting of first name and last name and an Address object, with street, number, etc. These three objects can be collapsed down to just the Person object, with all the fields moved up to the Person class continue.

Performance Tuning in Java public class Person { private Name name; private Address address; } class Name { private String firstname; private String lastname; private String[] othernames; } class Address { private int house Number; private String housename; private String streetname; private String town; private String area; private String greater Area; private String country; private String postcode; }

Performance Tuning in Java These three classes collapse into one class: public class Person { private String firstname; private String lastname; private String[] othernames; private int housenumber; private String housename; private String streetname; private String town; private String area; private String greaterarea; private String country; private String postcode; }

Performance Tuning in Java Reuse Object Objects are expensive to create so it is reasonable to reuse the same object. This requires awareness of when not to create new object. Look at the object and consider whether it is possible to reset the fields and then reuse the object, rather than throw it away and create another Important for objects that are constantly used and discarded: for example, in graphics processing, objects such as Rectangles, Points, Colors, and Fonts are used and discarded all the time. Recycling these types of objects can certainly improve performance.

Performance Tuning in Java Manage Pool Of Objects While not using the retained objects, we are holding on to more memory than if we simply discarded those objects, and this reduces the memory available to create other objects. Balance the need to have some free memory available against the need to improve performance by reusing objects. The space taken by retaining objects for later reuse is significant only for very large collections, and you should certainly know which ones these are in your application.

Performance Tuning in Java Canonicalizing Objects This activity of replacing multiple copies of an object with just a few objects is often referred to as canonicalizing objects. Example: Boolean t1 = new Boolean(true); System.out.println(t1=!Boolean.TRUE); System.out.println(t1.==(Boolean.TRUE)); produces the output: false true

Performance Tuning in Java Enumerating constants Another canonicalization technique often used is replacing constant objects with integers this is called Enueration. Enumeration can provide both speed and memory advantages. The enumeration requires less memory than the equivalent strings and makes network transfers faster. Example: public interface GENDER { public static final int FEMALE=1; public static final int MALE=2; } Rather than use the strings "female" and "male", you should use a constant defined in an interface

Performance Tuning in Java Comparison verses Identity Comparisons are faster compared to identity Comparison can be used instead of the equality comparison. Example: you can use this.gender == FEMALE; instead of: this.gender.equals("female");

Performance Tuning in Java Avoid Excess Garbage Collection The canonicalization techniques are one way to avoid garbage collection fewer objects means less to garbage-collect. The pooling technique tends to reduce garbage-collection requirements, partly because you are creating fewer objects by reusing them, and partly because you deallocate memory less often by holding on to the objects you have allocated Reducing garbage collection by using primitive data type. Hold an object in a primitive data-type format rather than another format as primitive data type use less memory.

Performance Tuning in Java Lazy Initialization Technique of delaying object creation until the last possible moment. This technique is useful for avoiding unnecessary object creation when only a few objects are used although many possible objects can be created. Many objects that need to be created and initialized, and most of these objects will be used, but not immediately. In this case, it can be useful to spread out the load of object initialization so you don't get one large hit on the application. It may be better to let a background thread initialize all the objects slowly or to use lazy initialization to take many small or negligible hits, thus spreading the load over time.

Java Performance Tuning Tools There are many tools available in the market to analyze and monitor Java applications which help us to find which part of the code should be optimized. Some of them are listed below NetBean Profiler for analyzing java application JAMon Java application monitor. GCViewer - visualizes verbose garbage collection data generated by Sun and IBM Java Virtual Machines (JVM). HPjmeter specific to Methods/Object. HPjtune - JVM

Java Performance Tuning Tools NetBean Profiler for analyzing Java Applications

Java Performance Tuning Tools Introduction The NetBeans Profiler is a powerful tool that provides important information about the runtime behavior of an application. The NetBeans Profiler help in tracking. Thread state CPU performance Memory usage. Object Creation Method creation

Java Performance Tuning Tools Thread State Threads (Timeline) Shows current and historical thread state, updated as the application runs. Threads (Details) Shows a summary of thread state information for a single thread. Green: the thread is either running or is ready to run. Purple: the thread is sleeping; for example it called Thread.sleep(). Yellow: the thread is waiting in a call to Object.wait(). Red: the thread is blocked while trying to enter a synchronized block or method.

Java Performance Tuning Tools CPU Performance This tool have CPU snapshot contains the following tabs: Call Tree Displays the Calling Context Tree (CCT) showing the method call chain and the time/number of invocations for executing threads and methods in each context. (A context is a unique chain of method calls leading to the method's invocation.) Hot Spots Shows the total execution time and number of invocations for each method, irrespective of the context.

Java Performance Tuning Tools CPU Performance Combined view of Call tree and hotspot

Java Performance Tuning Tools Memory Usage This tools have snapshots contains the following tab: Allocated Objects: The number of objects that the NetBeans Profiler is actually monitoring. Live Objects: The number of the Allocated Objects that are still on the JVM's heap and are therefore taking up memory. Live Bytes: The two columns show the amount of heap memory being used by the Live Objects. One column displays a graph, the other displays text. Avg. Age: This value is calculated using the Live Objects. The age of each object is the number of garbage collections that it has survived. The sum of the ages divided by the number of Live Objects is the Avg. Age.

Java Performance Tuning Tools Memory Usage

Java Performance Tuning Tools Memory Usage

Developing High Performance Java Applications - Checklist Reduce the number of temporary objects being used, especially in loops. Avoid creating temporary objects within frequently called methods. Presize collection objects. Reuse objects where possible. Empty collection objects before reusing them. (Do not shrink them unless they are very large.) Use custom conversion methods for converting between data types (especially strings and streams) to reduce the number of temporary objects. Define methods that accept reusable objects to be filled in with data, rather than methods that return objects holding that data. (Or you can return immutable objects.)

Developing High Performance Java Applications - Checklist Canonicalize objects wherever possible. Compare canonicalized objects by identity. Use primitive data types instead of objects as instance variables. Preallocate storage for large collections of objects by mapping the instance variables into multiple arrays. Eliminate object-creation bottlenecks by moving object creation to an alternative time. Create objects early, when there is spare time in the application, and hold those objects until required. Use lazy initialization when there are objects or variables that may never be used, or when you need to distribute the load of creating objects.

The biggest difference between Time and Space is that you cant re-use Time Megha Fulfagar

Performance Improvement In Java Application Q & A

Thank You! Megha.fulfagar@accenture.com Accenture, its logo, and High Performance Delivered are trademarks of Accenture.