Java Performance
           artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




Garbage Collection
Java Performance
                                                                                     2

                            artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




1) Garbage Collection
2) Garbage Collection Algorithm
3) Hotspot JVM   Garbage Collection

4) IBM JVM   Garbage Collection
Java Performance
                                                                          3
                       Java Performance Fundamental | twitter @novathinker
                                    artdb@ex-em.com | performeister.tistory.com
  Garbage Collection



• Garbage Collection
  – Garbage Collector
  –                     Unreferenced Memory
  –
  – Fragmentation


    “Heap storage for objects is reclaimed by an automatic
    storage management system (typically a garbage
    collector); objects are never explicitly deallocated.”
    - Java Virtual Machine Speculation, Section 3.5.3 [JVMS2
    1999]
Java Performance
                                                                           4
                        Java Performance Fundamental | twitter @novathinker
                                     artdb@ex-em.com | performeister.tistory.com
   Garbage Collection




     !
Garbage
Collector
Java Performance
                                                                           4
                        Java Performance Fundamental | twitter @novathinker
                                     artdb@ex-em.com | performeister.tistory.com
   Garbage Collection




     !                                                          object
Garbage
Collector
                                       Heap memory
                                                 .
Java Performance
                                                                           4
                        Java Performance Fundamental | twitter @novathinker
                                     artdb@ex-em.com | performeister.tistory.com
   Garbage Collection




     !                                                          object
Garbage
Collector
                                       Heap memory
                                                 .


                                               Garbage Collection
                                           Memory Recycling       Heap
                                       Fragmentation                           .
Java Performance
                                                                           4
                        Java Performance Fundamental | twitter @novathinker
                                     artdb@ex-em.com | performeister.tistory.com
   Garbage Collection




     !                                                            object
Garbage
Collector
                                       Heap memory
                                                 .


                                               Garbage Collection
                                           Memory Recycling       Heap
                                       Fragmentation                              .




 • JVM       heap          new, newarray, anewarray, multianewarray instruction
                                                    instruction
 • Garbage Collection
 • JVM       Spec                   Garbage Collection Algorithm
Java Performance
                                                                        5
                     Java Performance Fundamental | twitter @novathinker
                                  artdb@ex-em.com | performeister.tistory.com
Garbage Collection




                                  !
                             Garbage
                             Collector
Java Performance
                                                                        5
                     Java Performance Fundamental | twitter @novathinker
                                  artdb@ex-em.com | performeister.tistory.com
Garbage Collection




                                                                    Memory


                                  !                 Memory             System
                             Garbage
                             Collector
                                                      crash
                                                                .
Java Performance
                                                                           5
                        Java Performance Fundamental | twitter @novathinker
                                     artdb@ex-em.com | performeister.tistory.com
   Garbage Collection




                                                                       Memory


                                     !                 Memory             System
                                Garbage
                                Collector
                                                         crash
                                                                   .




Program

CPU Time        Scheduling

     .
Java Performance
                                                                          6
                       Java Performance Fundamental | twitter @novathinker
                                    artdb@ex-em.com | performeister.tistory.com
  Garbage Collection




• Garbage Collection
  – Garbage Collection
Java Performance
                                                                   7
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
Garbage Collection
Java Performance
                                                                   7
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
Garbage Collection




                           ROOT SET
Java Performance
                                                                     7
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Garbage Collection




                             ROOT SET




 Local Variable,
Operand Stack
Java Performance
                                                                     7
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Garbage Collection




                             ROOT SET




 Local Variable,
Operand Stack


                                   Class
                           Constant Pool
                              Reference
Java Performance
                                                                     7
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Garbage Collection




                             ROOT SET




 Local Variable,                                        Unreleased Native
Operand Stack                                               Method
                                                                Object
                                                           Reference
                                   Class
                           Constant Pool
                              Reference
Java Performance
                                                                         8
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
  Garbage Colletion



• Root Set
Java Performance
                                                                         9
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
  Garbage Colletion



• Memory Leak
class Main{
    public static void main (String args[]) {
       Leak lk = new Leak();
       for(int a=0; a<9000000; a++) {
          lk.addList(a);
          lk.removeStr(a);
       }
    }
}

class Leak {
     ArrayList lst = new ArrayList();
     public void addList(int a) {
         lst.add("                            "+a);
     }
     public void removeStr(int i) {
         Object obj = lst.get(i);
         obj = null;
     }
}
Java Performance
                                                                           9
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
  Garbage Colletion



• Memory Leak
class Main{
    public static void main (String args[]) {
       Leak lk = new Leak();
       for(int a=0; a<9000000; a++) {
          lk.addList(a);
          lk.removeStr(a);
       }
    }                                                          Why leak?
}

class Leak {
     ArrayList lst = new ArrayList();
     public void addList(int a) {
         lst.add("                            "+a);
     }
     public void removeStr(int i) {
         Object obj = lst.get(i);
         obj = null;
     }
}
Java Performance
                                                      10
   Java Performance Fundamental | twitter @novathinker
                artdb@ex-em.com | performeister.tistory.com




Garbage Collection
    Algorithm
Java Performance
                                                                                     11

                            artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




Garbage Collection Algorithm
1) Reference Counting Algorithm
2) Mark-and-Sweep Algorithm
3) Mark-and-Compacting Algorithm
4) Copying Algorithm
5) Generational Algorithm
6) Train Algorithm
7) Adaptive Algorithm
Java Performance
                                                                       12
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Garbage Collection Algorithm
Java Performance
                                                                       12
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Garbage Collection Algorithm



                       Garbage Object                     Detection
                             • Live Object : Root Set
                             •               Garbage Object
Java Performance
                                                                       12
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Garbage Collection Algorithm



                       Garbage Object                     Detection
                             • Live Object : Root Set
                             •               Garbage Object




      Garbage Object
             • Heap Memory Reclaim
Java Performance
                                                                         13
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




•   Reference Counting Algorithm
•   Mark-and-Sweep Algorithm
•   Copying Algorithm
•   Mark-and-Compacting Algorithm
•   Generational Algorithm
•   Train Algorithm
•   Adaptive Algorithm
Java Performance
                                                                       14
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Reference Counting Algorithm
  –                                 GC
  –         Object               Reference count
  – Reference Count                      0      GC
  –       Object                  GC        Object
      Object                                 Object           Count
                                         Count
Java Performance
                                                                      15
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
Garbage Collection Algorithm




                                                           Integer


                                                          RefCnt 00




                                                           Integer


                                                          RefCnt 00

                                                           Integer


                                                          RefCnt 00
Java Performance
                                                                       15
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                                            Integer
Object a = new Ingeter(1);

                                                           RefCnt 00




                                                            Integer


                                                           RefCnt 00

                                                            Integer


                                                           RefCnt 00
Java Performance
                                                                       15
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                                            Integer
Object a = new Ingeter(1);               a                     1
                                                           RefCnt 01
                                                                   0




                                                            Integer


                                                           RefCnt 00

                                                            Integer


                                                           RefCnt 00
Java Performance
                                                                       15
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                                            Integer
Object a = new Ingeter(1);               a                     1
Object b = a;                                              RefCnt 01
                                                                   0




                                                            Integer


                                                           RefCnt 00

                                                            Integer


                                                           RefCnt 00
Java Performance
                                                                       15
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                                            Integer
Object a = new Ingeter(1);               a                     1
Object b = a;                            b                 RefCnt 01
                                                                   0
                                                                   2




                                                            Integer


                                                           RefCnt 00

                                                            Integer


                                                           RefCnt 00
Java Performance
                                                                        15
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                                             Integer
Object a = new Ingeter(1);                a                     1
Object b = a;                             b                 RefCnt 01
                                                                    0
                                                                    2




                                                             Integer


Object a = new Ingeter(1);                                  RefCnt 00

                                                             Integer


                                                            RefCnt 00
Java Performance
                                                                        15
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                                             Integer
Object a = new Ingeter(1);                a                     1
Object b = a;                             b                 RefCnt 01
                                                                    0
                                                                    2




                                                             Integer

                                          a                     1
Object a = new Ingeter(1);                                          0
                                                            RefCnt 01
                                                             Integer


                                                            RefCnt 00
Java Performance
                                                                        15
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                                             Integer
Object a = new Ingeter(1);                a                     1
Object b = a;                             b                 RefCnt 01
                                                                    0
                                                                    2




                                                             Integer

                                          a                     1
Object a = new Ingeter(1);                                          0
                                                            RefCnt 01
Object b = new Ingeter(2);                                   Integer


                                                            RefCnt 00
Java Performance
                                                                        15
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                                             Integer
Object a = new Ingeter(1);                a                     1
Object b = a;                             b                 RefCnt 01
                                                                    0
                                                                    2




                                                             Integer

                                          a                     1
Object a = new Ingeter(1);                                          0
                                                            RefCnt 01
Object b = new Ingeter(2);                                   Integer
                                                                2
                                          b                 RefCnt 01
                                                                    0
Java Performance
                                                                        15
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                                             Integer
Object a = new Ingeter(1);                a                     1
Object b = a;                             b                 RefCnt 01
                                                                    0
                                                                    2




                                                             Integer

                                          a                     1
Object a = new Ingeter(1);                                          0
                                                            RefCnt 01
Object b = new Ingeter(2);                                   Integer
a = b;                                                          2
                                          b                 RefCnt 01
                                                                    0
Java Performance
                                                                        15
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                                             Integer
Object a = new Ingeter(1);                a                     1
Object b = a;                             b                 RefCnt 01
                                                                    0
                                                                    2




                                                             Integer

                                          a                     1
Object a = new Ingeter(1);                                          0
                                                            RefCnt 01
Object b = new Ingeter(2);                                   Integer
a = b;                                                          2
                                          b                 RefCnt 01
                                                                    0
                                                                    2
Java Performance
                                                                     16
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
Garbage Collection Algorithm
Java Performance
                                                                      16
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Object a = new TwoIngeter(new Integer(1), new Integer(2));
Java Performance
                                                                      16
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Object a = new TwoIngeter(new Integer(1), new Integer(2));




                                                           Integer
                                                             1
                                TwoInteger
                                                         RefCnt 00
                                                                 1
                                   ref
     a
                                RefCnt 00
                                        1                  Integer
                                                             2
                                                         RefCnt 01
                                                                 0
Java Performance
                                                                      16
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Object a = new TwoIngeter(new Integer(1), new Integer(2));

a = null;



                                                           Integer
                                                             1
                                TwoInteger
                                                         RefCnt 00
                                                                 1
                                   ref
     a
                                RefCnt 00
                                        1                  Integer
                                                             2
                                                         RefCnt 01
                                                                 0
Java Performance
                                                                      16
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Object a = new TwoIngeter(new Integer(1), new Integer(2));

a = null;



                                                           Integer
                                                             1
                                TwoInteger
                                                         RefCnt 00
                                                                 1
                                   ref
     a
                                RefCnt 00
                                        1                  Integer
                                                             2
                                                         RefCnt 01
                                                                 0
Java Performance
                                                                      16
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Object a = new TwoIngeter(new Integer(1), new Integer(2));

a = null;



                                                           Integer
                                                             1
                                TwoInteger
                                                         RefCnt 00
                                                                 1
                                   ref
     a                            GC
                                RefCnt 00
                                        1                  Integer
                                                             2
                                                         RefCnt 01
                                                                 0
Java Performance
                                                                      16
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Object a = new TwoIngeter(new Integer(1), new Integer(2));

a = null;



                                                           Integer
                                                             1
                                                         RefCnt 00
                                                                 1
     a
                                                           Integer
                                                             2
                                                         RefCnt 01
                                                                 0
                                                                 0
Java Performance
                                                                          17
                       Java Performance Fundamental | twitter @novathinker
                                    artdb@ex-em.com | performeister.tistory.com
     Garbage Collection Algorithm



• Reference Counting Algorithm


• Garbage Object
• Garbage
• Garbage Collector                                   (         )




• Reference Count
• Linked List                                     Reference Count   0
              Leak
Java Performance
                                                                           18
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




a


               Linked List
                 next ref
                RefCnt 02

                                      Linked List
                                        next ref
                                       RefCnt 11

                                                             Linked List
                                                              next ref
                                                              RefCnt 01
Java Performance
                                                                           18
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




a


               Linked List
                 next ref
                        2
                RefCnt 01

                                      Linked List
                                        next ref
                                       RefCnt 11

                                                             Linked List
                                                              next ref
                                                              RefCnt 01
Java Performance
                                                                       19
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Mark-and-Sweep Algorithm
  – Root Set                               Reference
  – Tracing Algorithm
  – Mark                         Sweep
       • Mark : Live Object                   Mark
         (Object     flag or                   bitmap table                  )
       • Sweep : Heap                Mark
Java Performance
                                                                          20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




R                          ref                ref                  ref
                            flag              flag                 flag



                           ref                ref                  ref
                            flag              flag                 flag



                           ref                ref                  ref
                             flag             flag                 flag
Java Performance
                                                                          20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




                                    Mark Phase
R                          ref                ref                  ref
                            flag              flag                 flag



                           ref                ref                  ref
                            flag              flag                 flag



                           ref                ref                  ref
                             flag             flag                 flag
Java Performance
                                                                         20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




                                    Mark Phase
R                          ref                ref                 ref
                      
                            flag          
                                              flag             
                                                                flag



                           ref                ref                 ref
                            flag              flag            
                                                                  flag



                           ref                ref                 ref
                             flag         
                                              flag             
                                                                flag
Java Performance
                                                                         20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




                                    Sweep Phase
R                          ref                ref                 ref
                      
                            flag          
                                              flag             
                                                                flag



                           ref                ref                 ref
                            flag              flag            
                                                                  flag



                           ref                ref                 ref
                             flag         
                                              flag             
                                                                flag
Java Performance
                                                                         20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




                                   Sweep Phase
R                          ref                ref                 ref
                      
                            flag          
                                              flag             
                                                                flag



                                                                  ref
                                                              
                                                                  flag



                                              ref                 ref
                                          
                                              flag             
                                                                flag
Java Performance
                                                                         20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




R                          ref                ref                 ref
                      
                            flag          
                                              flag             
                                                                flag



                                                                  ref
                                                              
                                                                  flag



                                              ref                 ref
                                          
                                              flag             
                                                                flag
Java Performance
                                                                          20
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




R                          ref                ref                  ref
                            flag              flag                 flag



                                                                   ref
                                                                   flag



                                              ref                  ref
                                              flag                 flag
Java Performance
                                                                          21
                       Java Performance Fundamental | twitter @novathinker
                                    artdb@ex-em.com | performeister.tistory.com
     Garbage Collection Algorithm




• Mark-and-Sweep Algorithm

• Reference
• Reference                             Overhead




• Suspend
• Fragmentation
          Memory
Java Performance
                                                                       22
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Mark-and-Compacting Algorithm
  – Fragmentation                    Memory
       Algorithm
  – Mark                         Compaction
       • Mark Phase : Live Object               Mark
       • Compaction : Live Object                         Memory


  –                         Handle
       • Mark Phase : Handle               Marking
       • Compaction : Object                     Handle Update
Java Performance
                                                                           23
                        Java Performance Fundamental | twitter @novathinker
                                     artdb@ex-em.com | performeister.tistory.com
      Garbage Collection Algorithm




 • Mark-and-Compacting Algorithm
     – Compaction
                                               Arbitrary                  Worst

                                               4 1 2 3
      1         2               3    4

                                               Linear

                                               1 3 4 2


• Arbitrary :                                  Sliding
• Linear :             Pointer
                                               1 2 3 4
• Sliding : Allocation
                                                                           Best
Java Performance
                                                                       24
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                2

        Handle
0     flag
1     flag        T22                       A     5           Z    1
2     flag        T11
3     flag        T12
                                            B     9          W     7
4     flag
5     flag        T21
6     flag                                  Q     3          C     2
7     flag        T31
8     flag
9     flag        T32
Java Performance
                                                                       24
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                2      Mark Phase
        Handle
