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.
Join the DZone community and get the full member experience.
Join For Free1.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:
Voluntary: application threads voluntarily takes itself off the CPU as a result of locks or wating on IO
High values of this ==> indication of lock contention
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
https://technet.microsoft.com/en-us/library/bb490960.aspx
typeperf-cpu.txt
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
Published at DZone with permission of Cristian Chiovari, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Apache Kafka + Apache Flink = Match Made in Heaven
-
Building a Flask Web Application With Docker: A Step-by-Step Guide
-
Building the World's Most Resilient To-Do List Application With Node.js, K8s, and Distributed SQL
-
Getting Started With Kubernetes-Native CI/CD Pipelines
Comments