The Artima Developer Community
Sponsored Link

Java Buzz Forum
Class Data Sharing in JDK 1.5.0

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Class Data Sharing in JDK 1.5.0 Posted: Jun 23, 2004 10:10 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Class Data Sharing in JDK 1.5.0
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

Just noticed a new feature in the JDK 1.5.0 Beta2 called Class Data Sharing.

Certain system classes from the rt.jar are loaded and then memory dumped into a shared archive file /opt/jdk1.5.0/jre/lib/i386/client/classes.jsa, either during installation or by running java -Xshare:dump.

On my system, this file is 12591104 bytes long.

Subsequent invocations of Java programs will merely map this file into memory, saving the time to load the classes. Moreover, between five to six megabytes of the shared archive (metadata for the classes in the shared archive) will be mapped read-only and shared by all JVM instances.

The net result is faster startup time for small Java programs such as BeanShell scripts. Here's some benchmarks while running a trivial class with an empty CLASSPATH:

[weiqi@gao] $ cat Foo.java
public class Foo {
  public static void main(String[] args) throws Exception {
    Thread.sleep(1000);
  }
}
[weiqi@gao] $ . switch-to-1.5.0
[weiqi@gao] $ time java Foo

real    0m1.101s
user    0m0.051s
sys     0m0.017s
[weiqi@gao] $ time java -Xshare:off Foo

real    0m1.144s
user    0m0.103s
sys     0m0.023s
[weiqi@gao] $ . switch-to-1.4.2
[weiqi@gao] $ time java Foo

real    0m1.131s
user    0m0.082s
sys     0m0.017s

Discounting the 1 second sleep, startup time in 1.5.0 Beta2 is 23% faster than in 1.4.2_04, and 30% faster than in 1.5.0 Beta2 with class data sharing turned off.

Ever since I started using Java, I have expressed the opinion that it is foolish to load and jit Java classes like java.lang.Object and java.lang.String on every invocation of any Java program, day after day, month after month, year after year.

I'm glad to see class data sharing coming to the JDK.

Read: Class Data Sharing in JDK 1.5.0

Topic: [Jun 16, 2004 03:15 PDT] 11 Links Previous Topic   Next Topic Topic: Yahoo to launch 100MB free e-mail

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use