SlideShare uma empresa Scribd logo
1 de 60
Baixar para ler offline
A D I G I TA L C O M M E R C E C O N S U LTA N C Y
Basics of JVM Tuning
... because out-of-the-box is often not enough


                    Vladislav Gangan
                    Vice President of Engineering
                    Tacit Knowledge, Moldova
AGENDA

 • Basics of JVM memory management
 • Optimal starting settings for tuning
 • Garbage collection algorithms
 • Debugging the garbage collection process
 • Putting theory in practice
RATIONALE BEHIND THE NEED OF JVM TUNING
TWO AREAS OF MEMORY - STACK
• scratch space for thread
execution

• easy to track internally
• any method call results in
block allocation
   • local vars
   • bookkeeping data
• always LIFO allocation
TWO AREAS OF MEMORY - STACK
• scratch space for thread
execution

• easy to track internally
                               m2 vars
• any method call results in
block allocation               m1 vars
   • local vars
   • bookkeeping data
• always LIFO allocation
TWO AREAS OF MEMORY - STACK
• scratch space for thread
execution

• easy to track internally
                                free
• any method call results in
block allocation               m1 vars
   • local vars
   • bookkeeping data
• always LIFO allocation
TWO AREAS OF MEMORY - STACK
• scratch space for thread
execution

• easy to track internally
                               m3 vars
• any method call results in
block allocation               m1 vars
   • local vars
   • bookkeeping data
• always LIFO allocation
TWO AREAS OF MEMORY - STACK
• scratch space for thread
execution

• easy to track internally     m4 vars
• any method call results in   m3 vars
block allocation
   • local vars                m1 vars
   • bookkeeping data
• always LIFO allocation
TWO AREAS OF MEMORY - HEAP

• dynamic & random memory
allocation

• much more complex to
handle

• can result in memory leaks if
objects not destroyed properly
   • shielded from the
   developer by the JVM
TWO AREAS OF MEMORY - HEAP

• dynamic & random memory
allocation                        o1

• much more complex to
handle

• can result in memory leaks if
objects not destroyed properly
   • shielded from the
   developer by the JVM
TWO AREAS OF MEMORY - HEAP

• dynamic & random memory
allocation                        o1

• much more complex to                 o2
handle

• can result in memory leaks if
objects not destroyed properly
   • shielded from the
   developer by the JVM
TWO AREAS OF MEMORY - HEAP

• dynamic & random memory
allocation                        o1

• much more complex to                 o2   o3
handle

• can result in memory leaks if
objects not destroyed properly
   • shielded from the
   developer by the JVM
HEAP STRUCTURE




   Eden   S0   S1   Tenured   Permanent
GENERATIONAL OBJECT FLOW
GENERATIONAL OBJECT FLOW
GENERATIONAL OBJECT FLOW
GENERATIONAL OBJECT FLOW
GENERATIONAL OBJECT FLOW




  Minor collection
GARBAGE COLLECTION ELIGIBILITY




Reachability test - can an object be reached from any live
               pointer in the application?
GARBAGE COLLECTION TYPES


  • Minor collection
    • operates on young space
    • low impact on performance
  • Major collection
    • operates on entire heap
    • very costly performance wise
    • some algorithms are “stop-the-world” activity
JVM TUNING PROCESS

  while (iAmNotSatisfied)
  {
    size = defineMinMaxHeapSize();
    ratios = fineTuneGenerationsRatios();
    alg = selectAppropriateGcAlgotrithm();
    loadTestTheApplication(size, ratios, alg);
    iAmNotSatisfied = analyzeStatistics();
  }
HEAP SIZE CONFIG OPTIONS



  -Xms - initial heap size
  -Xmx - max/final heap size

  java -Xms123m -Xmx456m MyApp
