jprofiler8 @ ovirt

25
Jprofiler 8 & OVIRT

Upload: liran-zelkha

Post on 05-Jul-2015

477 views

Category:

Technology


1 download

DESCRIPTION

Using JProfiler8 at the OVIRT project

TRANSCRIPT

Page 1: JProfiler8 @ OVIRT

Jprofiler 8 & OVIRT

Page 2: JProfiler8 @ OVIRT

Agenda

• Why profiling

• Installing Jprofiler

– Connecting Jprofiler to OVIRT

• Analyzing the results

– CPU analysis

– Memory analysis

– Threads analysis

– Database analysis

Page 3: JProfiler8 @ OVIRT

• "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil"

– Donald Knuth

Page 4: JProfiler8 @ OVIRT

Profiler

• Connects to running code and instruments the Java classes

• Application should run at least slower than without a profiler

• Gives a very good insight on what's going on inside our code

Page 5: JProfiler8 @ OVIRT

private static void test1() {

String s = "";

for (int i = 0; i < 100; ++i) {

s = s + "a";

}

}

private static void test2() {

StringBuffer sb = new StringBuffer();

for (int i = 0; i < 100; ++i) {

sb.append("a");

}

}

private static StringBuffer sb = new StringBuffer();

private static void test3() {

sb.setLength(0);

for (int i = 0; i < 100; ++i) {

sb.append("a");

}

}

Page 6: JProfiler8 @ OVIRT

Pretty Code vs. Fast Code

• What’s the clearer code?

• What’s the faster code?

Page 7: JProfiler8 @ OVIRT

Installing JProfiler

• We have licenses to Jprofiler 8.

• Contact me for serial number information

– We were asked not to publish S/N

Page 8: JProfiler8 @ OVIRT

OpenJDK Issues

• Install Oracle Java

• Update alternatives –config java or just the jprofiler.sh script

# Uncomment the following line to override the JVM search sequenceINSTALL4J_JAVA_HOME_OVERRIDE=~/jre1.7.0_25# Uncomment the following line to add additional VM parameters# INSTALL4J_ADD_VM_PARAMS=

Page 9: JProfiler8 @ OVIRT

Configuring OVIRT

• Jprofiler automatic configuration updates jboss’s script files.

• Since we use ovirt-engine service, add the following line:

• I added it directly in /etc/init.d/ovirt-engine under engineArgs.extend, but other options are possible too

-agentpath:/root/jprofiler8/bin/linux-x64/libjprofilerti.so=port=8849,nowait

Page 10: JProfiler8 @ OVIRT

Jprofiler main page

• Create a new session

Page 11: JProfiler8 @ OVIRT

Connection Page

Page 12: JProfiler8 @ OVIRT
Page 13: JProfiler8 @ OVIRT
Page 14: JProfiler8 @ OVIRT

Analyzing Information

• CPU– Check method execution time – only Runnable or

any state

• Memory– Who allocates which objects

• Threads– To check for thread leaks, dead-locks, etc.

• Database– To check for query execution time

Page 15: JProfiler8 @ OVIRT

CPU

• CPU View

• Hotspots

– Inherent Time vs Avg Execution Time vs Num Of Executions

Page 16: JProfiler8 @ OVIRT

CPU

Page 17: JProfiler8 @ OVIRT

CPU

Page 18: JProfiler8 @ OVIRT

Memory

• Allocated objects

• Monitor GC activity

Page 19: JProfiler8 @ OVIRT

Live Memory

Page 20: JProfiler8 @ OVIRT

Threads

• State

• Thread snapshot

Page 21: JProfiler8 @ OVIRT

Threads

Page 22: JProfiler8 @ OVIRT

Database Access

• Connection status

• Hot spots

Page 23: JProfiler8 @ OVIRT

Database

Page 24: JProfiler8 @ OVIRT

Other Monitoring Capabilities

• Network

• HTTP servlets

Page 25: JProfiler8 @ OVIRT

Alternatives

• Don’t want a profiler? That’s fine. Other tools exist (can also assist in production):

– Jmap

• Heap status

– Jstack

• Thread status

– verboseGC

• GC duration