SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Network Security- Secure Socket Layer
Network Security- Secure Socket LayerNetwork Security- Secure Socket Layer
Network Security- Secure Socket LayerDr.Florence Dayana
 
Using SharePoint & Office 365 for Digital Transformation
Using SharePoint & Office 365 for Digital TransformationUsing SharePoint & Office 365 for Digital Transformation
Using SharePoint & Office 365 for Digital TransformationJoel Oleson
 
Java Technical Design Document
Java Technical Design DocumentJava Technical Design Document
Java Technical Design DocumentDeborah Obasogie
 
Managing and supporting PowerApps & Flow at scale by Daniel Laskewitz
Managing and supporting PowerApps & Flow at scale by Daniel LaskewitzManaging and supporting PowerApps & Flow at scale by Daniel Laskewitz
Managing and supporting PowerApps & Flow at scale by Daniel LaskewitzDaniel Laskewitz
 
Microsoft Office 365 Advanced Threat Protection
Microsoft Office 365 Advanced Threat ProtectionMicrosoft Office 365 Advanced Threat Protection
Microsoft Office 365 Advanced Threat ProtectionDavid J Rosenthal
 
Reverse Engineering of Software Architecture
Reverse Engineering of Software ArchitectureReverse Engineering of Software Architecture
Reverse Engineering of Software ArchitectureDharmalingam Ganesan
 
Fundamentals of Web for Non-Developers
Fundamentals of Web for Non-DevelopersFundamentals of Web for Non-Developers
Fundamentals of Web for Non-DevelopersLemi Orhan Ergin
 
Jira customization
Jira customizationJira customization
Jira customizationRajesh P
 
Security Patterns with the WSO2 ESB
Security Patterns with the WSO2 ESBSecurity Patterns with the WSO2 ESB
Security Patterns with the WSO2 ESBWSO2
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theorySampath Kumar S
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Oleksii Prohonnyi
 
Lecture 9 electronic_mail_representation_and_transfer
Lecture 9 electronic_mail_representation_and_transferLecture 9 electronic_mail_representation_and_transfer
Lecture 9 electronic_mail_representation_and_transferSerious_SamSoul
 
Web Development Technologies
Web Development TechnologiesWeb Development Technologies
Web Development TechnologiesVignesh Prajapati
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
K6 - Teste de Carga e Desempenho.pptx
K6 - Teste de Carga e Desempenho.pptxK6 - Teste de Carga e Desempenho.pptx
K6 - Teste de Carga e Desempenho.pptxGdfr2
 

What's hot (20)

Network Security- Secure Socket Layer
Network Security- Secure Socket LayerNetwork Security- Secure Socket Layer
Network Security- Secure Socket Layer
 
Using SharePoint & Office 365 for Digital Transformation
Using SharePoint & Office 365 for Digital TransformationUsing SharePoint & Office 365 for Digital Transformation
Using SharePoint & Office 365 for Digital Transformation
 
Java Technical Design Document
Java Technical Design DocumentJava Technical Design Document
Java Technical Design Document
 
Managing and supporting PowerApps & Flow at scale by Daniel Laskewitz
Managing and supporting PowerApps & Flow at scale by Daniel LaskewitzManaging and supporting PowerApps & Flow at scale by Daniel Laskewitz
Managing and supporting PowerApps & Flow at scale by Daniel Laskewitz
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Microsoft Office 365 Advanced Threat Protection
Microsoft Office 365 Advanced Threat ProtectionMicrosoft Office 365 Advanced Threat Protection
Microsoft Office 365 Advanced Threat Protection
 
Reverse Engineering of Software Architecture
Reverse Engineering of Software ArchitectureReverse Engineering of Software Architecture
Reverse Engineering of Software Architecture
 
Fundamentals of Web for Non-Developers
Fundamentals of Web for Non-DevelopersFundamentals of Web for Non-Developers
Fundamentals of Web for Non-Developers
 
Jira customization
Jira customizationJira customization
Jira customization
 
Security Patterns with the WSO2 ESB
Security Patterns with the WSO2 ESBSecurity Patterns with the WSO2 ESB
Security Patterns with the WSO2 ESB
 
Cd lab manual
Cd lab manualCd lab manual
Cd lab manual
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theory
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 
Unit1 2 Webtechnology
Unit1 2 WebtechnologyUnit1 2 Webtechnology
Unit1 2 Webtechnology
 
Lecture 9 electronic_mail_representation_and_transfer
Lecture 9 electronic_mail_representation_and_transferLecture 9 electronic_mail_representation_and_transfer
Lecture 9 electronic_mail_representation_and_transfer
 
AI Builder Deep Dive
AI Builder Deep DiveAI Builder Deep Dive
AI Builder Deep Dive
 
Web Development Technologies
Web Development TechnologiesWeb Development Technologies
Web Development Technologies
 
Editor structure
Editor structureEditor structure
Editor structure
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
K6 - Teste de Carga e Desempenho.pptx
K6 - Teste de Carga e Desempenho.pptxK6 - Teste de Carga e Desempenho.pptx
K6 - Teste de Carga e Desempenho.pptx
 

Similar to JVM performance options. How it works

Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS EngineChengHui Weng
 
java memory management & gc
java memory management & gcjava memory management & gc
java memory management & gcexsuns
 
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 loopSaša Tatar
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
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...Spark Summit
 
Engineering fast indexes
Engineering fast indexesEngineering fast indexes
Engineering fast indexesDaniel Lemire
 
Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Alexey Fyodorov
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a monthDmitriy Dumanskiy
 
Профилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаПрофилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаsamsolutionsby
 
Score (smart contract for icon)
Score (smart contract for icon) Score (smart contract for icon)
Score (smart contract for icon) Doyun Hwang
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!José Paumard
 
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 ErlandsonDatabricks
 
Ø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 ...Charles Nutter
 
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 nodesGailen Tecnologías
 
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 196Mahmoud Samir Fayed
 
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?Federico Tomassetti
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 
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 31Mahmoud Samir Fayed
 

Similar to 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