HEAP SIZE DEFAULTS

                       Non-server class
                      machine (or 32-bit
      Heap setting                        Server class machine
                     Windows) or prior to
                         to J2SE 5.0

                                              1/64 of
        -Xms               4 MB               physical
                                            (up to 1 GB)

                                          1/4 of physical
        -Xmx              64 MB
                                           (up to 1 GB)
HEAP SIZE DEFAULTS

                        Non-server class
                                                      fo r
       Heap setting          te
                       machine (or 32-bit
                           a s
                      Windows) or prior to
                                           Server class machine
                         u p
                        q p
                          to J2SE 5.0
                       e a of
                      d l 1/64
                     a e
                  i4n ev physical
        -Xms     s MB l (up to 1 GB)
                e e
              im ris
             t p
           n r
         te te 64 MB 1/4 of physical
       f-Xmx
      O en                (up to 1 GB)
FINDING MAX HEAP SIZE




  • observe application under consistent load
  • then add supplementary 25-30% to peak value
  • do not exceed 2 GB value (so say the experts)
FINDING INITIAL HEAP SIZE
FINDING INITIAL HEAP SIZE


  assign it equal to the max size, and here’s why:
FINDING INITIAL HEAP SIZE


  assign it equal to the max size, and here’s why:

  • the heap will grow in the long run anyway
FINDING INITIAL HEAP SIZE


  assign it equal to the max size, and here’s why:

  • the heap will grow in the long run anyway
  • baking in the overhead of heap growth/
  resizing is viewed as irresponsible by the
  experts
CAVEATS ON 32-BIT SYSTEMS


  • requires contiguous unfragmented chunk of memory
  • 32-bit systems may not be able to allocate the desired size
   • 2-3 GB per process (Windows)
   • 3 GB per process (Linux)
   • some amount of memory is eaten up by OS and
   background processes
WHAT ARE THE OPTIONS?
SIZING HEAP GENERATIONS



  -XX:NewSize=123m

  -XX:MaxNewSize=123m

  -XX:SurvivorRatio=6
APPLICATION CONSIDERATIONS FOR HEAP GENERATIONS SIZES




   • reserve plenty of memory for young
   generation if creating lots of short-lived
   objects

   • favor tenured generation if making use
   of lots of long-lived objects
OPTIMAL SIZE FOR YOUNG GENERATION




      [⅓; ½)
WHAT ABOUT THAT SURVIVORRATIO FLAG?
WHAT ABOUT THAT SURVIVORRATIO FLAG?




   Eden   S0   S1   Tenured   Permanent
WHAT ABOUT THAT SURVIVORRATIO FLAG?



  • defaults to 1/34 of young generation
      • high risk of short-lived objects to migrate to
     tenured generation very fast

  • best if kept between [1/6; 1/12] of new space
      • -XX:SurvivorRatio=6 => 1/8
GARBAGE COLLECTION ALGORITHMS




 • serial
 • parallel
 • concurrent
SERIAL COLLECTOR


  • suitable only for single processor machines
  • relatively efficient
  • default on non-server class machines
  • -XX:+UseSerialGC
SERIAL COLLECTOR




   Application      GC    Application
    Threads        Stop    Threads
PARALLEL COLLECTOR


  • takes advantage of multiple CPUs/cores
  • performs minor collections in parallel
      • significantly improves performance in systems
     with lots of minor collections

  • default on server class machines
  • -XX:+UseParallelGC
PARALLEL COLLECTOR


  • major collections are still single threaded
  • -XX:+UseParallelOldGc
      • as of J2SE 5.0 update 6
      • allows parallel compaction which reduces heap
     fragmentation
     • allows major collections in parallel
PARALLEL COLLECTOR




   Application    GC    Application
    Threads      Stop    Threads
CONCURRENT COLLECTOR


 • performs most of its work concurrently
    • the goal is to keep GC pauses short
 • single GC thread that runs
 simultaneously with application threads

 • -XX:+UseConcMarkSweepGC
