SlideShare ist ein Scribd-Unternehmen logo
1 von 141
Downloaden Sie, um offline zu lesen
Java Performance Tuning




           Atthakorn Chanthong
What is software tuning?
User Experience


              The software has
             poor response time.

             I need it runs more
                    faster
Software tuning is to make
  application runs faster
Many people think
Java application is slow, why?
There are two major reasons
The first is the Bottleneck
The Bottleneck
                 Increased
                Memory Use
                             Lots of Casts


   Automatic
    memory
  management
  by Garbage
   Collector
                             All Object are
                              allocated on
                               the Heap.
        Java application
          is not native
The second is
The Bad Coding Practice
How to make it run faster?
The bottleneck is unavoidable
But the man could
have a good coding practice
A good design
A good coding practice
Java application
normally run fast enough
So the tuning game
  comes into play
Knowing the strategy
Tuning Strategy

 1     Identify the main causes



 2
         Choose the quickest
         and easier one to fix


 3
       Fix it, and repeat again
         for other root cause
Inside the strategy
Tuning Strategy
                           Need more faster, repeat again
   Profile, Measure
   Problem Priority
                                                Yes, it’s better

 Identify the location
    of bottleneck
                                               Test and compare
                          Still bad?          Before/after alteration
                          The result
  Think a hypothesis      isn’t good enough


                                                 Code alteration

 Create a test scenario
How to measure
the software performance?
We use the profiler
Profiler is a programming tool
         that can track
 the performance of another
      computer program
The two common usages of profiler are
    to analyze a software problem


                      Profiler




Profile application              Monitor application
  performance                     memory usage
How we get the profiler?
Don’t pay for it!
An opensource profiler
     is all around
Some interesting
opensource profilers
Opensource Profiler



                                                    JConsole




http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
Opensource Profiler



Eclipse TPTP




http://www.eclipse.org/tptp/index.php
Opensource Profiler
                                  NetBeans
                                Built-in Profiler




http://profiler.netbeans.org/
Opensource Profiler
               This is pulled out from NetBeans
                 to act as standalone profiler




                                           VisualVM




https://visualvm.dev.java.net/
And much more …
Opensource Profiler

             JRat          Cougaar




     DrMem          InfraRED           Profiler4j




         Jmeasurement          TIJMP
We love opensource
Make the brain smart with
   good code practice
1st Rule
Avoid Object-Creation
Object-Creation causes problem
             Why?
Avoid Object-Creation


  Lots of objects in memory
  means GC does lots of work

    Program is slow down
       when GC starts
Avoid Object-Creation



  Creating object costs time
 and CPU effort for application
Reuse objects where possible
Pool Management

Most container (e.g. Vector) objects
   could be reused rather than
     created and thrown away
Pool Management

  VectorPoolManager


    V1                 V3   V4          V5




    getVector()                  returnVector()



                  V2
Pool Management
  public void doSome()
  {
           for (int i=0; i < 10; i++) {
                     Vector v = new Vector()
                     … do vector manipulation stuff

           }
  }



  public static VectorPoolManager vpl = new VectorPoolManager(25)
  public void doSome()
  {
           for (int i=0; i < 10; i++) {
                    Vector v = vectorPoolManager.getVector( );
                    … do vector manipulation stuff
                    vectorPoolManager.returnVector(v);
           }
  }
Canonicalizing Objects

   Replace multiple object
by a single object or just a few
Canonicalizing Objects
   public class VectorPoolManager
   {
              private static final VectorPoolManager poolManager;
              private Vector[] pool;

             private VectorPoolManager(int size)
             {
                        ....
             }
             public static Vector getVector()
             {
                        if (poolManager== null)
                                   poolManager = new VectorPoolManager(20);

                       ...
                       return pool[pool.length-1];
             }
   }



                              Singleton Pattern
Canonicalizing Objects
  Boolean   b1   =   new   Boolean(true);
  Boolean   b2   =   new   Boolean(false);
  Boolean   b3   =   new   Boolean(false);
  Boolean   b4   =   new   Boolean(false);


                                             4 objects in memory




  Boolean   b1   =   Boolean.TRUE
  Boolean   b2   =   Boolean.FALSE
  Boolean   b3   =   Boolean.FALSE
  Boolean   b4   =   Boolean.FALSE
                                             2 objects in memory
Canonicalizing Objects

    String string = quot;55quot;;
    Integer theInt = new Integer(string);


                                                No Cache




    String string = quot;55quot;;
    Integer theInt = Integer.valueOf(string);



                                            Object Cached
Canonicalizing Objects
  private static class IntegerCache {
             private IntegerCache(){}

            static final Integer cache[] = new Integer[-(-128) + 127 + 1];
            static {
                        for(int i = 0; i < cache.length; i++)
                                    cache[i] = new Integer(i - 128);
            }
  }

  public static Integer valueOf(int i) {
             final int offset = 128;
             if (i >= -128 && i <= 127) { // must cache
                         return IntegerCache.cache[i + offset];
             }
             return new Integer(i);
  }



            Caching inside Integer.valueOf(…)
Keyword, ‘final’

Use the final modifier on variable
 to create immutable internally
        accessible object
Keyword, ‘final’

  public void doSome(Dimension width, Dimenstion height)
  {
           //Re-assign allow
           width = new Dimension(5,5);
           ...
  }




  public void doSome(final Dimension width, final Dimenstion height)
  {
           //Re-assign disallow
           width = new Dimension(5,5);
           ...
  }
Auto-Boxing/Unboxing

