Fundamental Concepts and Definitions of Java Performance Tuning

DZone 's Guide to

Fundamental Concepts and Definitions of Java Performance Tuning

Want to learn more about Java performance? Here are some really helpful fundamental concepts and definitions of Java performance tuning.

· Performance Zone ·
Free Resource

1.1) JDK vs JRE

  • JRE = JVM + Class libraries

  • JDK = JRE + developer tools (javac, jconsole etc)

  •  Server JRE (above Jre 7u21, no autoupdate )

1.2) Install the JDK

  • Windows

  • Linux64 : server JRE 64 bit

  • Solaris : in to steps first 32 and on top of that 64 bit version

1.3) Major Components of JVM

Hotspot VM Runtime:

  • Command line option parsing

  • JVM livecycle

  • Exception handling

  • Fatal exception handling

  • Class loading

  • Interpreter

  • Java native interface

  • Thread management and synchronization

Garbage Collector – Memory manager

  • Influence the performance of a java application

  • Hotspot JVM has 4 GC’s:

    • Two are known as ‘stop the world moment’ (STW GC) garbage collectors, the other two are a
       combination of STW and concurrent GC

STW GC==> stops all java application threads.

Mostly concurrent GC ==> concurrenlty executes while java application is running

Young gen. vs Old gen.

  • Perm Gen (Java 6&7) class metadata, class data structures. PermGen does not exist in Java 8, just metaspace.

GC in hotspot:

  • Serial GC, single threaded STW young generation collector + single threaded STW old gen collector

(Small Footprint)

  • Throughput GC, multithreaded STW young + old gen collectorCMS concurrent garbage collector, STW young and , mostly concurrent old generation

  •  G1 garbage collector (>jdk7u4) multithreaded STW region based young GC + combination of STW and mostly

  • Concurrent old generation GC: G1vs CMS ==> G1 compact old gen without requiring a Full GC

JIT compiler

  • Takes bytecode ==> native code for the undelying platform.

Understanding the Runtime System

  • Java -XX:+PrintFlagsFinal -version ==> to see the runtime params of JVM

  • Visual GC plugin on VisualVM

  • Memory Pools plugin

Code Cache – The Amount of Code That is JIT Compiled

  • For large enterprise application, code cache space might be exhausted so the application slows down because it disables the JIT compilation

Metrics to Monitor

  • OS level

  • JVM

  • Application

OS Level

-CPU usage : user CPU, system CPU and idle time
User CPU : time spent outside OS kernel by a program
Kernel (System) SPU – % spent executing kernel code
Idle CPU – % of CPU not being utilized
Goal is to execute more user CPU

-Virtual Memory Usage
Attention to swapping!!!

-Process behaviour: context switching, CPU scheduling, and thread migrations

Two Kinds of Context Switching:

  1. Voluntary: application threads voluntarily takes itself off the CPU as a result of locks or wating on IO

    1. High values of this ==> indication of lock contention

  2. Involuntary:==> there are a large number of application threads more than the CPU cores available

CPU scheduling queue —> large number of app. threads vs low number of CPU cores ==> system sluggish

Disk I/O

Network I/O

Monitor Metrics on Windows
PerfMon – Visual tool
Privileged time – kernel time


ex typeperf -si 5 -cf typeperf-cpu.txt

Monitoring CPU scheduling

Monitorign virtual Memory Usage

Monitoring avalable memory and paging activity

If paging is too often ==> swapping http://en.wikipedia.org/wiki/Paging

performance ,java ,java performance

Published at DZone with permission of Cristian Chiovari , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}