SlideShare a Scribd company logo
1 of 21
Download to read offline
Taming the
     JVM
Tuning Tools/Techniques

       Mike Prasad

  Or downright grimacing!
      ..can be adventurous!
Objectives
!   Application challenges
!   JVM Configuration
!   Heap Analysis Tools
!   Future/Alternate Solutions
!   Case Study
Application Challenges

!  Java environment dramatically
   changed


!  Multi-core, multi-GB environments


!  Understanding JVM important
Java Memory
!   Divided into two areas – Stack & Heap


Stack
  !   associated with methods
  !   intermediate calcs


Heap
  !   All objects created using “new” keyword
  !   GC responsible for cleaning dead/unwanted objects
  !   Heap sizes controlled by command line options
Java Garbage Collector

!   Objects either in young or tenured generations


!   Minor GC when young objects die


!   Surviving objects moved to tenured gen


!   Full GC when tenured gen needs to be collected
         http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
Generation Sizing

!  Default values typically used


!  This not always sufficient


!  Requires adjusting generation
   size
VM Options
New Space
Behavioral
Stack
-XX:NewSize
-XX:-UseConcMarkSweepGC    new gen heap size
                           old gen concurrent mark-sweep
-Xss
-XX:MaxNewSize
-XX:-UseParallelGC size
          set stack        parallel garbage collection
                           max new gen heap size
-XX:-UseSerialGC           serial garbage collection
-XX:NewRatio               ratio of new/old gen size

-XX:SurvivorRatio          eden/survivor space size
                            Heap

       Debugging            -Xms     initial heap size
        Perm Space
       -XX:-PrintConcurrentLocks
                      -Xmx maximum heap size
                               Prints concurrent           locks
         -XX:PermSize    initial perm size
       -XX:-PrintGCTimeStamps           Print timestamps at gc

                            -Xmn
         -XX:MaxPermSize max perm generation heap size
       -XX:-PrintTenuringDistributionyoung size
                                        Print tenuring age info


         -Xnoclassgc              eliminates load/unload overhead
Memory Analysis Tools
!   JMap
!   JConsole
!   Visual GC
!   JRockit Mission Control
!   Others
   !   JStat
   !   HPROF
jmap
!   Prints memory–related statistics


!   Other options
  !   –heap
  !   –histo
  !   -permstat



!   To programmatically monitor use:
   - java.lang.Runtime.totalMemory()

   - java.lang.Runtime.freeMemory()
jmap-heap

 Used to obtain :
   !   gc name
   !   algorithm details
     !   #threads used for parallel gc
     !   heap configuration
     !   heap usage summary
jmap -histo
!  Class-wise histogram of the heap


!  Prints out:
  !  the number of instances
  !  total amount of memory consumed
  !  the fully qualified class name
jmap -permstat

!   Get perm gen statistics


!   Configuring perm gen size important


!   Web apps load large number of classes
    (JPs etc)


!   “too many” classes = OutOfMemoryError
JConsole

!   Monitoring and management tool


!   JMX–compliant attaches to a running JVM


!   JDK 5.0 and above
Visual GC

!   Monitors
   !   Garbage Collector
   !   Compiler
   !   Class loader



!   Superior to JConsole
JRockit Mission Control

!   Associated with JRockit JVM


!   Tool Suite :
  –  visualize gc and other perf stats
  –  runtime performance profiling tool
  –  memory-analysis tool
Future
!   G1 a new GC in JDK 7


Supports
  !   Parallelism : Uses all available CPUs


  !   Generational: same as HotSpot GC's


  !   Compaction   : performs heap compaction
Appliance Solution

!   Theoretical heap limit of 32-bit JVM is 4G


!   Azul appliance provides
  !   hardware-assisted pauseless gc feature


!   Up to 864 cores with 768GB heap!


!   Xfer workload from app server to appliance
Case Study

!  JEE App – Struts/EJB
!  On WebLogic
!  High volume app
!  Overnight performance issues
!  Full GCs every 1.5 minutes
Case Study
Original VM Settings
  Attempted # of Settings
     -Server
  -XX:-UseConcMarkSweepGC
      –Xms2048M
ProblemPizza + ?
        solved Coke = solution
  -XX:-UseParallelGC
      –Xmx2048M
         ,    , нет , nein, αριθ.
  -XX:-UseHailMaryGC (made it
     –Xmn512M                       worse!)

       Problem was with the code!
Moral FinallyStory
            Of the
Apply rigor forJVM, test, the developer! test
 Don’t lookthe unit tamein the wrong place!
     Spare  –    garbage  profile, load




               Why women live longer!
Taming The JVM

More Related Content

Viewers also liked (8)

Futuristic programing language
Futuristic programing languageFuturistic programing language
Futuristic programing language
 
