SlideShare une entreprise Scribd logo
1  sur  37
JVM performance
    options.
  How it works?
Dmitriy Dumanskiy
 Cogniance, Velti project
     Java Team Lead
Xmx2048M -Xms2048M
     -XX:ParallelGCThreads=8 -Xincgc
     -XX:+UseConcMarkSweepGC -XX:
+UseParNewGC -XX:+CMSIncrementalPacing
            -XX:+AggressiveOpts
     -XX:+CMSParallelRemarkEnabled
           -XX:+DisableExplicitGC
         -XX:MaxGCPauseMillis=500
            -XX:SurvivorRatio=16
         -XX:TargetSurvivorRatio=90
       -XX:+UseAdaptiveGCBoundary
   -XX:-UseGCOverheadLimit -Xnoclassgc
    -XX:UseSSE=3 -XX:PermSize=128m
       -XX:LargePageSizeInBytes=4m
Options may vary per
architecture / OS / JVM version
JVM 6 ~ 730 options

JVM 7 ~ 680 options
-X   : are non-standard (not all JVM)
-XX : are not stable
Types

Boolean : -XX:+<option> or -XX:-<option>

Numeric : -XX:<option>=<number>

String   : -XX:<option>=<string>
Categories


    Behavioral options

    Garbage Collection options

    Performance tuning options

    Debugging options
-XX:+DoEscapeAnalysis

      Analys :

    Can objects be created on stack?

    Are objects accessed from 1 thread?
-XX:+DoEscapeAnalysis

      Analys result :

    GlobalEscape

    ArgEscape

    NoEscape
NoEscape
class Cursor {
    String icon;
    int x;
    public void create() {
        Cursor c = new Cursor(); //HEAP
        c.icon = null;           //HEAP
        c.x = 0;                 //HEAP
    }
}
NoEscape → scalar replacement
class Cursor {
    String icon;
    int x;
    public void create() {
        String icon = null; //ref on stack frame
        int x = 0;           //int on stack frame
    }
}
NoEscape → scalar replacement
NoEscape → scalar replacement
-XX:+DoEscapeAnalysis

    ~20-60% locks elimination

~15-20% performance improvement
-XX:+DoEscapeAnalysis
-XX:+AggressiveOpts
                            -AggressiveOpts +AggressiveOpts

AutoBoxCacheMax                  128             20000

BiasedLockingStartupDelay        4000             500

EliminateAutoBox                 false           true

OptimizeFill                     false           true

OptimizeStringConcat             false           true
-XX:AutoBoxCacheMax=size
Sets IntegerCache.high value :

class Integer {
    public static Integer valueOf(int i) {
      if(i >= -128 && i <= IntegerCache.high)
           return IntegerCache.cache[i + 128];
      else
           return new Integer(i);
  }
}
-XX:AutoBoxCacheMax=size


 new Integer(1) vs Integer.valueOf(1)


       valueOf ~4 times faster
-XX:BiasedLockingStartupDelay=delay


  
      Biased
  
      Thin
  
      Fat
-XX:-OptimizeStringConcat
String twenty = «12345678901234567890»;
String sb = twenty + twenty + twenty +
  twenty;



String twenty = «12345678901234567890»;
String sb = new StringBuilder()
.append(twenty).append(twenty)
.append(twenty).append(twenty).toString();
-XX:-OptimizeStringConcat
String twenty = «12345678901234567890»;
String sb = new StringBuilder()
.append(twenty).append(twenty)
.append(twenty).append(twenty).toString();



              new char[16];
              new char[34];
              new char[70];
              new char[142];
-XX:+OptimizeStringConcat
String twenty = «12345678901234567890»;
String sb = new StringBuilder()
.append(twenty).append(twenty)
.append(twenty).append(twenty).toString();


              new char[80];
-XX:+OptimizeStringConcat
String twenty = «12345678901234567890»;
StringBuilder sb1 = new StringBuilder();
sb1.append(new StringBuilder()
     .append(twenty).append(twenty)
     .append(twenty).append(twenty)
);



                new char[80];
XX:+OptimizeFill
Arrays.fill(), Arrays.copyOf() or code
  patterns :


for (int i = fromIndex; i < toIndex; i++) {
            a[i] = val;
}



       Native machine instructions
XX:+EliminateAutoBox



    Removes unnecessary AutoBox operations


    Works only for Integers
-XX:+UseStringCache



Look like not used anymore
-XX:+UseCompressedStrings



    For ASCII characters:
       char[] -> byte[]