Use Auto-Boxing as need not as always
Auto-Boxing/UnBoxing
   Integer i = 0;
   //Counting by 10M
   while (i < 100000000)
   {
            i++;
   }
    Takes 2313 ms
                                  Why it takes
                           2313/125 =~ 20 times longer?
   int p = 0;
   //Counting by 10M
   while (p < 100000000)
   {
           p++;
   }
    Takes 125 ms
Auto-Boxing/UnBoxing



 Object-Creation made every time
   we wrap primitive by boxing
2nd Rule
Knowing String Better
String is the Object
mostly used in the application
Overlook the String

    The software may
have the poor performance
Compile-Time
    String Initialization

Use the string concatenation (+)
       operator to create
    Strings at compile-time.
Compile-Time Initialization
 for (int i =0; i < loop; i++)
 {
           //Looping 10M rounds
           String x = quot;Helloquot; + quot;,quot; +quot; quot;+ quot;Worldquot;;
 }
                                                      Takes 16 ms



 for (int i =0; i < loop; i++)
 {
           //Looping 10M rounds
           String x = new String(quot;Helloquot; + quot;,quot; +quot; quot;+ quot;Worldquot;);
 }

                                                     Takes 672 ms
Runtime
   String Initialization

Use StringBuffers/StringBuilder
 to create Strings at runtime.
Runtime String Initialization
 String name = quot;Smithquot;;
 for (int i =0; i < loop; i++)
 {
            //Looping 1M rounds
            String x = quot;Helloquot;;
            x += quot;,quot;;
            x += quot; Mr.quot;;
            x += name;
 }                                                       Takes 10298 ms


 String name = quot;Smithquot;;
 for (int i =0; i < loop; i++)
 {
            //Looping 1M rounds
            String x = (new StringBuffer()).append(quot;Helloquot;)
                     .append(quot;,quot;).append(quot; quot;)
                     .append(name).toString();
 }
                                                          Takes 6187 ms
String comparison

Use appropriate method
 to compare the String
To Test String is Empty
 for (int i =0; i < loop; i++)
 {
            //10m loops
            if (a != null && a.equals(quot;quot;))
            {

          }
 }.
                                               Takes 125 ms

 for (int i =0; i < loop; i++)
 {
           //10m loops
           if (a != null && a.length() == 0)
           {

         }
 }                                             Takes 31 ms
If two strings have the same length
  String a = “abc”
  String b = “cdf”
  for (int i =0; i < loop; i++)
  {
             if (a.equalsIgnoreCase(b))
             {

           }
  }                                       Takes 750 ms


   String a = “abc”
   String b = “cdf”
   for (int i =0; i < loop; i++)
   {
              if (a.equals(b))
              {

            }                             Takes 125 ms
   }
If two strings have different length
  String a = “abc”
  String b = “cdfg”
  for (int i =0; i < loop; i++)
  {
             if (a.equalsIgnoreCase(b))
             {

           }
  }                                       Takes 780 ms


   String a = “abc”
   String b = “cdfg”
   for (int i =0; i < loop; i++)
   {
              if (a.equals(b))
              {

            }                             Takes 858 ms
   }
String.equalsIgnoreCase()
      does only 2 steps


It checks for identity and then
for Strings being the same size
Intern String
To compare String by identity
Intern String



  Normally, string can be created
           by two ways
Intern String

           By new String(…)

  String s = new String(“This is a string literal.”);



          By String Literals
       String s = “This is a string literal.”;
Intern String


    Create Strings by new String(…)


JVM always allocate a new memory address
       for each new String created
        even if they are the same.
Intern String

  String a = new String(“This is a string literal.”);
  String b = new String(“This is a string literal.”);



       a
                       “This is a string literal.”


                    The different memory address


       b               “This is a string literal.”
Intern String

     Create Strings by Literals
    Strings will be stored in Pool

   Double create Strings by laterals
 They will share as a unique instances
Intern String

   String a = “This is a string literal.”;
   String b = “This is a string literal.”;


      a             Same memory address


                    “This is a string literal.”


      b
Intern String


   We can point two Stings variable
          to the same address
     if they are the same values.

   By using String.intern() method
Intern String

  String a = new String(“This is a string literal.”).intern();
  String b = new String(“This is a string literal.”).intern();




        a                   Same memory address


                            “This is a string literal.”


        b
Intern String


           The idea is …

    Intern String could be used
   to compare String by identity
Intern String



   What “compare by identity”
            means?
Intern String

   If (a == b)
                      Identity comparison
                         (by reference)



   If (a.equals(b))

                       Value comparison
Intern String



         By using reference
    so identity comparison is fast
Intern String


       In traditionally style

  String must be compare by equals()
       to avoid the negative result
Intern String

        But Intern String…

      If Strings have different value
    they also have different address.

      If Strings have same value
   they also have the same address.
Intern String


        So we can say that

(a == b) is equivalent to (a.equals(b))
Intern String

      For these string variables
        String a = quot;abcquot;;
        String b = quot;abcquot;;
        String c = new String(quot;abcquot;).intern()



 They are pointed to the same address
          with the same value
Intern String
  for (int i =0; i < loop; i++)
  {
            if (a.equals(b))
            {

          }
  }
                                  Takes 312 ms



 for (int i =0; i < loop; i++)
 {
           if (a == b)
           {

         }
                                  Takes 32 ms
 }
Intern String


      Wow, Intern String is good

   Unfortunately, it makes code
  hard understand, use it carefully
Intern String

           String.intern()
       comes with overhead
     as there is a step to cache

  Use Intern String if they are planed
    to compare two or more times
char array instead of String

Avoid doing some stuffs by String object itself
           for optimal performance