CONCURRENT COLLECTOR




                          App                   App
     App     Initial   Threads +             Threads +
                                    Remark
   Threads   Mark      Concurrent            Concurrent
                         Mark                  Sweep
WHICH COLLECTOR WORKS WELL IN MY CASE?

     Collector                 Best for:

                   Single processor machines + small
       Serial                    heaps

                    Multiprocessor machines + high
      Parallel    throughput (batch processing apps)


                  Fast processor machines + minimized
     Concurrent         response times (web apps)
GATHERING HEAP BEHAVIOR STATISTICS


  • -verbose:gc
  • -XX:+PrintGCDetails
  • -XX:+PrintHeapAtGC
  • -Xloggc:/path/to/gc/log/file
EXAMPLE
                            java -verbose:gc MyApp




33.357: [GC 25394K->18238K(130176K), 0.0148471 secs]
33.811: [Full GC 22646K->18501K(130176K), 0.1954419 secs]
EXAMPLE
                java -verbose:gc -XX:+PrintGCDetails MyApp




19.834: [GC 19.834: [DefNew: 9088K->960K(9088K), 0.0126103 secs]
        16709K->9495K(130112K), 0.0126960 secs]
20.424: [Full GC 20.424:
        [Tenured: 8535K->10032K(121024K), 0.1342573 secs] 13847K->10032K(130112K),
        [Perm : 12287K->12287K(12288K)], 0.1343551 secs]
EXAMPLE
     java -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC MyApp