-XX:+UseCompressedOops


    Heap size up to 32Gb

    References size 50% smaller

    JVM performance boost 2-10%

    20 — 60% less memory consumption;
-XX:+UseCompressedOops
1.2
 1
0.8
0.6
0.4
0.2
 0
      32-bit   64-bit   64-bit Comp.
-XX:+EliminateLocks

synchronized (object) {
                          synchronized (object) {
   //doSomething1
                             //doSomething1
}
                             //doSomething2
synchronized (object) {
                          }
   //doSomething2
}
-XX:+EliminateLocks
synchronized (object) {
   //doSomething1
}                         synchronized (object) {
                             //doSomething1
//doSomething2               //doSomething2
                             //doSomething3
synchronized (object) {   }
   //doSomething3
}
-XX:+UseLargePages

 Translation-Lookaside Buffer
   (TLB) is a page translation
   cache that holds the most-
recently used virtual-to-physical
      address translations
-XX:CompileThreshold=n

    Client mode n = 1500
   Server mode n = 10000

More profile data — more optimizations
-XX:hashCode=n


Object.hashCode() - internal
address of the object?
-XX:hashCode=n
n is :

    0   –   Park-Miller RNG (default)

    1   –   f (address, global state)

    2   –   const 1

    3   –   sequence counter

    4   –   object address

    5   –   Thread-local Xorshift

Contenu connexe

Tendances

Manual de instalación de pentaho para windows 7
Manual de instalación de pentaho para windows 7Manual de instalación de pentaho para windows 7
Manual de instalación de pentaho para windows 7
German Pinchao
 

Tendances (20)

The Eclipse Transformer Project
The Eclipse Transformer Project The Eclipse Transformer Project
The Eclipse Transformer Project
 
Cookies & Session
Cookies & SessionCookies & Session
Cookies & Session
 
Validation Controls in asp.net
Validation Controls in asp.netValidation Controls in asp.net
Validation Controls in asp.net
 
Ch09 整合資料庫
Ch09 整合資料庫 Ch09 整合資料庫
Ch09 整合資料庫
 
Digital Forensics and Incident Response (DFIR) using Docker Containers
Digital Forensics and Incident Response (DFIR) using Docker ContainersDigital Forensics and Incident Response (DFIR) using Docker Containers
Digital Forensics and Incident Response (DFIR) using Docker Containers
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Load testing with J meter
Load testing with J meterLoad testing with J meter
Load testing with J meter
 
Memory Forensics for IR - Leveraging Volatility to Hunt Advanced Actors
Memory Forensics for IR - Leveraging Volatility to Hunt Advanced ActorsMemory Forensics for IR - Leveraging Volatility to Hunt Advanced Actors
Memory Forensics for IR - Leveraging Volatility to Hunt Advanced Actors
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_android
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
OS dan BIOS
OS dan BIOSOS dan BIOS
OS dan BIOS
 
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State management
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
Manual de instalación de pentaho para windows 7
Manual de instalación de pentaho para windows 7Manual de instalación de pentaho para windows 7
Manual de instalación de pentaho para windows 7
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
Blazor
BlazorBlazor
Blazor
 

Similaire à JVM performance options. How it works

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a month
Dmitriy Dumanskiy
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
Databricks
 
From Big GORM-centered into a cloud of fast redis nodes
From Big GORM-centered into a cloud of fast redis nodesFrom Big GORM-centered into a cloud of fast redis nodes
From Big GORM-centered into a cloud of fast redis nodes
Gailen Tecnologías
 

Similaire à JVM performance options. How it works (20)

Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gc
 
All you need to know about the JavaScript event loop
All you need to know about the JavaScript event loopAll you need to know about the JavaScript event loop
All you need to know about the JavaScript event loop
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
Engineering Fast Indexes for Big-Data Applications: Spark Summit East talk by...
 
Engineering fast indexes
Engineering fast indexesEngineering fast indexes
Engineering fast indexes
 
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a month
 
Профилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаПрофилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кода
 
Score (smart contract for icon)
Score (smart contract for icon) Score (smart contract for icon)
Score (smart contract for icon)
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
From Big GORM-centered into a cloud of fast redis nodes
From Big GORM-centered into a cloud of fast redis nodesFrom Big GORM-centered into a cloud of fast redis nodes
From Big GORM-centered into a cloud of fast redis nodes
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
Spark workshop
Spark workshopSpark workshop
Spark workshop
 

JVM performance options. How it works