char array
  String x = quot;abcdefghijklmnquot;;
  for (int i =0; i < loop; i++)
  {
             if (x.charAt(5) == 'x')
             {

           }
  }
                                                    Takes 281 ms


  String x = quot;abcdefghijklmnquot;;
  char y[] = x.toCharArray();
  for (int i =0; i < loop; i++)
  {
             if ( (20 < y.length && 20 >= 0) && y[20] == 'x')
             {
             }
  }                                                     Takes 156 ms
3rd Rule
Exception and Cast
Stop exception to be thrown
         if it is possible

Exception is really expensively to execute
Avoid Exception
 Object obj = null;
 for (int i =0; i < loop; i++)
 {
            try
            {
                     obj.hashCode();

          } catch (Exception e) {}
 }
                                        Takes 18563 ms



 Object obj = null;
 for (int i =0; i < loop; i++)
 {
            if (obj != null)
            {
                      obj.hashCode();
            }                           Takes 16 ms
 }
Cast as Less

We can reduce runtime cost by grouping
   cast object which is several used
Cast as Less
Integer io = new Integer(0);
Object obj = (Object)io;
for (int i =0; i < loop; i++)
{
            if (obj instanceof Integer)
            {
                        byte x = ((Integer) obj).byteValue();
                        double d = ((Integer) obj).doubleValue();
                        float f = ((Integer) obj).floatValue();
            }
}
                                                                    Takes 31 ms

for (int i =0; i < loop; i++)
{
            if (obj instanceof Integer)
            {
                        Integer icast = (Integer)obj;
                        byte x = icast.byteValue();
                        double d = icast.doubleValue();
                        float f = icast.floatValue();
            }
}                                                                   Takes 16 ms
4th Rule
The Rhythm of Motion
Loop Optimization

There are several ways to make
          a faster loop
Don’t terminate loop with
       method calls
Eliminate Method Call
byte x[] = new byte[loop];
for (int i = 0; i < x.length; i++)
{
          for (int j = 0; j < x.length; j++)
          {
          }
}                                              Takes 109 ms


byte x[] = new byte[loop];
int length = x.length;
for (int i = 0; i < length; i++)
{
          for (int j = 0; j < length; j++)
          {

        }                                      Takes 62 ms
}
Method Call generates some overhead
    in Object Oriented Paradigm
Use int to iterate over loop
Iterate over loop by int
 for (int i = 0; i < length; i++)
 {
           for (int j = 0; j < length; j++)
           {

         }
 }                                             Takes 62 ms


for (short i = 0; i < length; i++)
{
        for (short j = 0; j < length; j++)
        {

        }
}                                             Takes 125 ms
VM is optimized to use int
     for loop iteration
 not by byte, short, char
Use System.arraycopy(…)
     for copying object
instead of running over loop
System.arraycopy(….)
 for (int i = 0; i < length; i++)
 {
           x[i] = y[i];
 }


                                            Takes 62 ms




  System.arraycopy(x, 0, y, 0, x.length);




                                            Takes 16 ms
System.arraycopy() is native function
       It is efficiently to use
Terminate loop by primitive use
  not by function or variable
Terminate Loop by Primitive
 for(int i = 0; i < countArr.length; i++)
 {
           for(int j = 0; j < countArr.length; j++)
           {

         }
 }                                                      Takes 424 ms


for(int i = countArr.length-1; i >= 0; i--)
{
          for(int j = countArr.length-1; j >= 0; j--)
          {

        }
}
                                                        Takes 298 ms
Primitive comparison is more efficient
than function or variable comparison
The average time of
        switch vs. if-else
is about equally in random case
Switch vs. If-else
for(int i = 0; i < loop; i++)     for(int i = 0; i < loop; i++)
{                                 {
          if (i%10== 0)                     switch (i%10)
          {                                 {
                                                    case 0: break;
        } else if (i%10 == 1)                       case 1: break;
        {                                           ...
                 ...                                case 7: break;
        } else if (i%10 == 8)                       case 8: break;
        {                                           default: break;
        } else if (i%10 == 9)               }
        {                         }
        }
}


                  Takes 2623 ms                      Takes 2608 ms
Switch is quite fast if the case
        falls into the middle

   but slower than if-else in case of
falling at the beginning or default case


 ** Test against a contiguous range
     of case values eg, 1,2,3,4,..
Recursive Algorithm

Recursive function is easy to read
  but it costs for each recursion
Tail Recursion
      A recursive function for
which each recursive call to itself
is a reduction of the original call.
Recursive vs. Tail-Recursive
public static long factorial1(int n)
{
         if (n < 2) return 1L;
         else return n*factorial1(n-1);
}


                                                     Takes 172 ms

public static long factorial1a(int n)
{
         if (n < 2) return 1L;
         else return factorial1b(n, 1L);
}
public static long factorial1b(int n, long result)
{
         if (n == 2) return 2L*result;
         else return factorial1b(n-1, result*n);     Takes 125 ms
}
Dynamic Cached Recursive

Do cache to gain more speed
Dynamic-Cached Recursive
  public static long factorial1(int n)
  {
               if (n < 2) return 1L;
               else return n*factorial1(n-1);
  }




                                                                                  Takes 172 ms

public static final int CACHE_SIZE = 15;
public static final long[ ] factorial3Cache = new long[CACHE_SIZE];
public static long factorial3(int n)
{
             if (n < 2) return 1L;
             else if (n < CACHE_SIZE)
             {
                          if (factorial3Cache[n] == 0)
                                        factorial3Cache[n] = n*factorial3(n-1);
                          return factorial3Cache[n];
             }
             else return n*factorial3(n-1);
                                                                                  Takes 94 ms
}
Recursion Summary

 Dynamic-Cached Tail Recursive
          is better than

        Tail Recursive
          is better than


          Recursive