18.645: [GC {Heap before GC invocations=16:
Heap
    def new generation! total 9088K, used 9088K [0x02a20000, 0x033f0000, 0x05180000)
       eden space 8128K, 100% used [0x02a20000, 0x03210000, 0x03210000)
       from space 960K, 100% used [0x03210000, 0x03300000, 0x03300000)
       to! space 960K,! 0% used [0x03300000, 0x03300000, 0x033f0000)
    tenured generation!total 121024K, used 7646K [0x05180000, 0x0c7b0000, 0x22a20000)
       the space 121024K,! 6% used [0x05180000, 0x058f7870, 0x058f7a00, 0x0c7b0000)
compacting perm gen total 11264K, used 11202K [0x22a20000, 0x23520000, 0x26a20000)
       the space 11264K, 99% used [0x22a20000, 0x23510938, 0x23510a00, 0x23520000)
No shared spaces configured.
ANALYSIS TOOLS

  • custom scripts
      • feed the output to spreadsheet processor & build
      charts

  • GCViewer - http://www.tagtraum.com/gcviewer.html
  • Gchisto - http://java.net/projects/gchisto/
  • VisualVM - http://visualvm.java.net
  • a host of other tools (commercial & freeware)
Let’s practice
RATIONALE BEHIND THE NEED OF JVM TUNING
Q&A
BIBLIOGRAPHY
BIBLIOGRAPHY
BIBLIOGRAPHY
BIBLIOGRAPHY
THANK YOU

Mais conteúdo relacionado

Mais procurados

Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOMLeon Chen
 
Tuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issuesTuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issuesSergey Podolsky
 
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 UsageJelastic Multi-Cloud PaaS
 
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 PresentationGC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 PresentationLudovic Poitou
 
JVM Garbage Collection Tuning
JVM Garbage Collection TuningJVM Garbage Collection Tuning
JVM Garbage Collection Tuningihji
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunningguest1f2740
 
G1 collector and tuning and Cassandra
G1 collector and tuning and CassandraG1 collector and tuning and Cassandra
G1 collector and tuning and CassandraChris Lohfink
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVMSimon Ritter
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage CollectionHaim Yadid
 
G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?C2B2 Consulting
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionHaribabu Nandyal Padmanaban
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Monica Beckwith
 
On heap cache vs off-heap cache
On heap cache vs off-heap cacheOn heap cache vs off-heap cache
On heap cache vs off-heap cachergrebski
 
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...Jelastic Multi-Cloud PaaS
 
Storing Cassandra Metrics
Storing Cassandra MetricsStoring Cassandra Metrics
Storing Cassandra MetricsChris Lohfink
 
Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4YanpingWang
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Dinakar Guniguntala
 

Mais procurados (20)

Fight with Metaspace OOM
Fight with Metaspace OOMFight with Metaspace OOM
Fight with Metaspace OOM
 
Tuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issuesTuning Java GC to resolve performance issues
Tuning Java GC to resolve performance issues
 
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
 
Java GC, Off-heap workshop
Java GC, Off-heap workshopJava GC, Off-heap workshop
Java GC, Off-heap workshop
 
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 PresentationGC Tuning in the HotSpot Java VM - a FISL 10 Presentation
GC Tuning in the HotSpot Java VM - a FISL 10 Presentation
 
JVM Garbage Collection Tuning
JVM Garbage Collection TuningJVM Garbage Collection Tuning
JVM Garbage Collection Tuning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
G1 collector and tuning and Cassandra
G1 collector and tuning and CassandraG1 collector and tuning and Cassandra
G1 collector and tuning and Cassandra
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
G1GC
G1GCG1GC
G1GC
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
 
On heap cache vs off-heap cache
On heap cache vs off-heap cacheOn heap cache vs off-heap cache
On heap cache vs off-heap cache
 
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...Elastic JVM  for Scalable Java EE Applications  Running in Containers #Jakart...
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
 
Storing Cassandra Metrics
Storing Cassandra MetricsStoring Cassandra Metrics
Storing Cassandra Metrics
 
Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4
 
optimizing_ceph_flash
optimizing_ceph_flashoptimizing_ceph_flash
optimizing_ceph_flash
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !
 

Destaque

Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance TunningTerry Cho
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterAttila Szegedi
 
Jvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUGJvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUGTomek Borek
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovZeroTurnaround
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvmhome
 
JVM- Java Virtual Machine
JVM- Java Virtual MachineJVM- Java Virtual Machine
JVM- Java Virtual MachineManasvi Mehta
 
Tune up Yarn and Hive
Tune up Yarn and HiveTune up Yarn and Hive
Tune up Yarn and Hiverxu
 
JVM Tuning and Profiling
JVM Tuning and ProfilingJVM Tuning and Profiling
JVM Tuning and ProfilingBhuvan Rawal
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9Simon Ritter
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningSimone Bordet
 

Destaque (17)

Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @Twitter
 
Jvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUGJvm tuning in a rush! - Lviv JUG
Jvm tuning in a rush! - Lviv JUG
 
What's Inside a JVM?
What's Inside a JVM?What's Inside a JVM?
What's Inside a JVM?
 
QSpiders - Memory (JVM architecture)
QSpiders - Memory (JVM architecture)QSpiders - Memory (JVM architecture)
QSpiders - Memory (JVM architecture)
 
Understanding JVM
Understanding JVMUnderstanding JVM
Understanding JVM
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir Ivanov
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
 
JVM- Java Virtual Machine
JVM- Java Virtual MachineJVM- Java Virtual Machine
JVM- Java Virtual Machine
 
JVM
JVMJVM
JVM
 
Tune up Yarn and Hive
Tune up Yarn and HiveTune up Yarn and Hive
Tune up Yarn and Hive
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Hive tuning
Hive tuningHive tuning
Hive tuning
 
JVM Tuning and Profiling
JVM Tuning and ProfilingJVM Tuning and Profiling
JVM Tuning and Profiling
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
 

Semelhante a Basics of JVM Tuning

[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on KubernetesBruno Borges
 
Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesBruno Borges
 
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...Flink Forward
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Anna Shymchenko
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheNicolas Poggi
 
High performace network of Cloud Native Taiwan User Group
High performace network of Cloud Native Taiwan User GroupHigh performace network of Cloud Native Taiwan User Group
High performace network of Cloud Native Taiwan User GroupHungWei Chiu
 
A Dataflow Processing Chip for Training Deep Neural Networks
A Dataflow Processing Chip for Training Deep Neural NetworksA Dataflow Processing Chip for Training Deep Neural Networks
A Dataflow Processing Chip for Training Deep Neural Networksinside-BigData.com
 
JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011Kris Mok
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...Chester Chen
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormJohn Georgiadis
 
Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)DataWorks Summit
 
#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future DesignPivotalOpenSourceHub
 
Memory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationMemory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationBigstep
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance TuningJeremy Leisy
 
HBase: Extreme makeover
HBase: Extreme makeoverHBase: Extreme makeover
HBase: Extreme makeoverbigbase
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8AppDynamics
 
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdfSHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdfssuser9f7ea5
 
CASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for successCASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for successErick Ramirez
 
Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014marvin herrera
 

Semelhante a Basics of JVM Tuning (20)

Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
Flink Forward Berlin 2017: Robert Metzger - Keep it going - How to reliably a...
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket Cache
 
High performace network of Cloud Native Taiwan User Group
High performace network of Cloud Native Taiwan User GroupHigh performace network of Cloud Native Taiwan User Group
High performace network of Cloud Native Taiwan User Group
 
A Dataflow Processing Chip for Training Deep Neural Networks
A Dataflow Processing Chip for Training Deep Neural NetworksA Dataflow Processing Chip for Training Deep Neural Networks
A Dataflow Processing Chip for Training Deep Neural Networks
 
JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011JVM @ Taobao - QCon Hangzhou 2011
JVM @ Taobao - QCon Hangzhou 2011
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and Storm
 
Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)
 
#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design
 
Memory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and VirtualizationMemory, Big Data, NoSQL and Virtualization
Memory, Big Data, NoSQL and Virtualization
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
HBase: Extreme makeover
HBase: Extreme makeoverHBase: Extreme makeover
HBase: Extreme makeover
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8
 
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdfSHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
 
CASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for successCASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for success
 
Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014
 

Último

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Basics of JVM Tuning

  • 1. A D I G I TA L C O M M E R C E C O N S U LTA N C Y
  • 2. Basics of JVM Tuning ... because out-of-the-box is often not enough Vladislav Gangan Vice President of Engineering Tacit Knowledge, Moldova
  • 3. AGENDA • Basics of JVM memory management • Optimal starting settings for tuning • Garbage collection algorithms • Debugging the garbage collection process • Putting theory in practice
  • 4. RATIONALE BEHIND THE NEED OF JVM TUNING
  • 5. TWO AREAS OF MEMORY - STACK • scratch space for thread execution • easy to track internally • any method call results in block allocation • local vars • bookkeeping data • always LIFO allocation
  • 6. TWO AREAS OF MEMORY - STACK • scratch space for thread execution • easy to track internally m2 vars • any method call results in block allocation m1 vars • local vars • bookkeeping data • always LIFO allocation
  • 7. TWO AREAS OF MEMORY - STACK • scratch space for thread execution • easy to track internally free • any method call results in block allocation m1 vars • local vars • bookkeeping data • always LIFO allocation
  • 8. TWO AREAS OF MEMORY - STACK • scratch space for thread execution • easy to track internally m3 vars • any method call results in block allocation m1 vars • local vars • bookkeeping data • always LIFO allocation
  • 9. TWO AREAS OF MEMORY - STACK • scratch space for thread execution • easy to track internally m4 vars • any method call results in m3 vars block allocation • local vars m1 vars • bookkeeping data • always LIFO allocation
  • 10. TWO AREAS OF MEMORY - HEAP • dynamic & random memory allocation • much more complex to handle • can result in memory leaks if objects not destroyed properly • shielded from the developer by the JVM
  • 11. TWO AREAS OF MEMORY - HEAP • dynamic & random memory allocation o1 • much more complex to handle • can result in memory leaks if objects not destroyed properly • shielded from the developer by the JVM
  • 12. TWO AREAS OF MEMORY - HEAP • dynamic & random memory allocation o1 • much more complex to o2 handle • can result in memory leaks if objects not destroyed properly • shielded from the developer by the JVM
  • 13. TWO AREAS OF MEMORY - HEAP • dynamic & random memory allocation o1 • much more complex to o2 o3 handle • can result in memory leaks if objects not destroyed properly • shielded from the developer by the JVM
  • 14. HEAP STRUCTURE Eden S0 S1 Tenured Permanent
  • 19. GENERATIONAL OBJECT FLOW Minor collection
  • 20. GARBAGE COLLECTION ELIGIBILITY Reachability test - can an object be reached from any live pointer in the application?
  • 21. GARBAGE COLLECTION TYPES • Minor collection • operates on young space • low impact on performance • Major collection • operates on entire heap • very costly performance wise • some algorithms are “stop-the-world” activity
  • 22. JVM TUNING PROCESS while (iAmNotSatisfied) { size = defineMinMaxHeapSize(); ratios = fineTuneGenerationsRatios(); alg = selectAppropriateGcAlgotrithm(); loadTestTheApplication(size, ratios, alg); iAmNotSatisfied = analyzeStatistics(); }
  • 23. HEAP SIZE CONFIG OPTIONS -Xms - initial heap size -Xmx - max/final heap size java -Xms123m -Xmx456m MyApp
  • 24. HEAP SIZE DEFAULTS Non-server class machine (or 32-bit Heap setting Server class machine Windows) or prior to to J2SE 5.0 1/64 of -Xms 4 MB physical (up to 1 GB) 1/4 of physical -Xmx 64 MB (up to 1 GB)
  • 25. HEAP SIZE DEFAULTS Non-server class fo r Heap setting te machine (or 32-bit a s Windows) or prior to Server class machine u p q p to J2SE 5.0 e a of d l 1/64 a e i4n ev physical -Xms s MB l (up to 1 GB) e e im ris t p n r te te 64 MB 1/4 of physical f-Xmx O en (up to 1 GB)
  • 26. FINDING MAX HEAP SIZE • observe application under consistent load • then add supplementary 25-30% to peak value • do not exceed 2 GB value (so say the experts)
  • 28. FINDING INITIAL HEAP SIZE assign it equal to the max size, and here’s why:
  • 29. FINDING INITIAL HEAP SIZE assign it equal to the max size, and here’s why: • the heap will grow in the long run anyway
  • 30. FINDING INITIAL HEAP SIZE assign it equal to the max size, and here’s why: • the heap will grow in the long run anyway • baking in the overhead of heap growth/ resizing is viewed as irresponsible by the experts
  • 31. CAVEATS ON 32-BIT SYSTEMS • requires contiguous unfragmented chunk of memory • 32-bit systems may not be able to allocate the desired size • 2-3 GB per process (Windows) • 3 GB per process (Linux) • some amount of memory is eaten up by OS and background processes
  • 32. WHAT ARE THE OPTIONS?
  • 33. SIZING HEAP GENERATIONS -XX:NewSize=123m -XX:MaxNewSize=123m -XX:SurvivorRatio=6
  • 34. APPLICATION CONSIDERATIONS FOR HEAP GENERATIONS SIZES • reserve plenty of memory for young generation if creating lots of short-lived objects • favor tenured generation if making use of lots of long-lived objects
  • 35. OPTIMAL SIZE FOR YOUNG GENERATION [⅓; ½)
  • 36. WHAT ABOUT THAT SURVIVORRATIO FLAG?
  • 37. WHAT ABOUT THAT SURVIVORRATIO FLAG? Eden S0 S1 Tenured Permanent
  • 38. WHAT ABOUT THAT SURVIVORRATIO FLAG? • defaults to 1/34 of young generation • high risk of short-lived objects to migrate to tenured generation very fast • best if kept between [1/6; 1/12] of new space • -XX:SurvivorRatio=6 => 1/8
  • 39. GARBAGE COLLECTION ALGORITHMS • serial • parallel • concurrent
  • 40. SERIAL COLLECTOR • suitable only for single processor machines • relatively efficient • default on non-server class machines • -XX:+UseSerialGC
  • 41. SERIAL COLLECTOR Application GC Application Threads Stop Threads
  • 42. PARALLEL COLLECTOR • takes advantage of multiple CPUs/cores • performs minor collections in parallel • significantly improves performance in systems with lots of minor collections • default on server class machines • -XX:+UseParallelGC
  • 43. PARALLEL COLLECTOR • major collections are still single threaded • -XX:+UseParallelOldGc • as of J2SE 5.0 update 6 • allows parallel compaction which reduces heap fragmentation • allows major collections in parallel
  • 44. PARALLEL COLLECTOR Application GC Application Threads Stop Threads
  • 45. CONCURRENT COLLECTOR • performs most of its work concurrently • the goal is to keep GC pauses short • single GC thread that runs simultaneously with application threads • -XX:+UseConcMarkSweepGC
  • 46. CONCURRENT COLLECTOR App App App Initial Threads + Threads + Remark Threads Mark Concurrent Concurrent Mark Sweep
  • 47. WHICH COLLECTOR WORKS WELL IN MY CASE? Collector Best for: Single processor machines + small Serial heaps Multiprocessor machines + high Parallel throughput (batch processing apps) Fast processor machines + minimized Concurrent response times (web apps)
  • 48. GATHERING HEAP BEHAVIOR STATISTICS • -verbose:gc • -XX:+PrintGCDetails • -XX:+PrintHeapAtGC • -Xloggc:/path/to/gc/log/file
  • 49. EXAMPLE java -verbose:gc MyApp 33.357: [GC 25394K->18238K(130176K), 0.0148471 secs] 33.811: [Full GC 22646K->18501K(130176K), 0.1954419 secs]
  • 50. EXAMPLE java -verbose:gc -XX:+PrintGCDetails MyApp 19.834: [GC 19.834: [DefNew: 9088K->960K(9088K), 0.0126103 secs] 16709K->9495K(130112K), 0.0126960 secs] 20.424: [Full GC 20.424: [Tenured: 8535K->10032K(121024K), 0.1342573 secs] 13847K->10032K(130112K), [Perm : 12287K->12287K(12288K)], 0.1343551 secs]
  • 51. EXAMPLE java -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC MyApp 18.645: [GC {Heap before GC invocations=16: Heap def new generation! total 9088K, used 9088K [0x02a20000, 0x033f0000, 0x05180000) eden space 8128K, 100% used [0x02a20000, 0x03210000, 0x03210000) from space 960K, 100% used [0x03210000, 0x03300000, 0x03300000) to! space 960K,! 0% used [0x03300000, 0x03300000, 0x033f0000) tenured generation!total 121024K, used 7646K [0x05180000, 0x0c7b0000, 0x22a20000) the space 121024K,! 6% used [0x05180000, 0x058f7870, 0x058f7a00, 0x0c7b0000) compacting perm gen total 11264K, used 11202K [0x22a20000, 0x23520000, 0x26a20000) the space 11264K, 99% used [0x22a20000, 0x23510938, 0x23510a00, 0x23520000) No shared spaces configured.
  • 52. ANALYSIS TOOLS • custom scripts • feed the output to spreadsheet processor & build charts • GCViewer - http://www.tagtraum.com/gcviewer.html • Gchisto - http://java.net/projects/gchisto/ • VisualVM - http://visualvm.java.net • a host of other tools (commercial & freeware)
  • 54. RATIONALE BEHIND THE NEED OF JVM TUNING
  • 55. Q&A