0     flag
1     flag        T22                       A     5           Z    1
2     flag        T11
3     flag        T12
                                            B     9          W     7
4     flag
5     flag        T21
6     flag                                  Q     3          C     2
7     flag        T31
8     flag
9     flag        T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2      Mark Phase
         Handle
0      flag
1      flag        T22                       A     5           Z    1
  
2  flag            T11
3      flag        T12
                                             B     9          W     7
4      flag
  
5  flag            T21
6      flag                                  Q     3          C     2
7      flag        T31
8      flag
  
9  flag            T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2      Mark Phase
         Handle
0      flag
1      flag        T22                       A     5           Z    1
  
2  flag            T11
3      flag        T12
                                             B     9          W     7
4      flag
  
5  flag            T21
6      flag                                  Q     3          C     2
7      flag        T31
8      flag
  
9  flag            T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2      Mark Phase
         Handle
0      flag
1      flag        T22                       A     5           Z    1
  
2  flag            T11
3      flag        T12
                                             B     9          W     7
4      flag
  
5  flag            T21
6      flag                                  Q     3          C     2
7      flag        T31
8      flag
  
9  flag            T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2   Compation Phase
         Handle
0      flag
1      flag        T22                       A     5           Z    1
  
2  flag            T11
3      flag        T12
                                             B     9          W     7
4      flag
  
5  flag            T21
6      flag                                  Q     3          C     2
7      flag        T31
8      flag
  
9  flag            T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2   Compation Phase
         Handle
0      flag
1      flag        T22                       A     5
  
2  flag            T11
3      flag        T12
                                             B     9
4      flag
  
5  flag            T21
6      flag                                                   C     2
7      flag        T31
8      flag
  
9  flag            T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2   Compation Phase
         Handle
0      flag
1      flag        T22                       A     5           B    9
  
2  flag            T11
3      flag        T12
4      flag
  
5  flag            T12
                   T21
6      flag                                                   C     2
7      flag        T31
8      flag
  
9  flag            T32
Java Performance
                                                                        24
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




                                 2   Compation Phase
         Handle
0      flag
1      flag        T22                       A     5           B    9
  
2  flag            T11
3      flag        T12
                                              C     2
4      flag
  
5  flag            T12
                   T21
6      flag
7      flag        T31
8      flag
  
9  flag            T21
                   T32
Java Performance
                                                                       24
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




                                2

        Handle
0     flag
1     flag        T22                       A     5           B    9
2     flag        T11
3     flag        T12
                                             C     2
4     flag
5     flag        T12
                  T21
6     flag
7     flag        T31
8     flag
9     flag        T21
                  T32
Java Performance
                                                                        25
                     Java Performance Fundamental | twitter @novathinker
                                  artdb@ex-em.com | performeister.tistory.com
     Garbage Collection Algorithm




• Mark-and-Compacting Algorithm

• Fragmentation
• Memory




• Reference                    Object   Access    Overhead
• Suspend
Java Performance
                                                                       26
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Copying Algorithm
  – Stop-the-Copy Algorithm
  – Heap                 Active           Inactive

  – Active                        Object
  – Active                               Live Object          Inactive
    Copy
Java Performance
                                                                         27
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm



                                         Active Area

                                   A                            C



                                                B



R




                                          Inactive Area
Java Performance
                                                                         27
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm



                                          Active Area

                                    A                           C
                                   null                        null

                                                B
                                              null

R




                                          Inactive Area
Java Performance
                                                                         27
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm



                                         Active Area

                                   A                            C
                                                               null

                                                B
                                              null

R
                       A’
                      null




                                          Inactive Area
Java Performance
                                                                         27
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm



                                          Active Area

                                   A                            C
                                                               null

                                                B



R
                       A’           B’
                      null         null




                                          Inactive Area
Java Performance
                                                                         27
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm



                                          Active Area

                                   A                            C



                                                 B



R
                       A’           B’    C’
                      null         null   null




                                           Inactive Area
Java Performance
                                                                         27
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
    Garbage Collection Algorithm




                                          Inactive Area




R
                       A’           B’     C’
                      null         null   null




                                            Active Area
Java Performance
                                                                        28
                     Java Performance Fundamental | twitter @novathinker
    Garbage Collection Algorithm  artdb@ex-em.com | performeister.tistory.com




• Copying Algorithm

• Fragmentation
   Inactive                   Copy




• GC Suspend
• Copy     Overhead
•
Java Performance
                                                                       29
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Generational Algorithm
  – Copying Algorithm
       • Copy
       •                                                        Object

       •
           Object
       • Long Lived Object
  – Heap age              sub heap
    Youngest Generation Sub heap                                   GC
  – Object                                  Age
Java Performance
                                                                     30
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Youngest Generation Sub Heap

  Matured                Live      Live         Dead         Dead

     Live             Matured      Dead         Live         Dead

    Dead                 Live      Dead         Dead       Matured

Tenured Generation Sub Heap
Java Performance
                                                                    30
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Youngest Generation Sub Heap

                         Live      Live         Dead         Dead

     Live                          Dead         Live         Dead

    Dead                 Live      Dead         Dead

Tenured Generation Sub Heap                                 GC

  Matured             Matured    Matured
Java Performance
                                                                    30
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Youngest Generation Sub Heap

                         Live      Live

     Live                                       Live

                         Live

Tenured Generation Sub Heap                                 GC

  Matured             Matured    Matured
Java Performance
                                                                    30
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
 Garbage Collection Algorithm




Youngest Generation Sub Heap

                      Matured    Matured       Dead
                                               Live

  Matured                                      Dead

      Live            Matured      Live

Tenured Generation Sub Heap

  Matured             Matured    Matured
Java Performance
                                                                          31
                       Java Performance Fundamental | twitter @novathinker
      Garbage Collection Algorithm   artdb@ex-em.com | performeister.tistory.com




• Generational Algorithm


•     Sub Heap      Mark-and-Sweep          Copying       Algorithm


    Fragmentation, Memory             , Copy


•           JVM
Java Performance
                                                                        32
                     Java Performance Fundamental | twitter @novathinker
                                  artdb@ex-em.com | performeister.tistory.com
   Garbage Collection Algorithm




• Train Algorithm
  – Incremental Algorithm

  – Memory
    Mark-and-Copy GC

  – GC                            Suspend
                                      Idea
Java Performance
                                                                                          33
                         Java Performance Fundamental | twitter @novathinker
                                      artdb@ex-em.com | performeister.tistory.com
      Garbage Collection Algorithm



• Train Algorithm

                                     Car :       Memory Block        , Fixed Size


                         RememberSet               RememberSet
                                                                                    Car        root
                          A          B       C     A’      B’   C’           set




Train : Car(         )                               Car
Java Performance
                                                                            34
                         Java Performance Fundamental | twitter @novathinker
                                      artdb@ex-em.com | performeister.tistory.com
       Garbage Collection Algorithm



                                      Car 1-1           Car 1-2
     Train 1                           {R1,E}

                                  A      B      C   D      E      F


R1                                    Car 2-1
     Train 2                           {R2,B}
R2
                                 G
Java Performance
                                                                               34
                          Java Performance Fundamental | twitter @novathinker
                                       artdb@ex-em.com | performeister.tistory.com
        Garbage Collection Algorithm



                                       Free Car       Car 1-1            Car 1-2
     Train 1                                             {C}

                                                  D      E      F    C


R1                                     Car 2-1
     Train 2                            {R2,B}
R2
                                  G


                                       Car 3-1
     Train 3                            {R1}

                                   A      B
Java Performance
                                                                             34
                          Java Performance Fundamental | twitter @novathinker
                                       artdb@ex-em.com | performeister.tistory.com
        Garbage Collection Algorithm



                                       Free Car    Free Car           Free Car
 Free Train




R1                                     Car 2-1
     Train 2                            {R2,B}
R2
                                  G


                                       Car 3-1
     Train 3                            {R1}

                                   A      B
Java Performance
                                                                         35
                      Java Performance Fundamental | twitter @novathinker
                                   artdb@ex-em.com | performeister.tistory.com
Garbage Collection Algorithm




• Train Algorithm


• Suspend




•        Suspend
• Fragmentation
Java Performance
                                                                       36
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Garbage Collection Algorithm




• Adaptive Algorithm
  – Algorithm                          Trade Off
                                     Algorithm
  – Adaptive Algorithm                            Algorithm

  – Heap
    Algorithm
  – Hotspot Ergonomic                           , IBM      Tilt

  –                               Application
Java Performance
         artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




Hotspot JVM
Java Performance
                                                                                      38

                             artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




Hotspot JVM     Garbage Collection
  1) Garbage Collection of Hotspot JVM
  2) Heap of Hotspot JVM
  3) Garbage Collector

  4) Serial Collector
  5) Incremental Collector
  6) Parallel Collector
  7) Parallel Compacting Collector
  8) CMS Collector
  9) Garbage First Collector
Java Performance
                                                                   39
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Garbage Collection of Hotspot JVM
  – Weak Generational Hypothesis
        • High Infant Mortality
        • Few References from Older to Younger Objects
          Exists
  – Young Generation                  GC Algorithm
        • Speed              – Fast Allocation & TLAB
  – Old Generation GC Algorithm
        •                   – Card Table & Write Barrier
Java Performance
                                                                          40
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
   Hotspot JVM




• Fast Allocation & TLAB
                         T    T    T     T    T     Synchronization
                         1    2    3     4    5          Wait
                 Allocation




                          T          T          T          T          T
                          1          2          3          4          5
TLAB             Allocation Allocation Allocation Allocation Allocation
Java Performance
                                                                       41
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Fast Allocation & TLAB
  – Memory
  – Bump-the-Pointer
  – Multi Thread
  – Hotspot JVM        TLAB
    (Thread Local Allocation Buffer)
       • Thread
       • TLAB
       • Allocation code
                –    10      native instructions
Java Performance
                                                                    42
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Card Table               Write Barrier
  – 1 Byte Card / 512 Byte of Old Generation
  – Old to Young Reference
  – Write Barrier
       • Bytecode Interpreter
       • 2 native instructions
                                           Young Generation



                                                   Old Generation


                                                    Card Table
Java Performance
                                                                     43
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Garbage Collection of Hotspot JVM
  – Garbage Collection
        • Minor Collection : Young Generation
        • Major Collection : Old Generation
                – Full Collection
                – Method Area GC                 Major    Full
Java Performance
                                                                           44
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Heap of Hotspot JVM



                       Survivor 1

                                    Survivor 2
        Eden                                        Tenured        Permanent




      Young Generation                           Old Generation   Method Area

                           GC
Java Performance
                                                                     45
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
    Hotspot JVM



•    JVM Option
    – Standard Option
          :        JVM             Option
          :-
    – Non-Standard Option
          • JVM
          •          ,                 Parameter
          • -X Option : Macro
          • -XX Option : Micro
Java Performance
                                                                   46
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Automatic Selection
  – Java5                          Garbage Collector,
    Heap Size
  – Hardware Resource                   OS
  – Sever Class             Client Class
Java Performance
                                                                     47
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Automatic Selection
  – Server Class
        •          :2             CPU, 2GB             Physical Mem.
        •         32bit Windows
        • Default Garbage Collector              Parallel Collector
        • Initial Heap Size
                – 1GB       1/64 * Physical Memory
                – 1GB        32MB
        • Max Heap Size : 1GB                   ¼ * Physical Mem.
        • Server Runtime Compiler
Java Performance
                                                                   48
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Automatic Selection
  – Client Class
        • Server Class
        •   Default Garbage Collector          Serial Collector
        •   Initial Heap Size : 4MB
        •   Max Heap Size : 64MB
        •   Client Runtime Compiler
Java Performance
                                                                   49
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Automatic Selection
  –             Option
        • -server : Server Class
        • -client : Client Class
Java Performance
                                                                    50
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
   Hotspot JVM




• Garbage Collector
  – Serial Collector
      • Hotspot JVM          Default Garbage Collector
      • Default Collector
      • Young Generation : Generational Algorithm
      • Old Generation : Mark-and-Compacting
        Algorithm
Java Performance
                                                                    51
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
   Hotspot JVM




• Garbage Collector
  – Parallel Collector
      •           (Throughput)              Garbage Collector
      •   Throughput Garbage Collector
      •   Young Generation
      •   Young Generation : Parallel Copy Algorithm
      •   Old Generation : Mark-and-Compacting
          Algorithm
Java Performance
                                                                   52
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Garbage Collector
  – Parallel Compacting Collector
        •          Parallel Collector          Old Generation

        • Java SE 5.0 update 6
        • Young Generation : Parallel Copy Algorithm
        • Old Generation : Parallel Compacting
          Algorithm
Java Performance
                                                                   53
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Garbage Collector
  – CMS Collector
        • CMS : Concurrent Mark-Sweep
        •
        • Old Generation             Pause Time
                       (Low Pause Garbage Collector)
        • Young Generation : Parallel Copy Algorithm
        • Old Generation : Concurrent Mark-and-
          Sweep
                        Algorithm
Java Performance
                                                                   54
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Garbage Collector
  – Incremental Collector
        • Low Pause Garbage Collector
        • Train Collector
        • Young Generation : Generational Algorithm
        • Old Generation : Train Algorithm
Java Performance
                                                                   55
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Garbage Collector
  – Garbage First Collector
        • Java SE 6 Update 14
        • Train Algorithm
        • Generation
        • Heap Region
            Young , Old Area
        • Realtime                Low Pause
Java Performance
                                                                   56
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Serial Collector
  – Young, Old Generation Serial
    (Single CPU Use)
  – Suspend during Collecting
  – Client Class     Collector
  –
Java Performance
                                                                       57
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



 • Serial Collector
      – Young Generation Collection :
        Generational

Young          Eden

                                           A


                Survivor1 - From               Survivor2 - To

                        B       C                        Empty


Old
Java Performance
                                                                       57
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



 • Serial Collector
      – Young Generation Collection :
        Generational
                                      Minor GC
Young          Eden

                                           A


                Survivor1 - From               Survivor2 - To

                        B       C                   A’          B’    C’


Old
Java Performance
                                                                       57
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



 • Serial Collector
      – Young Generation Collection :
        Generational

Young          Eden

                                        Empty


                Survivor1 - From                Survivor2 - To

                          Empty                      A’          B’   C’


Old
Java Performance
                                                                       58
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



 • Serial Collector


Young          Eden

                                                     A


                Survivor1 - To                Survivor2 - From

                          Empty                                B      M


Old
Java Performance
                                                                        58
                     Java Performance Fundamental | twitter @novathinker
                                  artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



 • Serial Collector

                                       Minor GC
Young          Eden

                                         Empty


                Survivor1 - To                   Survivor2 - From

                    A’    B’                              Empty


Old
                               M’
Java Performance
                                                                       59
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



• Serial Collector
      – Old Generation Collection
                        : Mark-and-Compacting



Old
Java Performance
                                                                       59
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



• Serial Collector
      – Old Generation Collection
                        : Mark-and-Compacting

                                       Mark

Old
                       √                   √            √
Java Performance
                                                                       59
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



• Serial Collector
      – Old Generation Collection
                        : Mark-and-Compacting

                                       Sweep

Old
                       √                   √            √
Java Performance
                                                                       59
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
      Hotspot JVM



• Serial Collector
      – Old Generation Collection
                        : Mark-and-Compacting

                                 Sliding Compaction

Old
              √     √        √




                        Sliding Compaction : Fragmentation
Java Performance
                                                                   60
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Serial Collector
  – JVM Option
        • -XX:+UseSerialGC
           : J2SE5.0, update 6                  Serial Collector

        • -XX:MaxTenuringThreshold=<value>
           : Aging            , default 31
        • -XX:PretenureSizeThreshold=<value>
           : Old Generation directly Allocation
        • -XX:+PrintTenuringDistribution
           : Promotion