5th Rule
Use Appropriate Collection
Accession
ArrayList vs. LinkedList
Random Access
 ArrayList al = new ArrayList();

 for (int i =0; i < loop; i++)
 {
           al.get(i);
 }
                                      Takes 281 ms



 LinkedList ll = new LinkedList();
 for (int i =0; i < loop; i++)
 {
           ll.get(i);
 }
                                     Takes 5828 ms
Sequential Access
 ArrayList al = new ArrayList();
 for (Iterator i = al.iterator(); i.hasNext();)
 {
          i.next();
 }

                                                  Takes 1375 ms



 LinkedList ll = new LinkedList();
 for (Iterator i = ll.iterator(); i.hasNext();)
 {
          i.next();
 }

                                                  Takes 1047 ms
ArrayList is good for random access

LinkedList is good for sequential access
Random vs. Sequential Access
 ArrayList al = new ArrayList();

 for (int i =0; i < loop; i++)
 {
           al.get(i);
 }
                                                   Takes 281 ms



 LinkedList ll = new LinkedList();
 for (Iterator i = ll.iterator(); i.hasNext();)
 {
          i.next();
 }

                                                  Takes 1047 ms
Random Access is better than
     Sequential Access
Insertion
ArrayList vs. LinkedList
Insertion at zero index
 ArrayList al = new ArrayList();

 for (int i =0; i < loop; i++)
 {
           al.add(0, Integer.valueOf(i));
 }
                                            Takes 328 ms




 LinkedList ll = new LinkedList();
 for (int i =0; i < loop; i++)
 {
           ll.add(0, Integer.valueOf(i));
 }
                                            Takes 109 ms
LinkedList does insertion
   better than ArrayList
Vector is likely to ArrayList
but it is synchronized version
Accession and Insertion
  Vector vs. ArrayList
Random Accession
 ArrayList al = new ArrayList();
 for (int i =0; i < loop; i++)
 {
           al.get(i);
 }
                                   Takes 281 ms



  Vector vt = new Vector();
  for (int i =0; i < loop; i++)
  {
            vt.get(i);
  }

                                   Takes 422 ms
Sequential Accession
  ArrayList al = new ArrayList();
  for (Iterator i = al.iterator(); i.hasNext();)
  {
           i.next();
  }
                                                   Takes 1375 ms


  Vector vt = new Vector();
  for (Iterator i = vt.iterator(); i.hasNext();)
  {
           i.next();
  }

                                                   Takes 1890 ms
Insertion
  ArrayList al = new ArrayList();
  for (int i =1; i < loop; i++)
  {
            al.add(0, Integer.valueOf(i));
  }

                                             Takes 328 ms



  Vector vt = new Vector();
  for (int i =0; i < loop; i++)
  {
            vt.add(0, Integer.valueOf(i));
  }
                                             Takes 360 ms
Vector is slower than ArrayList
          in every method


Use Vector if only synchronize needed
Summary
 Type        Random   Sequential Insertion
             (get)    (Iterator)
 ArrayList   281      1375       328


 LinkedList 5828      1047       109


 Vector      422      1890       360
Addition and Accession
Hashtable vs HashMap
Addition
 Hashtable ht = new Hashtable();
 for (int i =0; i < loop; i++)
 {
           ht.put(Integer.valueOf(i), Integer.valueOf(i));
 }

                                                      Takes 453 ms


 HashMap hm = new HashMap();
 for (int i =0; i < loop; i++)
 {
           hm.put(Integer.valueOf(i), Integer.valueOf(i));
 }

                                                      Takes 328 ms
Accession
 Hashtable ht = new Hashtable();
 for (int i =0; i < loop; i++)
 {
           ht.get(Integer.valueOf(i));
 }

                                         Takes 94 ms


 HashMap hm = new HashMap();
 for (int i =0; i < loop; i++)
 {
           hm.get(Integer.valueOf(i));
 }

                                         Takes 47 ms
Hashtable is synchronized
so it is slower than HashMap
Q&A
Reference
 O'Reilly Java Performance Tuning 2nd
 http://www.javaperformancetuning.com
 http://www.glenmccl.com/jperf/
Future Topic
 I/O Logging, and Console Output
 Sorting
 Threading
 Tweak JVM and GC Strategy
The End

Weitere ähnliche Inhalte

Was ist angesagt?

JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia Vladimir Ivanov
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?Roman Elizarov
 
Java Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsJava Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsCarol McDonald
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with javaHoang Nguyen
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaIsuru Perera
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkDror Bereznitsky
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profilingschlebu
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection TuningKai Koenig
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Non blocking programming and waiting
Non blocking programming and waitingNon blocking programming and waiting
Non blocking programming and waitingRoman Elizarov
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in androidRakesh Jha
 
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsCS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsKwangshin Oh
 
Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Martin Toshev
 

Was ist angesagt? (20)

JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
Java Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsJava Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and Trends
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
 
JVM
JVMJVM
JVM
 
The Java memory model made easy
The Java memory model made easyThe Java memory model made easy
The Java memory model made easy
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own Benchmark
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profiling
 
JVM and Garbage Collection Tuning
JVM and Garbage Collection TuningJVM and Garbage Collection Tuning
JVM and Garbage Collection Tuning
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Non blocking programming and waiting
Non blocking programming and waitingNon blocking programming and waiting
Non blocking programming and waiting
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
JVM Internals (2015)
JVM Internals (2015)JVM Internals (2015)
JVM Internals (2015)
 
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIsCS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs
 
Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Concurrency Utilities in Java 8
Concurrency Utilities in Java 8
 

Andere mochten auch