Job Hunting Under Duress
Job Hunting Under DuressJob Hunting Under Duress
Job Hunting Under Duress
 
E-Commerce Thrills and Spills
E-Commerce Thrills and SpillsE-Commerce Thrills and Spills
E-Commerce Thrills and Spills
 
Agile Estimation
Agile EstimationAgile Estimation
Agile Estimation
 
Using Git and GitHub Effectively at Emerge Interactive
Using Git and GitHub Effectively at Emerge InteractiveUsing Git and GitHub Effectively at Emerge Interactive
Using Git and GitHub Effectively at Emerge Interactive
 
Principles Of Programing Languages
Principles Of Programing LanguagesPrinciples Of Programing Languages
Principles Of Programing Languages
 
Git Going With DVCS v1.1
Git Going With DVCS v1.1Git Going With DVCS v1.1
Git Going With DVCS v1.1
 
Adam Smith Builds an App
Adam Smith Builds an AppAdam Smith Builds an App
Adam Smith Builds an App
 

Similar to Taming The JVM

Tomcatx troubleshooting-production
Tomcatx troubleshooting-productionTomcatx troubleshooting-production
Tomcatx troubleshooting-production
Vladimir Khokhryakov
 
Inside The Java Virtual Machine
Inside The Java Virtual MachineInside The Java Virtual Machine
Inside The Java Virtual Machine
elliando dias
 

Similar to Taming The JVM (20)

Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUG
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo7 jvm-arguments-Confoo
7 jvm-arguments-Confoo
 
JVM Magic
JVM MagicJVM Magic
JVM Magic
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
Native Code, Off-Heap Data & JSON Facet API for Solr (Heliosearch)
Native Code, Off-Heap Data & JSON Facet API for Solr (Heliosearch)Native Code, Off-Heap Data & JSON Facet API for Solr (Heliosearch)
Native Code, Off-Heap Data & JSON Facet API for Solr (Heliosearch)
 
Garbage Collection of Java VM
Garbage Collection of Java VMGarbage Collection of Java VM
Garbage Collection of Java VM
 
jvm goes to big data
jvm goes to big datajvm goes to big data
jvm goes to big data
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
HotSpot JVM Tuning
HotSpot JVM TuningHotSpot JVM Tuning
HotSpot JVM Tuning
 
Tomcatx troubleshooting-production
Tomcatx troubleshooting-productionTomcatx troubleshooting-production
Tomcatx troubleshooting-production
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
 
Inside The Java Virtual Machine
Inside The Java Virtual MachineInside The Java Virtual Machine
Inside The Java Virtual Machine
 
Jvm problem diagnostics
Jvm problem diagnosticsJvm problem diagnostics
Jvm problem diagnostics
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory UsageChoosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 

More from Matthew McCullough

More from Matthew McCullough (20)

All About GitHub Pull Requests
All About GitHub Pull RequestsAll About GitHub Pull Requests
All About GitHub Pull Requests
 
Git's Filter Branch Command
Git's Filter Branch CommandGit's Filter Branch Command
Git's Filter Branch Command
 
Git Graphs, Hashes, and Compression, Oh My
Git Graphs, Hashes, and Compression, Oh MyGit Graphs, Hashes, and Compression, Oh My
Git Graphs, Hashes, and Compression, Oh My
 
Git and GitHub at the San Francisco JUG
 Git and GitHub at the San Francisco JUG Git and GitHub at the San Francisco JUG
Git and GitHub at the San Francisco JUG
 
Finding Things in Git
Finding Things in GitFinding Things in Git
Finding Things in Git
 
Git and GitHub for RallyOn
Git and GitHub for RallyOnGit and GitHub for RallyOn
Git and GitHub for RallyOn
 
Migrating from Subversion to Git and GitHub
Migrating from Subversion to Git and GitHubMigrating from Subversion to Git and GitHub
Migrating from Subversion to Git and GitHub
 
Git Notes and GitHub
Git Notes and GitHubGit Notes and GitHub
Git Notes and GitHub
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Build Lifecycle Craftsmanship for the Transylvania JUG
Build Lifecycle Craftsmanship for the Transylvania JUGBuild Lifecycle Craftsmanship for the Transylvania JUG
Build Lifecycle Craftsmanship for the Transylvania JUG
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUG
 
Transylvania JUG Pre-Meeting Announcements
Transylvania JUG Pre-Meeting AnnouncementsTransylvania JUG Pre-Meeting Announcements
Transylvania JUG Pre-Meeting Announcements
 
Game Theory for Software Developers at the Boulder JUG
Game Theory for Software Developers at the Boulder JUGGame Theory for Software Developers at the Boulder JUG
Game Theory for Software Developers at the Boulder JUG
 
Cascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUGCascading Through Hadoop for the Boulder JUG
Cascading Through Hadoop for the Boulder JUG
 