Java Performance
                                                                   61
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  –                  Memory, Multi-CPU

  – GC          Multi Thread
  – Large Young Generation
  – Server Class Default Garbage Collector
    (CPU 1                      )
  – Old Generation Collection
     : Serial Collector
Java Performance
                                                                   62
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Young Generation Collection : Parallel
    Copy

         Serial Collector                 Parallel Collector




                            Stop & Copy
Java Performance
                                                                   62
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Young Generation Collection : Parallel
    Copy

         Serial Collector                 Parallel Collector




                            Stop & Copy
Java Performance
                                                                   62
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Young Generation Collection : Parallel
    Copy

         Serial Collector                 Parallel Collector




                            Stop & Copy
Java Performance
                                                                     63
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Promotion Buffer
        • Parallel Local Allocation Buffer(PLAB)
        • Thread
        • Promotion                Thread               Promotion
          Buffer
        • Fragmentation
                – GC Thread
                – Old Generation Size
Java Performance
                                                                     64
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Promotion Buffer




                T1   T2                          T1          T2


                                                  Promotion Buffer
Java Performance
                                                                   65
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Option
        • -XX:+UseParallelGC : Parallel Collector
          (CMS Collector                )
        • -XX:ParallelGCThreads=<value>
           : GC Thread
             default CPU
Java Performance
                                                                   66
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
  – Ergonomics Option
        • -XX:MaxGCPauseMills=<value>
          (1.5+)
           : Maximum Pause Time Goal
            Pause Time
        • -XX:GCTimeRatio=<value>
          (1.5+)
          : Throughput Goal      , default 1%
                            GC Time
        • -XX:+UseAdaptiveSizePolicy
          (1.4.1+)
          :                  Young/Old Sizing
Java Performance
                                                                   67
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
        • -XX:YoungGenerationSizeIncrement=<value>
           : Young Growing Percent, Default = 20
          (1.5+)
        •-
          XX:TenuredGenerationSizeIncrement=<value>
           : Old Growing Percent, Default = 20 (1.5+)
        •-
          XX:AdaptiveSizeDecrementScaleFactor=<value
          >
           : Growing     Shrink  , Default = 4 (1.5+)
        • -XX:+AggressiveHeap
           : Physical Memory Max   Heap
             Hardware Resource
Java Performance
                                                                    68
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Collector
        • -XX:GCHeapFreeLimit=<value>
          (1.4.1+)
           : GC                 Free Space
                     Heap          (default 5)
             -XX:+UseParallelGC              GC
             OOME
        • -XX:GCTimeLimit=<value>
          (1.4.1+)
           : GC
                                                     (default 90)
                -XX:+UseParallelGC                         GC
                 OOME
Java Performance
                                                                   69
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Parallel Collector    Old Generation
           Collection Algorithm
  –             Parallel Collector
  – Multi CPU
  – Old Generation                Collection
  – Young Generation                  Collection
        • Parallel Collector
        • Parallel Copy Algorithm
Java Performance
                                                                     70
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Old Generation Collection
                 : Parallel Compaction

                Parallel Compacting Collector




                                            Mark Phase

                                            Summary Phase

                                            Compaction Phase
Java Performance
                                                                     70
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Old Generation Collection
                 : Parallel Compaction

                Parallel Compacting Collector




                                            Mark Phase

                                            Summary Phase

                                            Compaction Phase
Java Performance
                                                                     70
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Old Generation Collection
                 : Parallel Compaction

                Parallel Compacting Collector




                                            Mark Phase

                                            Summary Phase

                                            Compaction Phase
Java Performance
                                                                     70
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Old Generation Collection
                 : Parallel Compaction

                Parallel Compacting Collector




                                            Mark Phase

                                            Summary Phase

                                            Compaction Phase
Java Performance
                                                                     70
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Old Generation Collection
                 : Parallel Compaction

                Parallel Compacting Collector




                                            Mark Phase

                                            Summary Phase

                                            Compaction Phase
Java Performance
                                                                     70
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Old Generation Collection
                 : Parallel Compaction

                Parallel Compacting Collector




                                            Mark Phase

                                            Summary Phase

                                            Compaction Phase
Java Performance
                                                                   71
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Mark Phase
        • Generation Region
        • Live Object Marking
        • Parallel Work
Java Performance
                                                                       71
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Mark Phase
        • Generation Region
        • Live Object Marking
        • Parallel Work




                                               
Java Performance
                                                                       72
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Summary Phase
        •   Region              Operation
        •   Single Work
        •   Density
        •   Dense Prefix
        • Dense Prefix                   GC



                                               
Java Performance
                                                                       72
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Summary Phase
        •   Region              Operation
        •   Single Work
        •   Density
        •   Dense Prefix
        • Dense Prefix                     GC



                                               



                            Dense Prefix
Java Performance
                                                                       72
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Summary Phase
        •   Region              Operation
        •   Single Work
        •   Density
        •   Dense Prefix
        • Dense Prefix                     GC



                                               



                            Dense Prefix
Java Performance
                                                                       73
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Compaction Phase
        • Thread                    Region      Collecting
        • Source, Destination
        • Live Object Destination
          Compaction




                                               
Java Performance
                                                                       73
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Compaction Phase
        • Thread                    Region       Collecting
        • Source, Destination
        • Live Object Destination
          Compaction


                                   Destination    Source

                                               
Java Performance
                                                                       73
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Compaction Phase
        • Thread                    Region       Collecting
        • Source, Destination
        • Live Object Destination
          Compaction


                                   Destination    Source

                                               



                                       T1                        T2
Java Performance
                                                                       73
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Compaction Phase
        • Thread                    Region       Collecting
        • Source, Destination
        • Live Object Destination
          Compaction


                                   Destination    Source

                                               



                                       T1
Java Performance
                                                                       73
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Compaction Phase
        • Thread                    Region      Collecting
        • Source, Destination
        • Live Object Destination
          Compaction




                                 
Java Performance
                                                                   74
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Parallel Compacting Collector
  – Option
        • -XX:+UseParallelOldGC                            (+Java6)
           : Parallel Compaction Collector
        • -XX:+UseParallelOldGCCompacting
          (+Java6)
           : Parallel Compaction         , Default True
        • -XX:+UseParallelDensePrefixUpdate
          (+Java6)
           : Dense Prefix          , Default True
Java Performance
                                                                   75
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Fast Elapsed Time
  –                                                   Old
      Generation
  – Low Latency Collector
  –
  –                                             GC Pause Time

  – Young Generation                  Collection
        • Parallel Collector
Java Performance
                                                                   76
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
                   : Concurrent Mark-Sweep
 Concurrent Mark-Sweep Collector
Java Performance
                                                                   76
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
                   : Concurrent Mark-Sweep
 Concurrent Mark-Sweep Collector




                                          Initial Mark Phase
Java Performance
                                                                   76
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
                   : Concurrent Mark-Sweep
 Concurrent Mark-Sweep Collector




                                          Initial Mark Phase

                                          Concurrent Mark Phase
Java Performance
                                                                   76
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
                   : Concurrent Mark-Sweep
 Concurrent Mark-Sweep Collector




                                          Initial Mark Phase

                                          Concurrent Mark Phase

                                          Remark Phase
Java Performance
                                                                   76
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
                   : Concurrent Mark-Sweep
 Concurrent Mark-Sweep Collector




                                          Initial Mark Phase

                                          Concurrent Mark Phase

                                          Remark Phase
                                          Concurrent Sweep Phase
Java Performance
                                                                     77
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
        • Initial Mark Phase
                – Serial Phase
                – Direct Referenced Object
        • Concurrent Mark Phase
                – Serial Phase
                – Application
                – Direct Reference                             Object
Java Performance
                                                                     78
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Old Generation Collection
        • Remark Phase
                – Parallel Phase
                – Marking                      Mark
        • Concurrent Sweep Phase
                – Serial Phase
                – Dead Object      Reclaim
                – Compaction
Java Performance
                                                                   79
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – No Compaction!!!
        •                      , But           Free Space
           FreeList
        • Fast Allocation
            : Promotion                Young



                                                           
Java Performance
                                                                   79
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – No Compaction!!!
        •                      , But           Free Space
           FreeList
        • Fast Allocation
            : Promotion                Young
Java Performance
                                                                       80
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
        • Fragmentation
                                            Object Size      Tracking,

                                      Free Block
Java Performance
                                                                   81
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Concurrent Mark                           Allocation

  – Floating Garbage
        • Concurrent Mark                              Garbage
        • Next GC
        • Memory
Java Performance
                                                                   82
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Floating Garbage
Java Performance
                                                                   83
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Scheduling Collection
        • Old Generation          Full
        • Old Generation         Full
          GC
        • Minor GC                                     Remark
          Minor GC
        •     Current Heap

        •          :       Heap      68%
Java Performance
                                                                   84
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• CMS Collector
  – Option
      • -XX:+UseConcMarkSweepGC
        (1.4.0+)
         : CMS Collector
           (+XX:UseParallelGC                             )
      • -XX:+UseParNewGC                                      (1.4.1+)
        : Young      Parallel Option
      • -XX:CMSInitiatingOccupancyFraction
        (1.4.1+)
         :           Current Old Generation
Java Performance
                                                                    85
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
   Hotspot JVM




• CMS Collector
  – Incremental Mode
      • Concurrent phase
      • Concurrent Phase
Java Performance
                                                                    85
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
   Hotspot JVM




• CMS Collector
  – Incremental Mode
      • Concurrent phase
      • Concurrent Phase




     Initial Mark Phase
Java Performance
                                                                     85
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
    Hotspot JVM




• CMS Collector
  – Incremental Mode
       • Concurrent phase
       • Concurrent Phase




      Initial Mark Phase

 Concurrent Mark Phase
Java Performance
                                                                     85
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
    Hotspot JVM




• CMS Collector
  – Incremental Mode
       • Concurrent phase
       • Concurrent Phase




      Initial Mark Phase

 Concurrent Mark Phase

           Remark Phase
Java Performance
                                                                     85
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
    Hotspot JVM




• CMS Collector
   – Incremental Mode
       • Concurrent phase
       • Concurrent Phase




      Initial Mark Phase

 Concurrent Mark Phase

           Remark Phase
Concurrent Sweep Phase
Java Performance
                                                                     85
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
    Hotspot JVM




• CMS Collector
   – Incremental Mode
       • Concurrent phase
       • Concurrent Phase




      Initial Mark Phase
                                                         CPU
 Concurrent Mark Phase                                   GC

           Remark Phase
Concurrent Sweep Phase
Java Performance
                                                                     86
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Incremental Mode
        •                Minor GC                Concurrent Phase

        • Duty Cycle          Concurrent Collector

        • Duty Cycle
                –1     CPU
                – Minor GC
                – I-CMS                      (    ) or
Java Performance
                                                                     87
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
  – Option
        • -XX:+CMSIncrementalMode       (1.4.2+)
          : Incremental Mode      (default False)
                      CMS
                CMSInitiatingOccpancyFraction
        • -XX:+CMSIncrementalPacing      (1.4.2+)
          : Duty Cycle              (default False)
Java Performance
                                                                    88
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
        • -XX:CMSIncrementalDutyCycle=<value>
          (1.4.2+)
           : Duty Cycle         (default 50)
                Minor GC                       (0~100)
                                         50
        • -XX:CMSIncrementalDutyCycleMin=<value>
           :              Duty Cycle     (0~100)
             (Default 10) (1.4.2+)
Java Performance
                                                                   89
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
        •-
         XX:CMSIncrementalSafetyFactor=<value>(1.4.2
         +)
          : Duty Cycle
            (Default 10)
        • -XX:CMSIncrementalOffset=<value>
          (1.4.2+)
           : Duty Cycle   Minor GC
                 (0~100)  (Default 0)
Java Performance
                                                                   90
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• CMS Collector
        • -XX:CMSExpAvgFactor=<value>
          (1.4.2+)
           :                                                  %
             (Default 25) (0~100)
Java Performance
                                                                   91
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM



• Incremental Collector
  – Train Collector
  – Old Generation Pause Time
  – Young Generation Collection : Stop-the-
    Copy
  – Old Generation Collection : Train
       • Old            small                     GC
       • OOME                          Mark-and-Compaction


  – Old                Fragmentation
Java Performance
                                                                   92
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Incremental Collector
Java Performance
                                                                   93
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Incremental Collector
  – Minor GC
       • Minor GC         Major GC                      (overhead)
       • Minor GC          Old                        GC
       •         Throughput                   Default collector

       •           Pause Time
Java Performance
                                                                   94
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Incremental Collector
  –                           Collector
  – Option
       • -Xincgc : Incremental GC
           : -XX:+UseParallelGC, -XX:+UseParNewGC
Java Performance
                                                                                     95
                       Java Performance Fundamental | twitter @novathinker
                                    artdb@ex-em.com | performeister.tistory.com
         Hotspot JVM




  • Garbage Collector

     Garbage                                    Young Generation         Old Generation
                                 Option
     Collector                                 Collection Algorithm    Collection Algorithm

Serial Collector       -XX:+UseSerialGC        Generational           Mark-and-Compacting
(Default Collector)


Parallel Collector     -XX:+UseParallelGC      Parallel Copy          Mark-and-Compacting

Parallel
Compacting             -XX:+UseParallelOldGC   Parallel Copy          Parallel Compacting
Collector
                       -XX:                                           Concurrent
CMS Collector          +UseConcMarkSweepG      Parallel Copy
                       C                                              Mark-Sweep
Incremental
                       -Xincgc                 Generational           Train
Collector
Java Performance
                                                                     96
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
    Hotspot JVM




•                 Option
         • -XX:+DisableExplicitGC
            : System.gc()
         •   -XX:+PrintGC
         •   -XX:+PrintGCDetails
         •   -XX:+PrintGCTimeStamps
         •   -XX:+PrintHeapAtGC
         •   -Xloggc:<file>
         •   -verbosegc
Java Performance
                                                                     97
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Java SE 6 update 14
  – Realtime
       • Y ms interval                x ms           GC
  – Single Generation
       • Generation
       • Heap region
                – 1MB            Best Region
       • Young Generation : a Set of Regions
                – Allocation Region    Young Generation
       • Old Generation : a Set of Regions
Java Performance
                                                                   98
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First
       • Concurrent Marker               Heap Region           live
         data
       • Live Data      Garbage                     Region
       • Garbage Region
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection



                               Young GC (Evacuation Pause)
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection



                               Young GC (Evacuation Pause)

                               Concurrent Mark - Marking
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection



                               Young GC (Evacuation Pause)

                               Concurrent Mark - Marking

                               Concurrent Mark - Remarking
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection



                               Young GC (Evacuation Pause)

                               Concurrent Mark - Marking

                               Concurrent Mark - Remarking

                               Old Region Reclaim - Remark
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection



                               Young GC (Evacuation Pause)

                               Concurrent Mark - Marking

                               Concurrent Mark - Remarking

                               Old Region Reclaim - Remark

                               Old Region Reclaim – Evacuation Pause
Java Performance
                                                                   99
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection



                               Young GC (Evacuation Pause)

                               Concurrent Mark - Marking

                               Concurrent Mark - Remarking

                               Old Region Reclaim - Remark

                               Old Region Reclaim – Evacuation Pause

                               Compaction
Java Performance
                                                                     100
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Young GC (Evacuation Pause)
                – Live Object Survivor
                  Region Old Region

                – Stop-the-Copy
                – Parallel
Java Performance
                                                                     100
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Young GC (Evacuation Pause)
                – Live Object Survivor
                  Region Old Region

                – Stop-the-Copy
                – Parallel
Java Performance
                                                                     100
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Young GC (Evacuation Pause)
                – Live Object Survivor
                  Region Old Region

                – Stop-the-Copy
                – Parallel
Java Performance
                                                                     101
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Concurrent Marking
                – Mark : Evacuation Pause                  Initial Mark
                – Remark : Region    Live
                          Empty Region         reclaim
                          Stop the World