Java performance tuning
Java performance tuningJava performance tuning
Java performance tuningJerry Kurian
 
Hotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful PartsHotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful PartsjClarity
 
Real Life Java EE Performance Tuning
Real Life Java EE Performance TuningReal Life Java EE Performance Tuning
Real Life Java EE Performance TuningC2B2 Consulting
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterAttila Szegedi
 
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil TeneUnderstanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil Tenejaxconf
 
VLE GSA - How to use the Profile Tool
VLE GSA - How to use the Profile ToolVLE GSA - How to use the Profile Tool
VLE GSA - How to use the Profile Toolvlegsa
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandC2B2 Consulting
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVMStaffan Larsen
 
Java profiling Do It Yourself
Java profiling Do It YourselfJava profiling Do It Yourself
Java profiling Do It Yourselfaragozin
 
JavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingJavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingChris Bailey
 
Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVMkensipe
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applicationspkoza
 
Benchmarking Solr Performance
Benchmarking Solr PerformanceBenchmarking Solr Performance
Benchmarking Solr PerformanceLucidworks
 
Java Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningJava Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningCarol McDonald
 
High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...
High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...
High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...Lucidworks
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scalethelabdude
 
Apache Solr crash course
Apache Solr crash courseApache Solr crash course
Apache Solr crash courseTommaso Teofili
 
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014Shalin Shekhar Mangar
 

Andere mochten auch (19)

Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Hotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful PartsHotspot Garbage Collection - The Useful Parts
Hotspot Garbage Collection - The Useful Parts
 
Real Life Java EE Performance Tuning
Real Life Java EE Performance TuningReal Life Java EE Performance Tuning
Real Life Java EE Performance Tuning
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @Twitter
 
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil TeneUnderstanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
 
VLE GSA - How to use the Profile Tool
VLE GSA - How to use the Profile ToolVLE GSA - How to use the Profile Tool
VLE GSA - How to use the Profile Tool
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx Poland
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
 
Java profiling Do It Yourself
Java profiling Do It YourselfJava profiling Do It Yourself
Java profiling Do It Yourself
 
JavaOne 2014: Java Debugging
JavaOne 2014: Java DebuggingJavaOne 2014: Java Debugging
JavaOne 2014: Java Debugging
 
Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVM
 
Efficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java ApplicationsEfficient Memory and Thread Management in Highly Parallel Java Applications
Efficient Memory and Thread Management in Highly Parallel Java Applications
 
Benchmarking Solr Performance
Benchmarking Solr PerformanceBenchmarking Solr Performance
Benchmarking Solr Performance
 
Java Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningJava Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and Tuning
 
High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...
High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...
High Performance Solr and JVM Tuning Strategies used for MapQuest’s Search Ah...
 
High Performance Solr
High Performance SolrHigh Performance Solr
High Performance Solr
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scale
 
Apache Solr crash course
Apache Solr crash courseApache Solr crash course
Apache Solr crash course
 
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
Scaling SolrCloud to a Large Number of Collections - Fifth Elephant 2014
 

Ähnlich wie Java Performance Tuning

Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript EverywherePascal Rettig
 
Node.js behind: V8 and its optimizations
Node.js behind: V8 and its optimizationsNode.js behind: V8 and its optimizations
Node.js behind: V8 and its optimizationsDawid Rusnak
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav DukhinFwdays
 
Web technologies-course 12.pptx
Web technologies-course 12.pptxWeb technologies-course 12.pptx
Web technologies-course 12.pptxStefan Oprea
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: ServersidenessWebExpo
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipseanshunjain
 
Describe's Full of It's
Describe's Full of It'sDescribe's Full of It's
Describe's Full of It'sJim Lynch
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2ppd1961
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)Piyush Katariya
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 

Ähnlich wie Java Performance Tuning (20)

Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
Node.js behind: V8 and its optimizations
Node.js behind: V8 and its optimizationsNode.js behind: V8 and its optimizations
Node.js behind: V8 and its optimizations
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
Web technologies-course 12.pptx
Web technologies-course 12.pptxWeb technologies-course 12.pptx
Web technologies-course 12.pptx
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: Serversideness
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
Describe's Full of It's
Describe's Full of It'sDescribe's Full of It's
Describe's Full of It's
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
 
Thread
ThreadThread
Thread
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 

