SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
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

Contenu connexe

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de Matthew McCullough

Plus de 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
 

Dernier

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Dernier (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
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
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
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!