Java Performance
                                                                     101
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Concurrent Marking
                – Mark : Evacuation Pause                  Initial Mark
                – Remark : Region    Live
                          Empty Region         reclaim
                          Stop the World
Java Performance
                                                                     102
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Reclaim Old Region
                – Live Object      Region
                –        old Region collected
Java Performance
                                                                     102
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Reclaim Old Region
                – Live Object      Region
                –        old Region collected
Java Performance
                                                                     103
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  – Garbage First Collection
       • Compaction
                – Large chunk Free Space
                – Fragmentation
                – Fast Allocation
                    » Free List
                    » Linear
                    » TLAB
                –        - Copy     Pause Time
Java Performance
                                                                   104
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  Hotspot JVM




• Garbage First Collector
  –             Options
       • -XX:+UnlockExperimentalVMOptions
       • -XX:+UseG1GC
Java Performance
       artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




IBM JVM
Java Performance
                                                                                         106

                                artdb@ex-em.com | performeister.tistory.com | twitter @novathinker




IBM JVM    Garbage Collection
1) Heap of IBM JVM
2) Heap Expansion      Shrink

3) Garbage Collector

4) Optimize for Throughput

5) Optimize for Pause Time
6) Generation Concurrent
7) Subpooling
Java Performance
                                                                      107
                   Java Performance Fundamental | twitter @novathinker
                                artdb@ex-em.com | performeister.tistory.com
      IBM JVM




  • Heap Layout
      – 1.4                   Heap
      – Single Space




heapbase                                        heaplimit           heaptop
           •    Heap
           •    Heapbase : Heap
           •    Heaplimit :                       (movable)
           •    Heaptop : Heap
Java Performance
                                                                                   108
                                Java Performance Fundamental | twitter @novathinker
                                             artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Heap Layout
  – 1.4                                      Heap


       heapbase                                         heaplimit    heaptop


            Heap
        K Cluster

                    P Cluster




                                                                    Wilderness
                                               Heap         cache      or
                                                                      LOA
Java Performance
                                                                     109
                  Java Performance Fundamental | twitter @novathinker
                               artdb@ex-em.com | performeister.tistory.com
   IBM JVM




• Heap Layout
    • Kcluster : Pinned Class Object
             – Default 1280    class entries
             – 1    Class Entry 300byte(32it), 560byte(64bit)
    • Pcluster : Pinned Object
    • Kcluster          Pcluster
    • Pcluster               2KB           Pcluster
    • Pcluster
Java Performance
                                                                110
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Heap Layout
  – Large Object Area
       • Large Object
       • 64KB       Object
       • Heap
       • -Xloratio        LOA
         (0.5 ~ 0.95          )
       • Java5       -Xloainitial (default 0.05, 5%), -
         Xloamaximum(default 0.5, 50%)
       •               1MB          Object
Java Performance
                                                               111
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Heap Layout
                 Garbage Object     Live Object
Java Performance
                                                                                         112
                    Java Performance Fundamental | twitter @novathinker
                                 artdb@ex-em.com | performeister.tistory.com
       IBM JVM




   • Heap Layout - Subpool
       – Free Chunk                                                           FreeList
       – -Xgcpolicy: subpool
       – Pool                          FreeList,                     CPU

Pool

 1               Small Size Freelist                   Middle Size Freelist

 2
 3
 4
 5
 …




                                        Large Size Freelist
 n
Java Performance
                                                                113
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Heap Layout
  – Java 5                             Heap
  –           Heap        Generational Heap
  – -Xgcpolicy: gencon



       Allocation Space   Survivor Space     Tenured Space




                    Nursery                      Tenured
Java Performance
                                                               114
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM



• Heap Allocation
  – Heap Lock
       • 512byte          Object
       • Heap Lock           Free List
       •                             GC
       • Free Chunk                 Heap Lock
  – Dark Matter
       •          Free Chunk                                512
         byte       Freelist
       •      Dark Matter            compaction
Java Performance
                                                               115
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM        Heap
  – Heap         Options
     • -Xmx<value> , -Xms<value>
     • -Xmaxf<percentage>
       : Free Space      (default 0.6, 60%)
     • -Xminf<percentage>
       : Free Space       (default 0.3, 30%)
     • -Xloa :loa        , subpool           default
     • -Xmaxe<size>            heap expansion             (default
       0)
Java Performance
                                                                   116
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM            Heap
  – Heap             Options
     • -Xk<classes>                                           (~1.4.2)
            – Kcluster
            –          class
            –                         Class        1.1~1.15


     • -Xp<initial>,<overflow>
       (~1.4.2)
            – Pcluster
            –          initial Size     OverFlow
Java Performance
                                                                 117
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com
  IBM JVM



• Heap Expansion                  Shrink
  – Expansion
       • Expansion
            · Garbage Collector    Allocation

            · Free Space   –Xminf
            · GC                –Xmaxt
Java Performance
                                                                   118
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  IBM JVM



• Heap Expansion                    Shrink
  – Expansion
       • Expansion
            · Free Space     -Xmaxf              –Xmaxf
            ·                   –Xmaxe              –Xmaxe
            ·         –Xmine           –Xmine
            ·       Expansion         32bit          512byte
                64bit        1024byte
Java Performance
                                                                 119
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Heap Expansion                   Shrink
  – Shrink
       • Shrink
            · Garbage Collection

            · -Xmaxf 100%
            · System.gc()       free space         –Xminf
            · Heap        3     GC
       •                                   free space       –Xmaxf
                           Shrink
Java Performance
                                                                 120
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Heap Expansion                 Shrink
  – Shrink
       • Shrink
            – -Xmaxf               –Xms
            – 32bit      512byte          64bit          1024byte
Java Performance
                                                               121
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM        Heap
  – Heap Size          Options
     • -Xmaxf<percentage>
       : Free Space      (default 0.6, 60%)
     • -Xminf<percentage>
       : Free Space       (default 0.3, 30%)
     • -Xmaxe<size>      heap expansion       (default
       0)
     • -Xmine<size>     heap expansion       (default
       1MB)
     • -Xmaxt<percentage>
Java Performance
                                                               122
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM         Heap
  – Garbage Collection                Options
       • -Xgcpolicy:<optthruput | optavgpause | gencon
                    | subpool>
         : Garbage Collector
       • -Xdisableexplicitgc
         : System.gc()
       • -Xverbosegclog:<path to file>[X,Y]
         : file gc log
         : X,Y integer X file , Y GC Cycle
       • -verbose:gc :       gc
Java Performance
                                                                      123
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM             Heap
  – Garbage Collection                    Options
       • -Xcompactexplicitgc
            –    System.gc()         Compaction           (default)
       • -Xnocompactexplicitgc
            – System.gc()         Compaction
       • -Xcompactgc
            – GC         Compaction           (default)
       • -Xnocompacgc
            – GC    Compaction
Java Performance
                                                                      124
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM             Heap
  – Garbage Collection                    Options
       • -Xcompactexplicitgc
            –    System.gc()         Compaction           (default)
       • -Xnocompactexplicitgc
            – System.gc()         Compaction
       • -Xcompactgc
            – GC         Compaction           (default)
       • -Xnocompacgc
            – GC    Compaction
Java Performance
                                                               125
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM Garbage Collector
  – -Xgcpolicy
  – Optimize for throughput (optthruput)
       • Default garbage collector
       •
  – Optimize for pause time (optavgpause)
       • Concurrent GC
       • GC pause time
       •
Java Performance
                                                                 126
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• IBM JVM Garbage Collector
  – Generational Concurrent (gencon)
       • Object
       • Generational Heap
  – Subpooling (subpool)
       • Default algorithm
       • 16             CPU           SMP
Java Performance
                                                                              127
                 Java Performance Fundamental | twitter @novathinker
                              artdb@ex-em.com | performeister.tistory.com
      IBM JVM



  •          Collector            Algorithm
                  Mark Phase               Sweep Phase             Compaction Phase

                                                                 1.4 - Incremental
optthruput        Parallel Mark        Parallel bitwise Sweep      Compaction,
                                                              5.0–Parallel Compaction

                                         1.4-Parallel bitwise      1.4 - Incremental
                                               Sweep,                Compaction,
optavgpause     Concurrent Mark
                                           5.0-Concurrent       5.0-Mostly Concurrent
                                               Sweep                  Compaction
                                   Scavenge Copy of New Area
                                   Global Collection of Old Area
  gencon
                                                                   Mostly Concurrent
                Concurrent Mark        Parallel bitwise Sweep
                                                                     Compaction
                                                                 1.4 - Incremental
  subpool         Parallel Mark        Parallel bitwise Sweep      Compaction,
                                                              5.0–Parallel Compaction
Java Performance
                                                               128
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  –           Application
  – Default Garbage Collector
  – Parallel Algorithm
  – GC           Application Suspend
  – Mark-Sweep phase          GC Cycle

  – Compaction           Fragmentation                      AF

       • Allocation Failure(AF) :
Java Performance
                                                               129
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  – Mark-Sweep & Compaction
Java Performance
                                                               129
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  – Mark-Sweep & Compaction
Java Performance
                                                               129
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  – Mark-Sweep & Compaction


                          Mark Phase

                     
Java Performance
                                                               129
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  – Mark-Sweep & Compaction
Java Performance
                                                               129
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  – Mark-Sweep & Compaction
Java Performance
                                                               129
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
  – Mark-Sweep & Compaction
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread




                                             Mark
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread




                                             Mark

                                            Sweep
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread




                                             Mark

                                            Sweep
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread




                                             Mark

                                            Sweep


                                            Compaction
Java Performance
                                                               130

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – GC                                   Thread




                                             Mark

                                            Sweep


                                            Compaction
Java Performance
                                                                131

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Mark Phase : Parallel Mark
     • 1.4        : Mark Stack
     • Java 5        : Work Packet
  – Sweep Phase : Parallel Bitwise Sweep
  – Compaction Phase
     • 1.4        : Incremental Compaction
     • Java 5        : Parallel Compaction
Java Performance
                                                                    132
                Java Performance Fundamental | twitter @novathinker
  IBM JVM                    artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Mark Phase : Parallel Mark
       • Tracing              Live Object      Mark
       • Live Object
            –   Register, stack, static, jni               Object
            –   Move               dosed bit   on
            –   Mark bit
            –   Mark Stack
            –   Mptr         class object                      mark
            –   Array         array entry       trace
Java Performance
                                                                 133
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Mark Phase : Parallel Mark
       • Mark Stack (1.4)
            –      Trace         Live Object reference
            – Marking Thread 4KB Mark Stack
            – Marking Thread       thread Stack scan
              reference push,          mark bit
            – Garbage Collector              Pop
              Object Mark
            – Array          Array Entry               Mark
            – MSO(Mark Stack Overflow)
                » Object NotYetScanned bit       Global Flag
                »               Object
                » Thread
                » Heap
Java Performance
                                                                 134
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Mark Phase : Parallel Mark
       • Work Packet(5.0)
            – Java5      Work Packet        Pool
            –    Work Packet           Mark Stack
            –    Marking Thread 2        Work Packet
                » Input Packet : reference pop
                » Output Packet : Unmarked Object Push
                » Reference Output Packet Push         Mark
Java Performance
                                                                 135
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Mark Phase : Parallel Mark
       • Work Packet(5.0)
            – Root Object        mark bit
              reference output packet
            – Root Object            Reference       input Packet
                         Pop    Object
            –      List
Java Performance
                                                                 136
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Mark Phase : Parallel Mark
       • Parallel Mark(1.4)
            – Mark
            –       application Thread     master         gc thread
                helper thread
            – Helper Thread 4KB Mark Stack          Shareable
              Queue 2KB Mark Queue
       • Parallel Mark(5.0)
            – helper Thread      Work Packet    Pool
Java Performance
                                                                 137
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Sweep Phase : Parallel Bitwise Sweep
       • Alloc bits Mark Bits                       Reference
              Allocated Object
       • Bit Wised Technique
            – Mark bits     0            Free Space
            –                   512 byte         freelist
       • Sweep                    mark bits     alloc bits
Java Performance
                                                               138
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com
  IBM JVM




• Optimize for throughput
                 Garbage Object     Live Object
Java Performance
                                                                 139
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Sweep Phase : Parallel Bitwise Sweep
       • Parallel Bit-wised Sweep
            –              Sweep
            – Heap         N    Section
               » 1.4 : N   Helper Thread *32, heap size / 16MB

               » 5.0 : N heap size / 256KB,    256KB fixed
                 Size
            – Helper Thread            Section Scan & Sweep
            –     Section               Free List
Java Performance
                                                                 140

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Compaction
            –   GC
            – Sweep          Allocation Request

            – System.gc()                 AF      Compaction

            – TLH
              TLH 1000Byte(1.4)     1024Byte(5.0)
            – Free Space Active heap 5%     128MB
Java Performance
                                                                  141
               Java Performance Fundamental | twitter @novathinker
  IBM JVM                   artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
       • 1.4                 Compaction
            – Unmovable Object
            – Incremental Compaction Algorithm


       • 5.0           Compaction
            – Parallel Compaction
            – Unmovable Object
Java Performance
                                                                   142

  IBM JVM
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Incremental Compaction(1.4)
            –   Compaction                       Compaction
            –   128MB       Heap
            –   Heap Section                    Section   Compaction
            –   1.4.2      Default
            –   Mark Phase     Section             Free Space
            –   Object                ,     ,       Pointer
            –            Section                   GC
Java Performance
                                                                 143
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – UnMovable Object (~1.4.2)
       • Dosed Object
            – Stack(Local Variable, Method Parameter)
                   Object
            – Dosed bit on,
       • Pinned Object
            – JNI, Class Object, Other Pinned Object
            – Pinned bit On,
Java Performance
                                                               144

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – UnMovable Object




                                        pinned
                            dosed
                             Compaction




                                        pinned
                            dosed
Java Performance
                                                               145

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Incremental Compaction(1.4)


                           Dark Matter




                        One Section per Thread
Java Performance
                                                                   146

  IBM JVM
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Parallel Compaction(1.5)
            – Heap     n    area
            – Area         Heap Size     CPU, thread

            –    Thread                Area     Compaction
            –
                » Move Step : Object
                » Fix-up Step : Object        Reference
Java Performance
                                                                 147

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Parallel Compaction(1.5)
            – Move Step

    T1                T2



                                        T1                 T2
Java Performance
                                                                 148

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
     • Parallel Compaction(1.5)
            – Move Step
               »   Thread Source Area Destination Area
               » Object Moving         Pointer bitmap
               » Hole               Area

               » Area Size            Hole                     Load
                 Balancing
Java Performance
                                                                 149

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Parallel Compaction(1.5)
            – Fix-up Step
                »               reference      update
                » Block table
                » Block 256Kb               Heap
                » Fix-up      Block
                » Block object            ,
                » Object Block
Java Performance
                                                                 150

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  – Compaction Phase
      • Parallel Compaction(1.5)
            – Block Table
                » Block   1     Pointer
                » Block       Object
            – Object                  Bitmap
                » Old Bitmap : Move      Object      (Mark Phase)
                » New Bitmap : Move      Object       (Moving Step)
Java Performance
                                                                  151

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for throughput
  –          Options
      • -Xgcthreads<thread              >
            – GC Parallel                   Thread
            – Default CPU        – 1, Min   1, Max   CPU
      • -Xgcworkpackets<numbers>
            – Workpacket         default    maximum heap size
                     packet
      • -Xpartialcompactgc
            – Incremental compaction       (1.4.2      default)
            – 5.0      not set,  full compaction
      • -Xnopartialcompactgc
            – Incremental Compaction
Java Performance
                                                               152

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  –     GC Pause Time
  –           Background thread Application
           concurrent mark, sweep
  – Mark Phase : Concurrent Mark
  – Sweep Phase
      • 1.4      -Parallel bitwise Sweep,
      • Java 5 -Concurrent Sweep
  – Compaction Phase
      • 1.4      - Incremental Compaction,
      • Java 5 -Mostly Concurrent Compaction