Kürzlich hochgeladen

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Kürzlich hochgeladen (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Java Performance Tuning

  • 1. Java Performance Tuning Atthakorn Chanthong
  • 3. User Experience The software has poor response time. I need it runs more faster
  • 4. Software tuning is to make application runs faster
  • 5. Many people think Java application is slow, why?
  • 6. There are two major reasons
  • 7. The first is the Bottleneck
  • 8. The Bottleneck Increased Memory Use Lots of Casts Automatic memory management by Garbage Collector All Object are allocated on the Heap. Java application is not native
  • 9. The second is The Bad Coding Practice
  • 10. How to make it run faster?
  • 11. The bottleneck is unavoidable
  • 12. But the man could have a good coding practice
  • 14. A good coding practice
  • 16. So the tuning game comes into play
  • 18. Tuning Strategy 1 Identify the main causes 2 Choose the quickest and easier one to fix 3 Fix it, and repeat again for other root cause
  • 20. Tuning Strategy Need more faster, repeat again Profile, Measure Problem Priority Yes, it’s better Identify the location of bottleneck Test and compare Still bad? Before/after alteration The result Think a hypothesis isn’t good enough Code alteration Create a test scenario
  • 21. How to measure the software performance?
  • 22. We use the profiler
  • 23. Profiler is a programming tool that can track the performance of another computer program
  • 24. The two common usages of profiler are to analyze a software problem Profiler Profile application Monitor application performance memory usage
  • 25. How we get the profiler?
  • 27. An opensource profiler is all around
  • 29. Opensource Profiler JConsole http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
  • 31. Opensource Profiler NetBeans Built-in Profiler http://profiler.netbeans.org/
  • 32. Opensource Profiler This is pulled out from NetBeans to act as standalone profiler VisualVM https://visualvm.dev.java.net/
  • 34. Opensource Profiler JRat Cougaar DrMem InfraRED Profiler4j Jmeasurement TIJMP
  • 36. Make the brain smart with good code practice
  • 39. Avoid Object-Creation Lots of objects in memory means GC does lots of work Program is slow down when GC starts
  • 40. Avoid Object-Creation Creating object costs time and CPU effort for application
  • 42. Pool Management Most container (e.g. Vector) objects could be reused rather than created and thrown away
  • 43. Pool Management VectorPoolManager V1 V3 V4 V5 getVector() returnVector() V2
  • 44. Pool Management public void doSome() { for (int i=0; i < 10; i++) { Vector v = new Vector() … do vector manipulation stuff } } public static VectorPoolManager vpl = new VectorPoolManager(25) public void doSome() { for (int i=0; i < 10; i++) { Vector v = vectorPoolManager.getVector( ); … do vector manipulation stuff vectorPoolManager.returnVector(v); } }
  • 45. Canonicalizing Objects Replace multiple object by a single object or just a few
  • 46. Canonicalizing Objects public class VectorPoolManager { private static final VectorPoolManager poolManager; private Vector[] pool; private VectorPoolManager(int size) { .... } public static Vector getVector() { if (poolManager== null) poolManager = new VectorPoolManager(20); ... return pool[pool.length-1]; } } Singleton Pattern
  • 47. Canonicalizing Objects Boolean b1 = new Boolean(true); Boolean b2 = new Boolean(false); Boolean b3 = new Boolean(false); Boolean b4 = new Boolean(false); 4 objects in memory Boolean b1 = Boolean.TRUE Boolean b2 = Boolean.FALSE Boolean b3 = Boolean.FALSE Boolean b4 = Boolean.FALSE 2 objects in memory
  • 48. Canonicalizing Objects String string = quot;55quot;; Integer theInt = new Integer(string); No Cache String string = quot;55quot;; Integer theInt = Integer.valueOf(string); Object Cached
  • 49. Canonicalizing Objects private static class IntegerCache { private IntegerCache(){} static final Integer cache[] = new Integer[-(-128) + 127 + 1]; static { for(int i = 0; i < cache.length; i++) cache[i] = new Integer(i - 128); } } public static Integer valueOf(int i) { final int offset = 128; if (i >= -128 && i <= 127) { // must cache return IntegerCache.cache[i + offset]; } return new Integer(i); } Caching inside Integer.valueOf(…)
  • 50. Keyword, ‘final’ Use the final modifier on variable to create immutable internally accessible object
  • 51. Keyword, ‘final’ public void doSome(Dimension width, Dimenstion height) { //Re-assign allow width = new Dimension(5,5); ... } public void doSome(final Dimension width, final Dimenstion height) { //Re-assign disallow width = new Dimension(5,5); ... }
  • 53. Auto-Boxing/UnBoxing Integer i = 0; //Counting by 10M while (i < 100000000) { i++; } Takes 2313 ms Why it takes 2313/125 =~ 20 times longer? int p = 0; //Counting by 10M while (p < 100000000) { p++; } Takes 125 ms
  • 54. Auto-Boxing/UnBoxing Object-Creation made every time we wrap primitive by boxing
  • 56. String is the Object mostly used in the application
  • 57. Overlook the String The software may have the poor performance
  • 58. Compile-Time String Initialization Use the string concatenation (+) operator to create Strings at compile-time.
  • 59. Compile-Time Initialization for (int i =0; i < loop; i++) { //Looping 10M rounds String x = quot;Helloquot; + quot;,quot; +quot; quot;+ quot;Worldquot;; } Takes 16 ms for (int i =0; i < loop; i++) { //Looping 10M rounds String x = new String(quot;Helloquot; + quot;,quot; +quot; quot;+ quot;Worldquot;); } Takes 672 ms
  • 60. Runtime String Initialization Use StringBuffers/StringBuilder to create Strings at runtime.
  • 61. Runtime String Initialization String name = quot;Smithquot;; for (int i =0; i < loop; i++) { //Looping 1M rounds String x = quot;Helloquot;; x += quot;,quot;; x += quot; Mr.quot;; x += name; } Takes 10298 ms String name = quot;Smithquot;; for (int i =0; i < loop; i++) { //Looping 1M rounds String x = (new StringBuffer()).append(quot;Helloquot;) .append(quot;,quot;).append(quot; quot;) .append(name).toString(); } Takes 6187 ms
  • 62. String comparison Use appropriate method to compare the String
  • 63. To Test String is Empty for (int i =0; i < loop; i++) { //10m loops if (a != null && a.equals(quot;quot;)) { } }. Takes 125 ms for (int i =0; i < loop; i++) { //10m loops if (a != null && a.length() == 0) { } } Takes 31 ms
  • 64. If two strings have the same length String a = “abc” String b = “cdf” for (int i =0; i < loop; i++) { if (a.equalsIgnoreCase(b)) { } } Takes 750 ms String a = “abc” String b = “cdf” for (int i =0; i < loop; i++) { if (a.equals(b)) { } Takes 125 ms }
  • 65. If two strings have different length String a = “abc” String b = “cdfg” for (int i =0; i < loop; i++) { if (a.equalsIgnoreCase(b)) { } } Takes 780 ms String a = “abc” String b = “cdfg” for (int i =0; i < loop; i++) { if (a.equals(b)) { } Takes 858 ms }
  • 66. String.equalsIgnoreCase() does only 2 steps It checks for identity and then for Strings being the same size
  • 67. Intern String To compare String by identity
  • 68. Intern String Normally, string can be created by two ways
  • 69. Intern String By new String(…) String s = new String(“This is a string literal.”); By String Literals String s = “This is a string literal.”;
  • 70. Intern String Create Strings by new String(…) JVM always allocate a new memory address for each new String created even if they are the same.
  • 71. Intern String String a = new String(“This is a string literal.”); String b = new String(“This is a string literal.”); a “This is a string literal.” The different memory address b “This is a string literal.”
  • 72. Intern String Create Strings by Literals Strings will be stored in Pool Double create Strings by laterals They will share as a unique instances
  • 73. Intern String String a = “This is a string literal.”; String b = “This is a string literal.”; a Same memory address “This is a string literal.” b
  • 74. Intern String We can point two Stings variable to the same address if they are the same values. By using String.intern() method
  • 75. Intern String String a = new String(“This is a string literal.”).intern(); String b = new String(“This is a string literal.”).intern(); a Same memory address “This is a string literal.” b
  • 76. Intern String The idea is … Intern String could be used to compare String by identity
  • 77. Intern String What “compare by identity” means?
  • 78. Intern String If (a == b) Identity comparison (by reference) If (a.equals(b)) Value comparison
  • 79. Intern String By using reference so identity comparison is fast
  • 80. Intern String In traditionally style String must be compare by equals() to avoid the negative result
  • 81. Intern String But Intern String… If Strings have different value they also have different address. If Strings have same value they also have the same address.
  • 82. Intern String So we can say that (a == b) is equivalent to (a.equals(b))
  • 83. Intern String For these string variables String a = quot;abcquot;; String b = quot;abcquot;; String c = new String(quot;abcquot;).intern() They are pointed to the same address with the same value
  • 84. Intern String for (int i =0; i < loop; i++) { if (a.equals(b)) { } } Takes 312 ms for (int i =0; i < loop; i++) { if (a == b) { } Takes 32 ms }
  • 85. Intern String Wow, Intern String is good Unfortunately, it makes code hard understand, use it carefully
  • 86. Intern String String.intern() comes with overhead as there is a step to cache Use Intern String if they are planed to compare two or more times
  • 87. char array instead of String Avoid doing some stuffs by String object itself for optimal performance
  • 88. char array String x = quot;abcdefghijklmnquot;; for (int i =0; i < loop; i++) { if (x.charAt(5) == 'x') { } } Takes 281 ms String x = quot;abcdefghijklmnquot;; char y[] = x.toCharArray(); for (int i =0; i < loop; i++) { if ( (20 < y.length && 20 >= 0) && y[20] == 'x') { } } Takes 156 ms
  • 90. Stop exception to be thrown if it is possible Exception is really expensively to execute
  • 91. Avoid Exception Object obj = null; for (int i =0; i < loop; i++) { try { obj.hashCode(); } catch (Exception e) {} } Takes 18563 ms Object obj = null; for (int i =0; i < loop; i++) { if (obj != null) { obj.hashCode(); } Takes 16 ms }
  • 92. Cast as Less We can reduce runtime cost by grouping cast object which is several used
  • 93. Cast as Less Integer io = new Integer(0); Object obj = (Object)io; for (int i =0; i < loop; i++) { if (obj instanceof Integer) { byte x = ((Integer) obj).byteValue(); double d = ((Integer) obj).doubleValue(); float f = ((Integer) obj).floatValue(); } } Takes 31 ms for (int i =0; i < loop; i++) { if (obj instanceof Integer) { Integer icast = (Integer)obj; byte x = icast.byteValue(); double d = icast.doubleValue(); float f = icast.floatValue(); } } Takes 16 ms
  • 94. 4th Rule The Rhythm of Motion
  • 95. Loop Optimization There are several ways to make a faster loop
  • 96. Don’t terminate loop with method calls
  • 97. Eliminate Method Call byte x[] = new byte[loop]; for (int i = 0; i < x.length; i++) { for (int j = 0; j < x.length; j++) { } } Takes 109 ms byte x[] = new byte[loop]; int length = x.length; for (int i = 0; i < length; i++) { for (int j = 0; j < length; j++) { } Takes 62 ms }
  • 98. Method Call generates some overhead in Object Oriented Paradigm
  • 99. Use int to iterate over loop
  • 100. Iterate over loop by int for (int i = 0; i < length; i++) { for (int j = 0; j < length; j++) { } } Takes 62 ms for (short i = 0; i < length; i++) { for (short j = 0; j < length; j++) { } } Takes 125 ms
  • 101. VM is optimized to use int for loop iteration not by byte, short, char
  • 102. Use System.arraycopy(…) for copying object instead of running over loop
  • 103. System.arraycopy(….) for (int i = 0; i < length; i++) { x[i] = y[i]; } Takes 62 ms System.arraycopy(x, 0, y, 0, x.length); Takes 16 ms
  • 104. System.arraycopy() is native function It is efficiently to use
  • 105. Terminate loop by primitive use not by function or variable
  • 106. Terminate Loop by Primitive for(int i = 0; i < countArr.length; i++) { for(int j = 0; j < countArr.length; j++) { } } Takes 424 ms for(int i = countArr.length-1; i >= 0; i--) { for(int j = countArr.length-1; j >= 0; j--) { } } Takes 298 ms
  • 107. Primitive comparison is more efficient than function or variable comparison
  • 108. The average time of switch vs. if-else is about equally in random case
  • 109. Switch vs. If-else for(int i = 0; i < loop; i++) for(int i = 0; i < loop; i++) { { if (i%10== 0) switch (i%10) { { case 0: break; } else if (i%10 == 1) case 1: break; { ... ... case 7: break; } else if (i%10 == 8) case 8: break; { default: break; } else if (i%10 == 9) } { } } } Takes 2623 ms Takes 2608 ms
  • 110. Switch is quite fast if the case falls into the middle but slower than if-else in case of falling at the beginning or default case ** Test against a contiguous range of case values eg, 1,2,3,4,..
  • 111. Recursive Algorithm Recursive function is easy to read but it costs for each recursion
  • 112. Tail Recursion A recursive function for which each recursive call to itself is a reduction of the original call.
  • 113. Recursive vs. Tail-Recursive public static long factorial1(int n) { if (n < 2) return 1L; else return n*factorial1(n-1); } Takes 172 ms public static long factorial1a(int n) { if (n < 2) return 1L; else return factorial1b(n, 1L); } public static long factorial1b(int n, long result) { if (n == 2) return 2L*result; else return factorial1b(n-1, result*n); Takes 125 ms }
  • 114. Dynamic Cached Recursive Do cache to gain more speed
  • 115. Dynamic-Cached Recursive public static long factorial1(int n) { if (n < 2) return 1L; else return n*factorial1(n-1); } Takes 172 ms public static final int CACHE_SIZE = 15; public static final long[ ] factorial3Cache = new long[CACHE_SIZE]; public static long factorial3(int n) { if (n < 2) return 1L; else if (n < CACHE_SIZE) { if (factorial3Cache[n] == 0) factorial3Cache[n] = n*factorial3(n-1); return factorial3Cache[n]; } else return n*factorial3(n-1); Takes 94 ms }
  • 116. Recursion Summary Dynamic-Cached Tail Recursive is better than Tail Recursive is better than Recursive
  • 119. Random Access ArrayList al = new ArrayList(); for (int i =0; i < loop; i++) { al.get(i); } Takes 281 ms LinkedList ll = new LinkedList(); for (int i =0; i < loop; i++) { ll.get(i); } Takes 5828 ms
  • 120. Sequential Access ArrayList al = new ArrayList(); for (Iterator i = al.iterator(); i.hasNext();) { i.next(); } Takes 1375 ms LinkedList ll = new LinkedList(); for (Iterator i = ll.iterator(); i.hasNext();) { i.next(); } Takes 1047 ms
  • 121. ArrayList is good for random access LinkedList is good for sequential access
  • 122. Random vs. Sequential Access ArrayList al = new ArrayList(); for (int i =0; i < loop; i++) { al.get(i); } Takes 281 ms LinkedList ll = new LinkedList(); for (Iterator i = ll.iterator(); i.hasNext();) { i.next(); } Takes 1047 ms
  • 123. Random Access is better than Sequential Access
  • 125. Insertion at zero index ArrayList al = new ArrayList(); for (int i =0; i < loop; i++) { al.add(0, Integer.valueOf(i)); } Takes 328 ms LinkedList ll = new LinkedList(); for (int i =0; i < loop; i++) { ll.add(0, Integer.valueOf(i)); } Takes 109 ms
  • 126. LinkedList does insertion better than ArrayList
  • 127. Vector is likely to ArrayList but it is synchronized version
  • 128. Accession and Insertion Vector vs. ArrayList
  • 129. Random Accession ArrayList al = new ArrayList(); for (int i =0; i < loop; i++) { al.get(i); } Takes 281 ms Vector vt = new Vector(); for (int i =0; i < loop; i++) { vt.get(i); } Takes 422 ms
  • 130. Sequential Accession ArrayList al = new ArrayList(); for (Iterator i = al.iterator(); i.hasNext();) { i.next(); } Takes 1375 ms Vector vt = new Vector(); for (Iterator i = vt.iterator(); i.hasNext();) { i.next(); } Takes 1890 ms
  • 131. Insertion ArrayList al = new ArrayList(); for (int i =1; i < loop; i++) { al.add(0, Integer.valueOf(i)); } Takes 328 ms Vector vt = new Vector(); for (int i =0; i < loop; i++) { vt.add(0, Integer.valueOf(i)); } Takes 360 ms
  • 132. Vector is slower than ArrayList in every method Use Vector if only synchronize needed
  • 133. Summary Type Random Sequential Insertion (get) (Iterator) ArrayList 281 1375 328 LinkedList 5828 1047 109 Vector 422 1890 360
  • 135. Addition Hashtable ht = new Hashtable(); for (int i =0; i < loop; i++) { ht.put(Integer.valueOf(i), Integer.valueOf(i)); } Takes 453 ms HashMap hm = new HashMap(); for (int i =0; i < loop; i++) { hm.put(Integer.valueOf(i), Integer.valueOf(i)); } Takes 328 ms
  • 136. Accession Hashtable ht = new Hashtable(); for (int i =0; i < loop; i++) { ht.get(Integer.valueOf(i)); } Takes 94 ms HashMap hm = new HashMap(); for (int i =0; i < loop; i++) { hm.get(Integer.valueOf(i)); } Takes 47 ms
  • 137. Hashtable is synchronized so it is slower than HashMap
  • 138. Q&A
  • 139. Reference O'Reilly Java Performance Tuning 2nd http://www.javaperformancetuning.com http://www.glenmccl.com/jperf/
  • 140. Future Topic I/O Logging, and Console Output Sorting Threading Tweak JVM and GC Strategy