Startup Time Saving with Restoring Shared Archive

This section provides a tutorial example on how to save startup time by restoring shared archive 'java -Xshare:on'.

In order to test the saving of start up time with CDS, I wrote the following simple perl program, StartupTimeTest.pl:

#- StartupTimeTest.pl
#- Copyright (c) 2004, HerongYang.com, All Rights Reserved.
#
   ($test) = @ARGV;
   if ($test eq "jdk142") {
      $cmd = "\\j2sdk1.4.2\\bin\\java -cp . Hello";
   } elsif ($test eq "jdk150_off") {
      $cmd = "\\j2sdk1.5.0\\bin\\java -cp . -Xshare:off Hello";
   } elsif ($test eq "jdk150_on") {
      $cmd = "\\j2sdk1.5.0\\bin\\java -cp . -Xshare:on Hello";
   }
   $number = 100;
   $t1 = time();
   for ($i=0; $i<$number; $i++) {
      system($cmd);
   }
   $t2 = time();
   $tt =  $t2 - $t1;
   $at =  $tt/$number;
   print "Command: $cmd\n";
   print "Total time: $tt seconds.\n";
   print "Average time: $at seconds.\n";

Here is how I did my tests:

>\j2sdk1.4.2\bin\javac Hello.java

>perl StartupTimeTest.pl jdk142
Hello world!
Hello world!
...
Command: \j2sdk1.4.2\bin\java -cp . Hello
Total time: 24 seconds.
Average time: 0.24 seconds.

\j2sdk1.5.0\bin\javac Hello.java
perl StartupTimeTest.pl jdk150_off
Hello world!
Hello world!
...
Command: \j2sdk1.5.0\bin\java -cp . -Xshare:off Hello
Total time: 31 seconds.
Average time: 0.31 seconds.

perl StartupTimeTest.pl jdk150_on
Hello world!
Hello world!
...
Command: \j2sdk1.5.0\bin\java -cp . -Xshare:on Hello
Total time: 18 seconds.
Average time: 0.18 seconds.

The test result is very interest:

Last update: 2004.

Table of Contents

 About This Book

 Downloading and Installing JDK 1.8.0 on Windows

 Downloading and Installing JDK 1.7.0 on Windows

 java.lang.Runtime Class - The JVM Instance

 java.lang.System Class - The Operating System

 ClassLoader Class - Class Loaders

 Class Class - Class Reflections

 Sun's JVM - Java HotSpot VM

 JRockit JVM 28.2.7 by Oracle Corporation

 JVM Runtime Data Areas

 Memory Management and Garbage Collectors

 Garbage Collection Tests

 JVM Stack, Frame and Stack Overflow

 Thread Testing Program and Result

 CPU Impact of Multi-Thread Applications

 I/O Impact of Multi-Thread Applications

CDS (Class Data Sharing)

 What Is Class Data Sharing?

 Regenerating Shared Archive

Startup Time Saving with Restoring Shared Archive

 Startup Time Saving with Multiple JVM Processes

 Footprint Saving with Restoring Shared Archive

 Viewing Shared Memory of JVM Processes

 Micro Benchmark Runner and JVM Options

 Micro Benchmark Tests on "int" Operations

 Micro Benchmark Tests on "long" Operations

 Micro Benchmark Tests in JIT Compilation Mode

 Micro Benchmark Tests on "float" and "double" Operations

 Outdated Tutorials

 References

 PDF Printing Version