Java Performance
                                                               153

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
                       ~ 1.4.2        Java5 ~
Java Performance
                                                               153

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
                       ~ 1.4.2        Java5 ~
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark


Sweep
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark


Sweep
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark


Sweep


Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark


Sweep


Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark


Sweep


Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark                                        Concurrent Mark


Sweep


Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark                                        Concurrent Mark


Sweep                                                  Concurrent Sweep



Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark                                        Concurrent Mark


Sweep                                                  Concurrent Sweep



Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark                                        Concurrent Mark


Sweep                                                  Concurrent Sweep



Compaction                                             Compaction
Java Performance
                                                                  153

     IBM JVM
               Java Performance Fundamental | twitter @novathinker
                            artdb@ex-em.com | performeister.tistory.com




 • Optimize for pause time
                          ~ 1.4.2        Java5 ~




Concurrent Mark                                        Concurrent Mark


Sweep                                                  Concurrent Sweep



Compaction                                             Compaction
Java Performance
                                                                 154

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Concurrent Mark
      •   Thread       Stack Scan
        root
      • Trace background thread
      •   Thread            marking
            –      trace Object
            – Object reference              write barrier
                 heap
            – Heap 512byte      1byte card                card
              table
            – Reference              object
              0x01
Java Performance
                                                                 155
              Java Performance Fundamental | twitter @novathinker
  IBM JVM                  artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Concurrent Mark
       • Object Allocation ‘tax’ rate
            – STW
            – heap                     Marking
            – Garbage Collection Thread       Application Thread

            – Garbage Collection
              Tax
Java Performance
                                                               156

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Stop the World Phase
      •      Root     Scan
      • Marked Card
      •         Sweep
      • Floating Garbage
Java Performance
                                                                 157

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Concurrent Sweep Phase
      • Java 5
      • 1.4.2              Parallel Bitwise Sweep Algorithm

      • Parallel bit-wise Sweep
      • Heap Section            Allocation
                         Sweep
      •
            – Sweep Analysis
               » Markbit        Data Section
               » Freelist
            – Connection
Java Performance
                                                               158

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Concurrent Sweep Phase
      • Heap Section               parallel bitwise sweep

      •          Sweep STW
      • Allocation Process             Concurrent Sweep

      • Compaction
      •              Mark                            .
Java Performance
                                                                 159

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Java 5
      • 1.4      Incremental Compaction
      • Compaction
      • STW            Partial Move
            – Sweep             Compact
      • Fixup      Concurrently
            – Compaction                 Pause Time
Java Performance
                                                                 160

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Move Step
            – Application
               » Map2            Heap Fixup view
               » Map2 :       Virtual Address range
                 Physical Memory Map
            – Compact Area
               » Sweep              Object Layout
                 Compaction        Section
            – Move – Object             Compaction
Java Performance
                                                                 161

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • STW Fix-up
            – Root Reference Fixup
            – Heap page
               » Object           Heap Page
               » Object               Heap Page            Unfixed
                       –       Lock
               »         Free Page Fixed
            – Application Thread
Java Performance
                                                                   162

  IBM JVM
                Java Performance Fundamental | twitter @novathinker
                             artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up
            –        unfixed page                 fixed
            –   Unfixed(protected)  Busy  Fixed(unprotected)
            –   Application fixed Page
            –   Exclusive Fixer : Fix          Thread
            –   Collector Thread             Fix
            –   Trapped Thread : Application Thread Unfixed page
                          Trap Routine
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                Collector         Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                 Exclusive
                Collector         Unfixed
                  Fixer


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                 Exclusive
                Collector         Unfixed
                  Fixer


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                 Exclusive
                Collector         Unfixed
                                   Busy
                  Fixer


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                 Exclusive
                Collector         Unfixed
                                   Fixed
                                   Busy
                  Fixer


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                 Exclusive
                Collector         Unfixed
                                   Fixed
                                   Busy
                  Fixer


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                Collector         Unfixed
                                   Fixed
                                   Busy


                                  Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy

                 Exclusive
                Collector
                  Fixer           Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy

                 Exclusive
                Collector
                  Fixer           Unfixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy

                 Exclusive
                Collector
                  Fixer           Unfixed
                                   Busy


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy

                 Exclusive
                Collector
                  Fixer           Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy

                 Exclusive
                Collector
                  Fixer           Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                                  Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Mutator          Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Mutator          Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                     Unfixed
                                      Fixed
                                      Busy


                Collector            Unfixed
                                      Busy
                                      Fixed


                                     Unfixed

                            blocke
                 Mutator       d     Unfixed


                                     Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Mutator          Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Trapped
                 Mutator          Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed

                 Exclusive
                 Trapped
                 Mutator
                   Fixer          Unfixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed

                 Exclusive
                 Trapped
                 Mutator
                   Fixer          Unfixed
                                   Busy


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed

                 Exclusive
                 Trapped
                 Mutator
                   Fixer          Unfixed
                                   Busy
                                   Fixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Trapped
                 Mutator          Unfixed
                                   Busy
                                   Fixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Mutator          Unfixed
                                   Busy
                                   Fixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                 Mutator          Unfixed
                                   Busy
                                   Fixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed

                                  Mutator
                                  Unfixed
                                   Busy
                                   Fixed


                                  Unfixed
Java Performance
                                                               163

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  – Mostly Concurrent Compaction
      • Concurrent Fix-up

                                  Unfixed
                                   Fixed
                                   Busy


                Collector         Unfixed
                                   Busy
                                   Fixed


                                  Unfixed


                                  Unfixed
                                   Busy
                                   Fixed


                                  Unfixed
Java Performance
                                                                 164

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  –          Options
      • -Xconcurrentbackground<number>
            – Concurrent mark background         GC
              Application Thread
            – Default 1
      • -Xconcurrentlevel<number>
            – Tax rate
            –     heap           Tax
            – Default 8
Java Performance
                                                                 165

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Optimize for pause time
  –          Options
      • -Xconmeter:<soa:loa:dynamic>
            – Concurrent Mark Allocation Tax
            – Dynamic
            – Default  soa (Small Object Area)
Java Performance
                                                                166

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
  – Generation                Heap




       Allocation Space   Survivor Space     Tenured Space




              New Area (Nursery)                Old Area
Java Performance
                                                               167

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
  – Nursery :               Object
      • Allocate Space : Object
      • Survivor Space
        : Allocate Space          Allocation Failure
          Scavenge-Copy (GC : Stop-the-Copy)
        :      Live Object
      • Allocate Space      Survivor Space        Flip
Java Performance
                                                                                     168

  IBM JVM
                     Java Performance Fundamental | twitter @novathinker
                                  artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
  – Tenured :                                        Object          Promotion
         •     14 GC Aging         Promotion (adaptive)
         • Optavgpause     concurrent mark
         • But sweep                    concurrent
  – Tilt Ratio : Adaptive


                                                                                  Survivor
  Allocation Space     Survivor Space                    Allocation Space
                                                                                   Space




                 50%                                                        80%
Java Performance
                                                               169

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
Java Performance
                                                               169

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
Java Performance
                                                               169

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
Java Performance
                                                               169

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark
Java Performance
                                                               169

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark
Java Performance
                                                               169

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark
Java Performance
                                                                169

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark

            Global Collection
Java Performance
                                                                169

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark

            Global Collection
Java Performance
                                                                169

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark

            Global Collection
Java Performance
                                                                169

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark

            Global Collection
Java Performance
                                                                169

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark

            Global Collection



             Scavenge Copy
Java Performance
                                                                169

  IBM JVM
             Java Performance Fundamental | twitter @novathinker
                          artdb@ex-em.com | performeister.tistory.com




• Generation concurrent

             Scavenge Copy

            Concurrent Mark

             Scavenge Copy

            Concurrent Mark

            Global Collection



             Scavenge Copy
Java Performance
                                                               170

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
  – Scavenge GC
      • New Area Garbage Collection
      • Stop The Copy Algorithm
  – Global GC
      • Tenured Area optavgpause                       Concurrent
        Mark
      • Concurrent Sweep
      • Nursery, tenured
      • GC        Application Suspend
      • Compaction
Java Performance
                                                                 171

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Generation concurrent
  –          Options
      • -Xmn<size>
            – New Area
      • -Xmns<size> : New Area
      • -Xmnx<size> : New Area
      • -Xmo<size>
            – Old Area
      • -Xmos<size> : Old Area
      • -Xmox<size> : Old Area
Java Performance
                                                                 172

  IBM JVM
              Java Performance Fundamental | twitter @novathinker
                           artdb@ex-em.com | performeister.tistory.com




• Subpooling
  – 16                     CPU
  – Size           Heap
      • Pool         freelist
      • Pool                 sorting
      • Fast allocation
            – Allocation    Heap Lock


      • CPU                 Pool
Java Performance
                                                               173

  IBM JVM
            Java Performance Fundamental | twitter @novathinker
                         artdb@ex-em.com | performeister.tistory.com




• Subpooling
  – Subpool
      • JVM                  Compaction
        Subpool
      •       GC    Sweep phase                     subpool
      • Concurrent Algorithm
Java Performance
                                                   174
Java Performance Fundamental | twitter @novathinker
             artdb@ex-em.com | performeister.tistory.com