JQuery Mobile
JQuery MobileJQuery Mobile
JQuery Mobile
 
R Data Analysis Software
R Data Analysis SoftwareR Data Analysis Software
R Data Analysis Software
 
Please, Stop Using Git
Please, Stop Using GitPlease, Stop Using Git
Please, Stop Using Git
 
Dr. Strangedev
Dr. StrangedevDr. Strangedev
Dr. Strangedev
 
Jenkins for One
Jenkins for OneJenkins for One
Jenkins for One
 
Lean Fluffy Startups
Lean Fluffy StartupsLean Fluffy Startups
Lean Fluffy Startups
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

Taming The JVM

  • 1. Taming the JVM Tuning Tools/Techniques Mike Prasad Or downright grimacing! ..can be adventurous!
  • 2. Objectives !   Application challenges !   JVM Configuration !   Heap Analysis Tools !   Future/Alternate Solutions !   Case Study
  • 3. Application Challenges !  Java environment dramatically changed !  Multi-core, multi-GB environments !  Understanding JVM important
  • 4. Java Memory !   Divided into two areas – Stack & Heap Stack !   associated with methods !   intermediate calcs Heap !   All objects created using “new” keyword !   GC responsible for cleaning dead/unwanted objects !   Heap sizes controlled by command line options
  • 5. Java Garbage Collector !   Objects either in young or tenured generations !   Minor GC when young objects die !   Surviving objects moved to tenured gen !   Full GC when tenured gen needs to be collected http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
  • 6. Generation Sizing !  Default values typically used !  This not always sufficient !  Requires adjusting generation size
  • 7. VM Options New Space Behavioral Stack -XX:NewSize -XX:-UseConcMarkSweepGC new gen heap size old gen concurrent mark-sweep -Xss -XX:MaxNewSize -XX:-UseParallelGC size set stack parallel garbage collection max new gen heap size -XX:-UseSerialGC serial garbage collection -XX:NewRatio ratio of new/old gen size -XX:SurvivorRatio eden/survivor space size Heap Debugging -Xms initial heap size Perm Space -XX:-PrintConcurrentLocks -Xmx maximum heap size Prints concurrent locks -XX:PermSize initial perm size -XX:-PrintGCTimeStamps Print timestamps at gc -Xmn -XX:MaxPermSize max perm generation heap size -XX:-PrintTenuringDistributionyoung size Print tenuring age info -Xnoclassgc eliminates load/unload overhead
  • 8. Memory Analysis Tools !   JMap !   JConsole !   Visual GC !   JRockit Mission Control !   Others !   JStat !   HPROF
  • 9. jmap !   Prints memory–related statistics !   Other options !   –heap !   –histo !   -permstat !   To programmatically monitor use: - java.lang.Runtime.totalMemory() - java.lang.Runtime.freeMemory()
  • 10. jmap-heap Used to obtain : !   gc name !   algorithm details !   #threads used for parallel gc !   heap configuration !   heap usage summary
  • 11. jmap -histo !  Class-wise histogram of the heap !  Prints out: !  the number of instances !  total amount of memory consumed !  the fully qualified class name
  • 12. jmap -permstat !   Get perm gen statistics !   Configuring perm gen size important !   Web apps load large number of classes (JPs etc) !   “too many” classes = OutOfMemoryError
  • 13. JConsole !   Monitoring and management tool !   JMX–compliant attaches to a running JVM !   JDK 5.0 and above
  • 14. Visual GC !   Monitors !   Garbage Collector !   Compiler !   Class loader !   Superior to JConsole
  • 15. JRockit Mission Control !   Associated with JRockit JVM !   Tool Suite : –  visualize gc and other perf stats –  runtime performance profiling tool –  memory-analysis tool
  • 16. Future !   G1 a new GC in JDK 7 Supports !   Parallelism : Uses all available CPUs !   Generational: same as HotSpot GC's !   Compaction : performs heap compaction
  • 17. Appliance Solution !   Theoretical heap limit of 32-bit JVM is 4G !   Azul appliance provides !   hardware-assisted pauseless gc feature !   Up to 864 cores with 768GB heap! !   Xfer workload from app server to appliance
  • 18. Case Study !  JEE App – Struts/EJB !  On WebLogic !  High volume app !  Overnight performance issues !  Full GCs every 1.5 minutes
  • 19. Case Study Original VM Settings Attempted # of Settings -Server -XX:-UseConcMarkSweepGC –Xms2048M ProblemPizza + ? solved Coke = solution -XX:-UseParallelGC –Xmx2048M , , нет , nein, αριθ. -XX:-UseHailMaryGC (made it –Xmn512M worse!) Problem was with the code!
  • 20. Moral FinallyStory Of the Apply rigor forJVM, test, the developer! test Don’t lookthe unit tamein the wrong place! Spare – garbage profile, load Why women live longer!