Over a million developers have joined DZone.

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.

See Gartner’s latest research on the application performance monitoring landscape and how APM suites are becoming more and more critical to the business, brought to you in partnership with AppDynamics.

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

The Performance Zone is brought to you in partnership with AppDynamics.  See Gartner’s latest research on the application performance monitoring landscape and how APM suites are becoming more and more critical to the business.

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.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}