3장. Garbage Collection

  • 1.
    Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Garbage Collection
  • 2.
    Java Performance 2 artdb@ex-em.com | performeister.tistory.com | twitter @novathinker 1) Garbage Collection 2) Garbage Collection Algorithm 3) Hotspot JVM Garbage Collection 4) IBM JVM Garbage Collection
  • 3.
    Java Performance 3 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection • Garbage Collection – Garbage Collector – Unreferenced Memory – – Fragmentation “Heap storage for objects is reclaimed by an automatic storage management system (typically a garbage collector); objects are never explicitly deallocated.” - Java Virtual Machine Speculation, Section 3.5.3 [JVMS2 1999]
  • 4.
    Java Performance 4 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ! Garbage Collector
  • 5.
    Java Performance 4 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ! object Garbage Collector Heap memory .
  • 6.
    Java Performance 4 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ! object Garbage Collector Heap memory . Garbage Collection Memory Recycling Heap Fragmentation .
  • 7.
    Java Performance 4 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ! object Garbage Collector Heap memory . Garbage Collection Memory Recycling Heap Fragmentation . • JVM heap new, newarray, anewarray, multianewarray instruction instruction • Garbage Collection • JVM Spec Garbage Collection Algorithm
  • 8.
    Java Performance 5 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ! Garbage Collector
  • 9.
    Java Performance 5 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Memory ! Memory System Garbage Collector crash .
  • 10.
    Java Performance 5 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Memory ! Memory System Garbage Collector crash . Program CPU Time Scheduling .
  • 11.
    Java Performance 6 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection • Garbage Collection – Garbage Collection
  • 12.
    Java Performance 7 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection
  • 13.
    Java Performance 7 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ROOT SET
  • 14.
    Java Performance 7 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ROOT SET Local Variable, Operand Stack
  • 15.
    Java Performance 7 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ROOT SET Local Variable, Operand Stack Class Constant Pool Reference
  • 16.
    Java Performance 7 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection ROOT SET Local Variable, Unreleased Native Operand Stack Method Object Reference Class Constant Pool Reference
  • 17.
    Java Performance 8 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Colletion • Root Set
  • 18.
    Java Performance 9 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Colletion • Memory Leak class Main{ public static void main (String args[]) { Leak lk = new Leak(); for(int a=0; a<9000000; a++) { lk.addList(a); lk.removeStr(a); } } } class Leak { ArrayList lst = new ArrayList(); public void addList(int a) { lst.add(" "+a); } public void removeStr(int i) { Object obj = lst.get(i); obj = null; } }
  • 19.
    Java Performance 9 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Colletion • Memory Leak class Main{ public static void main (String args[]) { Leak lk = new Leak(); for(int a=0; a<9000000; a++) { lk.addList(a); lk.removeStr(a); } } Why leak? } class Leak { ArrayList lst = new ArrayList(); public void addList(int a) { lst.add(" "+a); } public void removeStr(int i) { Object obj = lst.get(i); obj = null; } }
  • 20.
    Java Performance 10 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm
  • 21.
    Java Performance 11 artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Garbage Collection Algorithm 1) Reference Counting Algorithm 2) Mark-and-Sweep Algorithm 3) Mark-and-Compacting Algorithm 4) Copying Algorithm 5) Generational Algorithm 6) Train Algorithm 7) Adaptive Algorithm
  • 22.
    Java Performance 12 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Garbage Collection Algorithm
  • 23.
    Java Performance 12 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Garbage Collection Algorithm Garbage Object Detection • Live Object : Root Set • Garbage Object
  • 24.
    Java Performance 12 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Garbage Collection Algorithm Garbage Object Detection • Live Object : Root Set • Garbage Object Garbage Object • Heap Memory Reclaim
  • 25.
    Java Performance 13 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Reference Counting Algorithm • Mark-and-Sweep Algorithm • Copying Algorithm • Mark-and-Compacting Algorithm • Generational Algorithm • Train Algorithm • Adaptive Algorithm
  • 26.
    Java Performance 14 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Reference Counting Algorithm – GC – Object Reference count – Reference Count 0 GC – Object GC Object Object Object Count Count
  • 27.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer RefCnt 00 Integer RefCnt 00 Integer RefCnt 00
  • 28.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); RefCnt 00 Integer RefCnt 00 Integer RefCnt 00
  • 29.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 RefCnt 01 0 Integer RefCnt 00 Integer RefCnt 00
  • 30.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; RefCnt 01 0 Integer RefCnt 00 Integer RefCnt 00
  • 31.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer RefCnt 00 Integer RefCnt 00
  • 32.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer Object a = new Ingeter(1); RefCnt 00 Integer RefCnt 00
  • 33.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer a 1 Object a = new Ingeter(1); 0 RefCnt 01 Integer RefCnt 00
  • 34.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer a 1 Object a = new Ingeter(1); 0 RefCnt 01 Object b = new Ingeter(2); Integer RefCnt 00
  • 35.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer a 1 Object a = new Ingeter(1); 0 RefCnt 01 Object b = new Ingeter(2); Integer 2 b RefCnt 01 0
  • 36.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer a 1 Object a = new Ingeter(1); 0 RefCnt 01 Object b = new Ingeter(2); Integer a = b; 2 b RefCnt 01 0
  • 37.
    Java Performance 15 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Integer Object a = new Ingeter(1); a 1 Object b = a; b RefCnt 01 0 2 Integer a 1 Object a = new Ingeter(1); 0 RefCnt 01 Object b = new Ingeter(2); Integer a = b; 2 b RefCnt 01 0 2
  • 38.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm
  • 39.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Object a = new TwoIngeter(new Integer(1), new Integer(2));
  • 40.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Object a = new TwoIngeter(new Integer(1), new Integer(2)); Integer 1 TwoInteger RefCnt 00 1 ref a RefCnt 00 1 Integer 2 RefCnt 01 0
  • 41.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Object a = new TwoIngeter(new Integer(1), new Integer(2)); a = null; Integer 1 TwoInteger RefCnt 00 1 ref a RefCnt 00 1 Integer 2 RefCnt 01 0
  • 42.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Object a = new TwoIngeter(new Integer(1), new Integer(2)); a = null; Integer 1 TwoInteger RefCnt 00 1 ref a RefCnt 00 1 Integer 2 RefCnt 01 0
  • 43.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Object a = new TwoIngeter(new Integer(1), new Integer(2)); a = null; Integer 1 TwoInteger RefCnt 00 1 ref a GC RefCnt 00 1 Integer 2 RefCnt 01 0
  • 44.
    Java Performance 16 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Object a = new TwoIngeter(new Integer(1), new Integer(2)); a = null; Integer 1 RefCnt 00 1 a Integer 2 RefCnt 01 0 0
  • 45.
    Java Performance 17 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Reference Counting Algorithm • Garbage Object • Garbage • Garbage Collector ( ) • Reference Count • Linked List Reference Count 0 Leak
  • 46.
    Java Performance 18 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm a Linked List next ref RefCnt 02 Linked List next ref RefCnt 11 Linked List next ref RefCnt 01
  • 47.
    Java Performance 18 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm a Linked List next ref 2 RefCnt 01 Linked List next ref RefCnt 11 Linked List next ref RefCnt 01
  • 48.
    Java Performance 19 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Mark-and-Sweep Algorithm – Root Set Reference – Tracing Algorithm – Mark Sweep • Mark : Live Object Mark (Object flag or bitmap table ) • Sweep : Heap Mark
  • 49.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm R ref ref ref  flag  flag  flag ref ref ref  flag  flag  flag ref ref ref  flag  flag  flag
  • 50.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Mark Phase R ref ref ref  flag  flag  flag ref ref ref  flag  flag  flag ref ref ref  flag  flag  flag
  • 51.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Mark Phase R ref ref ref   flag   flag   flag ref ref ref  flag  flag   flag ref ref ref  flag   flag   flag
  • 52.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Sweep Phase R ref ref ref   flag   flag   flag ref ref ref  flag  flag   flag ref ref ref  flag   flag   flag
  • 53.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Sweep Phase R ref ref ref   flag   flag   flag ref   flag ref ref   flag   flag
  • 54.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm R ref ref ref   flag   flag   flag ref   flag ref ref   flag   flag
  • 55.
    Java Performance 20 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm R ref ref ref  flag  flag  flag ref  flag ref ref  flag  flag
  • 56.
    Java Performance 21 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Mark-and-Sweep Algorithm • Reference • Reference Overhead • Suspend • Fragmentation  Memory
  • 57.
    Java Performance 22 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Mark-and-Compacting Algorithm – Fragmentation Memory Algorithm – Mark Compaction • Mark Phase : Live Object Mark • Compaction : Live Object Memory – Handle • Mark Phase : Handle Marking • Compaction : Object Handle Update
  • 58.
    Java Performance 23 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Mark-and-Compacting Algorithm – Compaction Arbitrary Worst 4 1 2 3 1 2 3 4 Linear 1 3 4 2 • Arbitrary : Sliding • Linear : Pointer 1 2 3 4 • Sliding : Allocation Best
  • 59.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Handle 0  flag 1  flag T22 A 5 Z 1 2  flag T11 3  flag T12 B 9 W 7 4  flag 5  flag T21 6  flag Q 3 C 2 7  flag T31 8  flag 9  flag T32
  • 60.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Mark Phase Handle 0  flag 1  flag T22 A 5 Z 1 2  flag T11 3  flag T12 B 9 W 7 4  flag 5  flag T21 6  flag Q 3 C 2 7  flag T31 8  flag 9  flag T32
  • 61.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Mark Phase Handle 0  flag 1  flag T22 A 5 Z 1  2  flag T11 3  flag T12 B 9 W 7 4  flag  5  flag T21 6  flag Q 3 C 2 7  flag T31 8  flag  9  flag T32
  • 62.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Mark Phase Handle 0  flag 1  flag T22 A 5 Z 1  2  flag T11 3  flag T12 B 9 W 7 4  flag  5  flag T21 6  flag Q 3 C 2 7  flag T31 8  flag  9  flag T32
  • 63.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Mark Phase Handle 0  flag 1  flag T22 A 5 Z 1  2  flag T11 3  flag T12 B 9 W 7 4  flag  5  flag T21 6  flag Q 3 C 2 7  flag T31 8  flag  9  flag T32
  • 64.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Compation Phase Handle 0  flag 1  flag T22 A 5 Z 1  2  flag T11 3  flag T12 B 9 W 7 4  flag  5  flag T21 6  flag Q 3 C 2 7  flag T31 8  flag  9  flag T32
  • 65.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Compation Phase Handle 0  flag 1  flag T22 A 5  2  flag T11 3  flag T12 B 9 4  flag  5  flag T21 6  flag C 2 7  flag T31 8  flag  9  flag T32
  • 66.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Compation Phase Handle 0  flag 1  flag T22 A 5 B 9  2  flag T11 3  flag T12 4  flag  5  flag T12 T21 6  flag C 2 7  flag T31 8  flag  9  flag T32
  • 67.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Compation Phase Handle 0  flag 1  flag T22 A 5 B 9  2  flag T11 3  flag T12 C 2 4  flag  5  flag T12 T21 6  flag 7  flag T31 8  flag  9  flag T21 T32
  • 68.
    Java Performance 24 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm 2 Handle 0  flag 1  flag T22 A 5 B 9 2  flag T11 3  flag T12 C 2 4  flag 5  flag T12 T21 6  flag 7  flag T31 8  flag 9  flag T21 T32
  • 69.
    Java Performance 25 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Mark-and-Compacting Algorithm • Fragmentation • Memory • Reference Object Access Overhead • Suspend
  • 70.
    Java Performance 26 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Copying Algorithm – Stop-the-Copy Algorithm – Heap Active Inactive – Active Object – Active Live Object Inactive Copy
  • 71.
    Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Active Area A C B R Inactive Area
  • 72.
    Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Active Area A C null null B null R Inactive Area
  • 73.
    Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Active Area A C null B null R A’ null Inactive Area
  • 74.
    Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Active Area A C null B R A’ B’ null null Inactive Area
  • 75.
    Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Active Area A C B R A’ B’ C’ null null null Inactive Area
  • 76.
    Java Performance 27 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Inactive Area R A’ B’ C’ null null null Active Area
  • 77.
    Java Performance 28 Java Performance Fundamental | twitter @novathinker Garbage Collection Algorithm artdb@ex-em.com | performeister.tistory.com • Copying Algorithm • Fragmentation  Inactive Copy • GC Suspend • Copy Overhead •
  • 78.
    Java Performance 29 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Generational Algorithm – Copying Algorithm • Copy • Object • Object • Long Lived Object – Heap age sub heap Youngest Generation Sub heap GC – Object Age
  • 79.
    Java Performance 30 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Youngest Generation Sub Heap Matured Live Live Dead Dead Live Matured Dead Live Dead Dead Live Dead Dead Matured Tenured Generation Sub Heap
  • 80.
    Java Performance 30 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Youngest Generation Sub Heap Live Live Dead Dead Live Dead Live Dead Dead Live Dead Dead Tenured Generation Sub Heap GC Matured Matured Matured
  • 81.
    Java Performance 30 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Youngest Generation Sub Heap Live Live Live Live Live Tenured Generation Sub Heap GC Matured Matured Matured
  • 82.
    Java Performance 30 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Youngest Generation Sub Heap Matured Matured Dead Live Matured Dead Live Matured Live Tenured Generation Sub Heap Matured Matured Matured
  • 83.
    Java Performance 31 Java Performance Fundamental | twitter @novathinker Garbage Collection Algorithm artdb@ex-em.com | performeister.tistory.com • Generational Algorithm • Sub Heap Mark-and-Sweep Copying Algorithm Fragmentation, Memory , Copy • JVM
  • 84.
    Java Performance 32 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Train Algorithm – Incremental Algorithm – Memory Mark-and-Copy GC – GC Suspend Idea
  • 85.
    Java Performance 33 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Train Algorithm Car : Memory Block , Fixed Size RememberSet RememberSet Car root A B C A’ B’ C’ set Train : Car( ) Car
  • 86.
    Java Performance 34 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Car 1-1 Car 1-2 Train 1 {R1,E} A B C D E F R1 Car 2-1 Train 2 {R2,B} R2 G
  • 87.
    Java Performance 34 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Free Car Car 1-1 Car 1-2 Train 1 {C} D E F C R1 Car 2-1 Train 2 {R2,B} R2 G Car 3-1 Train 3 {R1} A B
  • 88.
    Java Performance 34 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm Free Car Free Car Free Car Free Train R1 Car 2-1 Train 2 {R2,B} R2 G Car 3-1 Train 3 {R1} A B
  • 89.
    Java Performance 35 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Train Algorithm • Suspend • Suspend • Fragmentation
  • 90.
    Java Performance 36 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Garbage Collection Algorithm • Adaptive Algorithm – Algorithm Trade Off  Algorithm – Adaptive Algorithm Algorithm – Heap Algorithm – Hotspot Ergonomic , IBM Tilt – Application
  • 91.
    Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Hotspot JVM
  • 92.
    Java Performance 38 artdb@ex-em.com | performeister.tistory.com | twitter @novathinker Hotspot JVM Garbage Collection 1) Garbage Collection of Hotspot JVM 2) Heap of Hotspot JVM 3) Garbage Collector 4) Serial Collector 5) Incremental Collector 6) Parallel Collector 7) Parallel Compacting Collector 8) CMS Collector 9) Garbage First Collector
  • 93.
    Java Performance 39 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collection of Hotspot JVM – Weak Generational Hypothesis • High Infant Mortality • Few References from Older to Younger Objects Exists – Young Generation GC Algorithm • Speed – Fast Allocation & TLAB – Old Generation GC Algorithm • – Card Table & Write Barrier
  • 94.
    Java Performance 40 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Fast Allocation & TLAB T T T T T Synchronization 1 2 3 4 5 Wait Allocation T T T T T 1 2 3 4 5 TLAB Allocation Allocation Allocation Allocation Allocation
  • 95.
    Java Performance 41 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Fast Allocation & TLAB – Memory – Bump-the-Pointer – Multi Thread – Hotspot JVM TLAB (Thread Local Allocation Buffer) • Thread • TLAB • Allocation code – 10 native instructions
  • 96.
    Java Performance 42 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Card Table Write Barrier – 1 Byte Card / 512 Byte of Old Generation – Old to Young Reference – Write Barrier • Bytecode Interpreter • 2 native instructions Young Generation Old Generation Card Table
  • 97.
    Java Performance 43 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collection of Hotspot JVM – Garbage Collection • Minor Collection : Young Generation • Major Collection : Old Generation – Full Collection – Method Area GC Major Full
  • 98.
    Java Performance 44 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Heap of Hotspot JVM Survivor 1 Survivor 2 Eden Tenured Permanent Young Generation Old Generation Method Area GC
  • 99.
    Java Performance 45 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • JVM Option – Standard Option : JVM Option :- – Non-Standard Option • JVM • , Parameter • -X Option : Macro • -XX Option : Micro
  • 100.
    Java Performance 46 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Automatic Selection – Java5 Garbage Collector, Heap Size – Hardware Resource OS – Sever Class Client Class
  • 101.
    Java Performance 47 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Automatic Selection – Server Class • :2 CPU, 2GB Physical Mem. • 32bit Windows • Default Garbage Collector Parallel Collector • Initial Heap Size – 1GB 1/64 * Physical Memory – 1GB 32MB • Max Heap Size : 1GB ¼ * Physical Mem. • Server Runtime Compiler
  • 102.
    Java Performance 48 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Automatic Selection – Client Class • Server Class • Default Garbage Collector Serial Collector • Initial Heap Size : 4MB • Max Heap Size : 64MB • Client Runtime Compiler
  • 103.
    Java Performance 49 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Automatic Selection – Option • -server : Server Class • -client : Client Class
  • 104.
    Java Performance 50 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector – Serial Collector • Hotspot JVM Default Garbage Collector • Default Collector • Young Generation : Generational Algorithm • Old Generation : Mark-and-Compacting Algorithm
  • 105.
    Java Performance 51 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector – Parallel Collector • (Throughput) Garbage Collector • Throughput Garbage Collector • Young Generation • Young Generation : Parallel Copy Algorithm • Old Generation : Mark-and-Compacting Algorithm
  • 106.
    Java Performance 52 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector – Parallel Compacting Collector • Parallel Collector Old Generation • Java SE 5.0 update 6 • Young Generation : Parallel Copy Algorithm • Old Generation : Parallel Compacting Algorithm
  • 107.
    Java Performance 53 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector – CMS Collector • CMS : Concurrent Mark-Sweep • • Old Generation Pause Time (Low Pause Garbage Collector) • Young Generation : Parallel Copy Algorithm • Old Generation : Concurrent Mark-and- Sweep Algorithm
  • 108.
    Java Performance 54 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector – Incremental Collector • Low Pause Garbage Collector • Train Collector • Young Generation : Generational Algorithm • Old Generation : Train Algorithm
  • 109.
    Java Performance 55 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector – Garbage First Collector • Java SE 6 Update 14 • Train Algorithm • Generation • Heap Region Young , Old Area • Realtime Low Pause
  • 110.
    Java Performance 56 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Young, Old Generation Serial (Single CPU Use) – Suspend during Collecting – Client Class Collector –
  • 111.
    Java Performance 57 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Young Generation Collection : Generational Young Eden A Survivor1 - From Survivor2 - To B C Empty Old
  • 112.
    Java Performance 57 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Young Generation Collection : Generational Minor GC Young Eden A Survivor1 - From Survivor2 - To B C A’ B’ C’ Old
  • 113.
    Java Performance 57 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Young Generation Collection : Generational Young Eden Empty Survivor1 - From Survivor2 - To Empty A’ B’ C’ Old
  • 114.
    Java Performance 58 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector Young Eden A Survivor1 - To Survivor2 - From Empty B M Old
  • 115.
    Java Performance 58 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector Minor GC Young Eden Empty Survivor1 - To Survivor2 - From A’ B’ Empty Old M’
  • 116.
    Java Performance 59 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Old Generation Collection : Mark-and-Compacting Old
  • 117.
    Java Performance 59 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Old Generation Collection : Mark-and-Compacting Mark Old √ √ √
  • 118.
    Java Performance 59 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Old Generation Collection : Mark-and-Compacting Sweep Old √ √ √
  • 119.
    Java Performance 59 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – Old Generation Collection : Mark-and-Compacting Sliding Compaction Old √ √ √ Sliding Compaction : Fragmentation
  • 120.
    Java Performance 60 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Serial Collector – JVM Option • -XX:+UseSerialGC : J2SE5.0, update 6 Serial Collector • -XX:MaxTenuringThreshold=<value> : Aging , default 31 • -XX:PretenureSizeThreshold=<value> : Old Generation directly Allocation • -XX:+PrintTenuringDistribution : Promotion
  • 121.
    Java Performance 61 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Memory, Multi-CPU – GC Multi Thread – Large Young Generation – Server Class Default Garbage Collector (CPU 1 ) – Old Generation Collection : Serial Collector
  • 122.
    Java Performance 62 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Young Generation Collection : Parallel Copy Serial Collector Parallel Collector Stop & Copy
  • 123.
    Java Performance 62 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Young Generation Collection : Parallel Copy Serial Collector Parallel Collector Stop & Copy
  • 124.
    Java Performance 62 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Young Generation Collection : Parallel Copy Serial Collector Parallel Collector Stop & Copy
  • 125.
    Java Performance 63 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Promotion Buffer • Parallel Local Allocation Buffer(PLAB) • Thread • Promotion Thread Promotion Buffer • Fragmentation – GC Thread – Old Generation Size
  • 126.
    Java Performance 64 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Promotion Buffer T1 T2 T1 T2 Promotion Buffer
  • 127.
    Java Performance 65 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Option • -XX:+UseParallelGC : Parallel Collector (CMS Collector ) • -XX:ParallelGCThreads=<value> : GC Thread default CPU
  • 128.
    Java Performance 66 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector – Ergonomics Option • -XX:MaxGCPauseMills=<value> (1.5+) : Maximum Pause Time Goal Pause Time • -XX:GCTimeRatio=<value> (1.5+) : Throughput Goal , default 1% GC Time • -XX:+UseAdaptiveSizePolicy (1.4.1+) : Young/Old Sizing
  • 129.
    Java Performance 67 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector • -XX:YoungGenerationSizeIncrement=<value> : Young Growing Percent, Default = 20 (1.5+) •- XX:TenuredGenerationSizeIncrement=<value> : Old Growing Percent, Default = 20 (1.5+) •- XX:AdaptiveSizeDecrementScaleFactor=<value > : Growing Shrink , Default = 4 (1.5+) • -XX:+AggressiveHeap : Physical Memory Max Heap Hardware Resource
  • 130.
    Java Performance 68 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Collector • -XX:GCHeapFreeLimit=<value> (1.4.1+) : GC Free Space Heap (default 5) -XX:+UseParallelGC GC OOME • -XX:GCTimeLimit=<value> (1.4.1+) : GC (default 90) -XX:+UseParallelGC GC OOME
  • 131.
    Java Performance 69 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Parallel Collector Old Generation Collection Algorithm – Parallel Collector – Multi CPU – Old Generation Collection – Young Generation Collection • Parallel Collector • Parallel Copy Algorithm
  • 132.
    Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Old Generation Collection : Parallel Compaction Parallel Compacting Collector Mark Phase Summary Phase Compaction Phase
  • 133.
    Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Old Generation Collection : Parallel Compaction Parallel Compacting Collector Mark Phase Summary Phase Compaction Phase
  • 134.
    Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Old Generation Collection : Parallel Compaction Parallel Compacting Collector Mark Phase Summary Phase Compaction Phase
  • 135.
    Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Old Generation Collection : Parallel Compaction Parallel Compacting Collector Mark Phase Summary Phase Compaction Phase
  • 136.
    Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Old Generation Collection : Parallel Compaction Parallel Compacting Collector Mark Phase Summary Phase Compaction Phase
  • 137.
    Java Performance 70 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Old Generation Collection : Parallel Compaction Parallel Compacting Collector Mark Phase Summary Phase Compaction Phase
  • 138.
    Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Mark Phase • Generation Region • Live Object Marking • Parallel Work
  • 139.
    Java Performance 71 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Mark Phase • Generation Region • Live Object Marking • Parallel Work       
  • 140.
    Java Performance 72 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Summary Phase • Region Operation • Single Work • Density • Dense Prefix • Dense Prefix GC       
  • 141.
    Java Performance 72 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Summary Phase • Region Operation • Single Work • Density • Dense Prefix • Dense Prefix GC        Dense Prefix
  • 142.
    Java Performance 72 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Summary Phase • Region Operation • Single Work • Density • Dense Prefix • Dense Prefix GC        Dense Prefix
  • 143.
    Java Performance 73 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Compaction Phase • Thread Region Collecting • Source, Destination • Live Object Destination Compaction       
  • 144.
    Java Performance 73 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Compaction Phase • Thread Region Collecting • Source, Destination • Live Object Destination Compaction Destination Source       
  • 145.
    Java Performance 73 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Compaction Phase • Thread Region Collecting • Source, Destination • Live Object Destination Compaction Destination Source        T1 T2
  • 146.
    Java Performance 73 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Compaction Phase • Thread Region Collecting • Source, Destination • Live Object Destination Compaction Destination Source        T1
  • 147.
    Java Performance 73 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Compaction Phase • Thread Region Collecting • Source, Destination • Live Object Destination Compaction       
  • 148.
    Java Performance 74 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Parallel Compacting Collector – Option • -XX:+UseParallelOldGC (+Java6) : Parallel Compaction Collector • -XX:+UseParallelOldGCCompacting (+Java6) : Parallel Compaction , Default True • -XX:+UseParallelDensePrefixUpdate (+Java6) : Dense Prefix , Default True
  • 149.
    Java Performance 75 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Fast Elapsed Time – Old Generation – Low Latency Collector – – GC Pause Time – Young Generation Collection • Parallel Collector
  • 150.
    Java Performance 76 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection : Concurrent Mark-Sweep Concurrent Mark-Sweep Collector
  • 151.
    Java Performance 76 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection : Concurrent Mark-Sweep Concurrent Mark-Sweep Collector Initial Mark Phase
  • 152.
    Java Performance 76 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection : Concurrent Mark-Sweep Concurrent Mark-Sweep Collector Initial Mark Phase Concurrent Mark Phase
  • 153.
    Java Performance 76 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection : Concurrent Mark-Sweep Concurrent Mark-Sweep Collector Initial Mark Phase Concurrent Mark Phase Remark Phase
  • 154.
    Java Performance 76 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection : Concurrent Mark-Sweep Concurrent Mark-Sweep Collector Initial Mark Phase Concurrent Mark Phase Remark Phase Concurrent Sweep Phase
  • 155.
    Java Performance 77 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection • Initial Mark Phase – Serial Phase – Direct Referenced Object • Concurrent Mark Phase – Serial Phase – Application – Direct Reference Object
  • 156.
    Java Performance 78 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Old Generation Collection • Remark Phase – Parallel Phase – Marking Mark • Concurrent Sweep Phase – Serial Phase – Dead Object Reclaim – Compaction
  • 157.
    Java Performance 79 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – No Compaction!!! • , But Free Space  FreeList • Fast Allocation : Promotion Young     
  • 158.
    Java Performance 79 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – No Compaction!!! • , But Free Space  FreeList • Fast Allocation : Promotion Young
  • 159.
    Java Performance 80 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector • Fragmentation  Object Size Tracking,  Free Block
  • 160.
    Java Performance 81 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Concurrent Mark Allocation – Floating Garbage • Concurrent Mark Garbage • Next GC • Memory
  • 161.
    Java Performance 82 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Floating Garbage
  • 162.
    Java Performance 83 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Scheduling Collection • Old Generation Full • Old Generation Full GC • Minor GC Remark Minor GC • Current Heap • : Heap 68%
  • 163.
    Java Performance 84 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Option • -XX:+UseConcMarkSweepGC (1.4.0+) : CMS Collector (+XX:UseParallelGC ) • -XX:+UseParNewGC (1.4.1+) : Young Parallel Option • -XX:CMSInitiatingOccupancyFraction (1.4.1+) : Current Old Generation
  • 164.
    Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Concurrent phase • Concurrent Phase
  • 165.
    Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Concurrent phase • Concurrent Phase Initial Mark Phase
  • 166.
    Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Concurrent phase • Concurrent Phase Initial Mark Phase Concurrent Mark Phase
  • 167.
    Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Concurrent phase • Concurrent Phase Initial Mark Phase Concurrent Mark Phase Remark Phase
  • 168.
    Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Concurrent phase • Concurrent Phase Initial Mark Phase Concurrent Mark Phase Remark Phase Concurrent Sweep Phase
  • 169.
    Java Performance 85 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Concurrent phase • Concurrent Phase Initial Mark Phase CPU Concurrent Mark Phase GC Remark Phase Concurrent Sweep Phase
  • 170.
    Java Performance 86 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Incremental Mode • Minor GC Concurrent Phase • Duty Cycle Concurrent Collector • Duty Cycle –1 CPU – Minor GC – I-CMS ( ) or
  • 171.
    Java Performance 87 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector – Option • -XX:+CMSIncrementalMode (1.4.2+) : Incremental Mode (default False) CMS CMSInitiatingOccpancyFraction • -XX:+CMSIncrementalPacing (1.4.2+) : Duty Cycle (default False)
  • 172.
    Java Performance 88 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector • -XX:CMSIncrementalDutyCycle=<value> (1.4.2+) : Duty Cycle (default 50) Minor GC (0~100) 50 • -XX:CMSIncrementalDutyCycleMin=<value> : Duty Cycle (0~100) (Default 10) (1.4.2+)
  • 173.
    Java Performance 89 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector •- XX:CMSIncrementalSafetyFactor=<value>(1.4.2 +) : Duty Cycle (Default 10) • -XX:CMSIncrementalOffset=<value> (1.4.2+) : Duty Cycle Minor GC (0~100) (Default 0)
  • 174.
    Java Performance 90 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • CMS Collector • -XX:CMSExpAvgFactor=<value> (1.4.2+) : % (Default 25) (0~100)
  • 175.
    Java Performance 91 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Incremental Collector – Train Collector – Old Generation Pause Time – Young Generation Collection : Stop-the- Copy – Old Generation Collection : Train • Old small GC • OOME Mark-and-Compaction – Old Fragmentation
  • 176.
    Java Performance 92 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Incremental Collector
  • 177.
    Java Performance 93 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Incremental Collector – Minor GC • Minor GC Major GC (overhead) • Minor GC Old GC • Throughput Default collector • Pause Time
  • 178.
    Java Performance 94 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Incremental Collector – Collector – Option • -Xincgc : Incremental GC : -XX:+UseParallelGC, -XX:+UseParNewGC
  • 179.
    Java Performance 95 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage Collector Garbage Young Generation Old Generation Option Collector Collection Algorithm Collection Algorithm Serial Collector -XX:+UseSerialGC Generational Mark-and-Compacting (Default Collector) Parallel Collector -XX:+UseParallelGC Parallel Copy Mark-and-Compacting Parallel Compacting -XX:+UseParallelOldGC Parallel Copy Parallel Compacting Collector -XX: Concurrent CMS Collector +UseConcMarkSweepG Parallel Copy C Mark-Sweep Incremental -Xincgc Generational Train Collector
  • 180.
    Java Performance 96 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Option • -XX:+DisableExplicitGC : System.gc() • -XX:+PrintGC • -XX:+PrintGCDetails • -XX:+PrintGCTimeStamps • -XX:+PrintHeapAtGC • -Xloggc:<file> • -verbosegc
  • 181.
    Java Performance 97 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Java SE 6 update 14 – Realtime • Y ms interval x ms GC – Single Generation • Generation • Heap region – 1MB Best Region • Young Generation : a Set of Regions – Allocation Region Young Generation • Old Generation : a Set of Regions
  • 182.
    Java Performance 98 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First • Concurrent Marker Heap Region live data • Live Data Garbage Region • Garbage Region
  • 183.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection
  • 184.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection
  • 185.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection Young GC (Evacuation Pause)
  • 186.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection Young GC (Evacuation Pause) Concurrent Mark - Marking
  • 187.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection Young GC (Evacuation Pause) Concurrent Mark - Marking Concurrent Mark - Remarking
  • 188.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection Young GC (Evacuation Pause) Concurrent Mark - Marking Concurrent Mark - Remarking Old Region Reclaim - Remark
  • 189.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection Young GC (Evacuation Pause) Concurrent Mark - Marking Concurrent Mark - Remarking Old Region Reclaim - Remark Old Region Reclaim – Evacuation Pause
  • 190.
    Java Performance 99 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection Young GC (Evacuation Pause) Concurrent Mark - Marking Concurrent Mark - Remarking Old Region Reclaim - Remark Old Region Reclaim – Evacuation Pause Compaction
  • 191.
    Java Performance 100 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Young GC (Evacuation Pause) – Live Object Survivor Region Old Region – Stop-the-Copy – Parallel
  • 192.
    Java Performance 100 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Young GC (Evacuation Pause) – Live Object Survivor Region Old Region – Stop-the-Copy – Parallel
  • 193.
    Java Performance 100 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Young GC (Evacuation Pause) – Live Object Survivor Region Old Region – Stop-the-Copy – Parallel
  • 194.
    Java Performance 101 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Concurrent Marking – Mark : Evacuation Pause Initial Mark – Remark : Region Live Empty Region reclaim Stop the World
  • 195.
    Java Performance 101 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Concurrent Marking – Mark : Evacuation Pause Initial Mark – Remark : Region Live Empty Region reclaim Stop the World
  • 196.
    Java Performance 102 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Reclaim Old Region – Live Object Region – old Region collected
  • 197.
    Java Performance 102 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Reclaim Old Region – Live Object Region – old Region collected
  • 198.
    Java Performance 103 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Garbage First Collection • Compaction – Large chunk Free Space – Fragmentation – Fast Allocation » Free List » Linear » TLAB – - Copy Pause Time
  • 199.
    Java Performance 104 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com Hotspot JVM • Garbage First Collector – Options • -XX:+UnlockExperimentalVMOptions • -XX:+UseG1GC
  • 200.
    Java Performance artdb@ex-em.com | performeister.tistory.com | twitter @novathinker IBM JVM
  • 201.
    Java Performance 106 artdb@ex-em.com | performeister.tistory.com | twitter @novathinker IBM JVM Garbage Collection 1) Heap of IBM JVM 2) Heap Expansion Shrink 3) Garbage Collector 4) Optimize for Throughput 5) Optimize for Pause Time 6) Generation Concurrent 7) Subpooling
  • 202.
    Java Performance 107 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout – 1.4 Heap – Single Space heapbase heaplimit heaptop • Heap • Heapbase : Heap • Heaplimit : (movable) • Heaptop : Heap
  • 203.
    Java Performance 108 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout – 1.4 Heap heapbase heaplimit heaptop Heap K Cluster P Cluster Wilderness Heap cache or LOA
  • 204.
    Java Performance 109 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout • Kcluster : Pinned Class Object – Default 1280 class entries – 1 Class Entry 300byte(32it), 560byte(64bit) • Pcluster : Pinned Object • Kcluster Pcluster • Pcluster 2KB Pcluster • Pcluster
  • 205.
    Java Performance 110 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout – Large Object Area • Large Object • 64KB Object • Heap • -Xloratio LOA (0.5 ~ 0.95 ) • Java5 -Xloainitial (default 0.05, 5%), - Xloamaximum(default 0.5, 50%) • 1MB Object
  • 206.
    Java Performance 111 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout Garbage Object Live Object
  • 207.
    Java Performance 112 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout - Subpool – Free Chunk FreeList – -Xgcpolicy: subpool – Pool FreeList, CPU Pool 1 Small Size Freelist Middle Size Freelist 2 3 4 5 … Large Size Freelist n
  • 208.
    Java Performance 113 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Layout – Java 5 Heap – Heap Generational Heap – -Xgcpolicy: gencon Allocation Space Survivor Space Tenured Space Nursery Tenured
  • 209.
    Java Performance 114 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Allocation – Heap Lock • 512byte Object • Heap Lock Free List • GC • Free Chunk Heap Lock – Dark Matter • Free Chunk 512 byte Freelist • Dark Matter compaction
  • 210.
    Java Performance 115 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Heap – Heap Options • -Xmx<value> , -Xms<value> • -Xmaxf<percentage> : Free Space (default 0.6, 60%) • -Xminf<percentage> : Free Space (default 0.3, 30%) • -Xloa :loa , subpool default • -Xmaxe<size> heap expansion (default 0)
  • 211.
    Java Performance 116 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Heap – Heap Options • -Xk<classes> (~1.4.2) – Kcluster – class – Class 1.1~1.15 • -Xp<initial>,<overflow> (~1.4.2) – Pcluster – initial Size OverFlow
  • 212.
    Java Performance 117 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Expansion Shrink – Expansion • Expansion · Garbage Collector Allocation · Free Space –Xminf · GC –Xmaxt
  • 213.
    Java Performance 118 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Expansion Shrink – Expansion • Expansion · Free Space -Xmaxf –Xmaxf · –Xmaxe –Xmaxe · –Xmine –Xmine · Expansion 32bit 512byte 64bit 1024byte
  • 214.
    Java Performance 119 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Expansion Shrink – Shrink • Shrink · Garbage Collection · -Xmaxf 100% · System.gc() free space –Xminf · Heap 3 GC • free space –Xmaxf Shrink
  • 215.
    Java Performance 120 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Heap Expansion Shrink – Shrink • Shrink – -Xmaxf –Xms – 32bit 512byte 64bit 1024byte
  • 216.
    Java Performance 121 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Heap – Heap Size Options • -Xmaxf<percentage> : Free Space (default 0.6, 60%) • -Xminf<percentage> : Free Space (default 0.3, 30%) • -Xmaxe<size> heap expansion (default 0) • -Xmine<size> heap expansion (default 1MB) • -Xmaxt<percentage>
  • 217.
    Java Performance 122 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Heap – Garbage Collection Options • -Xgcpolicy:<optthruput | optavgpause | gencon | subpool> : Garbage Collector • -Xdisableexplicitgc : System.gc() • -Xverbosegclog:<path to file>[X,Y] : file gc log : X,Y integer X file , Y GC Cycle • -verbose:gc : gc
  • 218.
    Java Performance 123 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Heap – Garbage Collection Options • -Xcompactexplicitgc – System.gc() Compaction (default) • -Xnocompactexplicitgc – System.gc() Compaction • -Xcompactgc – GC Compaction (default) • -Xnocompacgc – GC Compaction
  • 219.
    Java Performance 124 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Heap – Garbage Collection Options • -Xcompactexplicitgc – System.gc() Compaction (default) • -Xnocompactexplicitgc – System.gc() Compaction • -Xcompactgc – GC Compaction (default) • -Xnocompacgc – GC Compaction
  • 220.
    Java Performance 125 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Garbage Collector – -Xgcpolicy – Optimize for throughput (optthruput) • Default garbage collector • – Optimize for pause time (optavgpause) • Concurrent GC • GC pause time •
  • 221.
    Java Performance 126 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • IBM JVM Garbage Collector – Generational Concurrent (gencon) • Object • Generational Heap – Subpooling (subpool) • Default algorithm • 16 CPU SMP
  • 222.
    Java Performance 127 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Collector Algorithm Mark Phase Sweep Phase Compaction Phase 1.4 - Incremental optthruput Parallel Mark Parallel bitwise Sweep Compaction, 5.0–Parallel Compaction 1.4-Parallel bitwise 1.4 - Incremental Sweep, Compaction, optavgpause Concurrent Mark 5.0-Concurrent 5.0-Mostly Concurrent Sweep Compaction Scavenge Copy of New Area Global Collection of Old Area gencon Mostly Concurrent Concurrent Mark Parallel bitwise Sweep Compaction 1.4 - Incremental subpool Parallel Mark Parallel bitwise Sweep Compaction, 5.0–Parallel Compaction
  • 223.
    Java Performance 128 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Application – Default Garbage Collector – Parallel Algorithm – GC Application Suspend – Mark-Sweep phase GC Cycle – Compaction Fragmentation AF • Allocation Failure(AF) :
  • 224.
    Java Performance 129 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Mark-Sweep & Compaction
  • 225.
    Java Performance 129 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Mark-Sweep & Compaction
  • 226.
    Java Performance 129 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Mark-Sweep & Compaction Mark Phase  
  • 227.
    Java Performance 129 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Mark-Sweep & Compaction
  • 228.
    Java Performance 129 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Mark-Sweep & Compaction
  • 229.
    Java Performance 129 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput – Mark-Sweep & Compaction
  • 230.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread
  • 231.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread
  • 232.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread Mark
  • 233.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread Mark Sweep
  • 234.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread Mark Sweep
  • 235.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread Mark Sweep Compaction
  • 236.
    Java Performance 130 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – GC Thread Mark Sweep Compaction
  • 237.
    Java Performance 131 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Mark Phase : Parallel Mark • 1.4 : Mark Stack • Java 5 : Work Packet – Sweep Phase : Parallel Bitwise Sweep – Compaction Phase • 1.4 : Incremental Compaction • Java 5 : Parallel Compaction
  • 238.
    Java Performance 132 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Mark Phase : Parallel Mark • Tracing Live Object Mark • Live Object – Register, stack, static, jni Object – Move dosed bit on – Mark bit – Mark Stack – Mptr class object mark – Array array entry trace
  • 239.
    Java Performance 133 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Mark Phase : Parallel Mark • Mark Stack (1.4) – Trace Live Object reference – Marking Thread 4KB Mark Stack – Marking Thread thread Stack scan reference push, mark bit – Garbage Collector Pop Object Mark – Array Array Entry Mark – MSO(Mark Stack Overflow) » Object NotYetScanned bit Global Flag » Object » Thread » Heap
  • 240.
    Java Performance 134 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Mark Phase : Parallel Mark • Work Packet(5.0) – Java5 Work Packet Pool – Work Packet Mark Stack – Marking Thread 2 Work Packet » Input Packet : reference pop » Output Packet : Unmarked Object Push » Reference Output Packet Push Mark
  • 241.
    Java Performance 135 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Mark Phase : Parallel Mark • Work Packet(5.0) – Root Object mark bit reference output packet – Root Object Reference input Packet Pop Object – List
  • 242.
    Java Performance 136 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Mark Phase : Parallel Mark • Parallel Mark(1.4) – Mark – application Thread master gc thread helper thread – Helper Thread 4KB Mark Stack Shareable Queue 2KB Mark Queue • Parallel Mark(5.0) – helper Thread Work Packet Pool
  • 243.
    Java Performance 137 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Sweep Phase : Parallel Bitwise Sweep • Alloc bits Mark Bits Reference Allocated Object • Bit Wised Technique – Mark bits 0 Free Space – 512 byte freelist • Sweep mark bits alloc bits
  • 244.
    Java Performance 138 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com IBM JVM • Optimize for throughput Garbage Object Live Object
  • 245.
    Java Performance 139 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Sweep Phase : Parallel Bitwise Sweep • Parallel Bit-wised Sweep – Sweep – Heap N Section » 1.4 : N Helper Thread *32, heap size / 16MB » 5.0 : N heap size / 256KB, 256KB fixed Size – Helper Thread Section Scan & Sweep – Section Free List
  • 246.
    Java Performance 140 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Compaction – GC – Sweep Allocation Request – System.gc() AF Compaction – TLH TLH 1000Byte(1.4) 1024Byte(5.0) – Free Space Active heap 5% 128MB
  • 247.
    Java Performance 141 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • 1.4 Compaction – Unmovable Object – Incremental Compaction Algorithm • 5.0 Compaction – Parallel Compaction – Unmovable Object
  • 248.
    Java Performance 142 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Incremental Compaction(1.4) – Compaction Compaction – 128MB Heap – Heap Section Section Compaction – 1.4.2 Default – Mark Phase Section Free Space – Object , , Pointer – Section GC
  • 249.
    Java Performance 143 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – UnMovable Object (~1.4.2) • Dosed Object – Stack(Local Variable, Method Parameter) Object – Dosed bit on, • Pinned Object – JNI, Class Object, Other Pinned Object – Pinned bit On,
  • 250.
    Java Performance 144 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – UnMovable Object pinned dosed Compaction pinned dosed
  • 251.
    Java Performance 145 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Incremental Compaction(1.4) Dark Matter One Section per Thread
  • 252.
    Java Performance 146 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Parallel Compaction(1.5) – Heap n area – Area Heap Size CPU, thread – Thread Area Compaction – » Move Step : Object » Fix-up Step : Object Reference
  • 253.
    Java Performance 147 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Parallel Compaction(1.5) – Move Step T1 T2 T1 T2
  • 254.
    Java Performance 148 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Parallel Compaction(1.5) – Move Step » Thread Source Area Destination Area » Object Moving Pointer bitmap » Hole Area » Area Size Hole Load Balancing
  • 255.
    Java Performance 149 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Parallel Compaction(1.5) – Fix-up Step » reference update » Block table » Block 256Kb Heap » Fix-up Block » Block object , » Object Block
  • 256.
    Java Performance 150 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Compaction Phase • Parallel Compaction(1.5) – Block Table » Block 1 Pointer » Block Object – Object Bitmap » Old Bitmap : Move Object (Mark Phase) » New Bitmap : Move Object (Moving Step)
  • 257.
    Java Performance 151 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for throughput – Options • -Xgcthreads<thread > – GC Parallel Thread – Default CPU – 1, Min 1, Max CPU • -Xgcworkpackets<numbers> – Workpacket default maximum heap size packet • -Xpartialcompactgc – Incremental compaction (1.4.2 default) – 5.0 not set, full compaction • -Xnopartialcompactgc – Incremental Compaction
  • 258.
    Java Performance 152 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – GC Pause Time – Background thread Application concurrent mark, sweep – Mark Phase : Concurrent Mark – Sweep Phase • 1.4 -Parallel bitwise Sweep, • Java 5 -Concurrent Sweep – Compaction Phase • 1.4 - Incremental Compaction, • Java 5 -Mostly Concurrent Compaction
  • 259.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~
  • 260.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~
  • 261.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark
  • 262.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Sweep
  • 263.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Sweep
  • 264.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Sweep Compaction
  • 265.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Sweep Compaction
  • 266.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Sweep Compaction
  • 267.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Concurrent Mark Sweep Compaction
  • 268.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Concurrent Mark Sweep Concurrent Sweep Compaction
  • 269.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Concurrent Mark Sweep Concurrent Sweep Compaction
  • 270.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Concurrent Mark Sweep Concurrent Sweep Compaction Compaction
  • 271.
    Java Performance 153 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time ~ 1.4.2 Java5 ~ Concurrent Mark Concurrent Mark Sweep Concurrent Sweep Compaction Compaction
  • 272.
    Java Performance 154 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Concurrent Mark • Thread Stack Scan root • Trace background thread • Thread marking – trace Object – Object reference write barrier heap – Heap 512byte 1byte card card table – Reference object 0x01
  • 273.
    Java Performance 155 Java Performance Fundamental | twitter @novathinker IBM JVM artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Concurrent Mark • Object Allocation ‘tax’ rate – STW – heap Marking – Garbage Collection Thread Application Thread – Garbage Collection Tax
  • 274.
    Java Performance 156 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Stop the World Phase • Root Scan • Marked Card • Sweep • Floating Garbage
  • 275.
    Java Performance 157 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Concurrent Sweep Phase • Java 5 • 1.4.2 Parallel Bitwise Sweep Algorithm • Parallel bit-wise Sweep • Heap Section Allocation Sweep • – Sweep Analysis » Markbit Data Section » Freelist – Connection
  • 276.
    Java Performance 158 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Concurrent Sweep Phase • Heap Section parallel bitwise sweep • Sweep STW • Allocation Process Concurrent Sweep • Compaction • Mark .
  • 277.
    Java Performance 159 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Java 5 • 1.4 Incremental Compaction • Compaction • STW Partial Move – Sweep Compact • Fixup Concurrently – Compaction Pause Time
  • 278.
    Java Performance 160 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Move Step – Application » Map2 Heap Fixup view » Map2 : Virtual Address range Physical Memory Map – Compact Area » Sweep Object Layout Compaction Section – Move – Object Compaction
  • 279.
    Java Performance 161 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • STW Fix-up – Root Reference Fixup – Heap page » Object Heap Page » Object Heap Page Unfixed – Lock » Free Page Fixed – Application Thread
  • 280.
    Java Performance 162 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up – unfixed page fixed – Unfixed(protected)  Busy  Fixed(unprotected) – Application fixed Page – Exclusive Fixer : Fix Thread – Collector Thread Fix – Trapped Thread : Application Thread Unfixed page Trap Routine
  • 281.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Unfixed Unfixed Unfixed Unfixed
  • 282.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Collector Unfixed Unfixed Unfixed Unfixed Unfixed
  • 283.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Exclusive Collector Unfixed Fixer Unfixed Unfixed Unfixed Unfixed
  • 284.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Exclusive Collector Unfixed Fixer Unfixed Unfixed Unfixed Unfixed
  • 285.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Exclusive Collector Unfixed Busy Fixer Unfixed Unfixed Unfixed Unfixed
  • 286.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Exclusive Collector Unfixed Fixed Busy Fixer Unfixed Unfixed Unfixed Unfixed
  • 287.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Exclusive Collector Unfixed Fixed Busy Fixer Unfixed Unfixed Unfixed Unfixed
  • 288.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Collector Unfixed Fixed Busy Unfixed Unfixed Unfixed Unfixed
  • 289.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Unfixed Unfixed Unfixed
  • 290.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Exclusive Collector Fixer Unfixed Unfixed Unfixed Unfixed
  • 291.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Exclusive Collector Fixer Unfixed Unfixed Unfixed Unfixed
  • 292.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Exclusive Collector Fixer Unfixed Busy Unfixed Unfixed Unfixed
  • 293.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Exclusive Collector Fixer Unfixed Busy Fixed Unfixed Unfixed Unfixed
  • 294.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Exclusive Collector Fixer Unfixed Busy Fixed Unfixed Unfixed Unfixed
  • 295.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Unfixed Unfixed
  • 296.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Mutator Unfixed Unfixed
  • 297.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Mutator Unfixed Unfixed
  • 298.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed blocke Mutator d Unfixed Unfixed
  • 299.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Mutator Unfixed Unfixed
  • 300.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Trapped Mutator Unfixed Unfixed
  • 301.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Exclusive Trapped Mutator Fixer Unfixed Unfixed
  • 302.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Exclusive Trapped Mutator Fixer Unfixed Busy Unfixed
  • 303.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Exclusive Trapped Mutator Fixer Unfixed Busy Fixed Unfixed
  • 304.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Trapped Mutator Unfixed Busy Fixed Unfixed
  • 305.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Mutator Unfixed Busy Fixed Unfixed
  • 306.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Mutator Unfixed Busy Fixed Unfixed
  • 307.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Mutator Unfixed Busy Fixed Unfixed
  • 308.
    Java Performance 163 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Mostly Concurrent Compaction • Concurrent Fix-up Unfixed Fixed Busy Collector Unfixed Busy Fixed Unfixed Unfixed Busy Fixed Unfixed
  • 309.
    Java Performance 164 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Options • -Xconcurrentbackground<number> – Concurrent mark background GC Application Thread – Default 1 • -Xconcurrentlevel<number> – Tax rate – heap Tax – Default 8
  • 310.
    Java Performance 165 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Optimize for pause time – Options • -Xconmeter:<soa:loa:dynamic> – Concurrent Mark Allocation Tax – Dynamic – Default soa (Small Object Area)
  • 311.
    Java Performance 166 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent – Generation Heap Allocation Space Survivor Space Tenured Space New Area (Nursery) Old Area
  • 312.
    Java Performance 167 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent – Nursery : Object • Allocate Space : Object • Survivor Space : Allocate Space Allocation Failure Scavenge-Copy (GC : Stop-the-Copy) : Live Object • Allocate Space Survivor Space Flip
  • 313.
    Java Performance 168 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent – Tenured : Object Promotion • 14 GC Aging Promotion (adaptive) • Optavgpause concurrent mark • But sweep concurrent – Tilt Ratio : Adaptive Survivor Allocation Space Survivor Space Allocation Space Space 50% 80%
  • 314.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent
  • 315.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent
  • 316.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent
  • 317.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark
  • 318.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark
  • 319.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark
  • 320.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark Global Collection
  • 321.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark Global Collection
  • 322.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark Global Collection
  • 323.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark Global Collection
  • 324.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark Global Collection Scavenge Copy
  • 325.
    Java Performance 169 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent Scavenge Copy Concurrent Mark Scavenge Copy Concurrent Mark Global Collection Scavenge Copy
  • 326.
    Java Performance 170 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent – Scavenge GC • New Area Garbage Collection • Stop The Copy Algorithm – Global GC • Tenured Area optavgpause Concurrent Mark • Concurrent Sweep • Nursery, tenured • GC Application Suspend • Compaction
  • 327.
    Java Performance 171 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Generation concurrent – Options • -Xmn<size> – New Area • -Xmns<size> : New Area • -Xmnx<size> : New Area • -Xmo<size> – Old Area • -Xmos<size> : Old Area • -Xmox<size> : Old Area
  • 328.
    Java Performance 172 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Subpooling – 16 CPU – Size Heap • Pool freelist • Pool sorting • Fast allocation – Allocation Heap Lock • CPU Pool
  • 329.
    Java Performance 173 IBM JVM Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com • Subpooling – Subpool • JVM Compaction Subpool • GC Sweep phase subpool • Concurrent Algorithm
  • 330.
    Java Performance 174 Java Performance Fundamental | twitter @novathinker artdb@ex-em.com | performeister.tistory.com