Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 207282 - Our ebuilds for sun-jdk and sun-jre could build classes.jsa
Summary: Our ebuilds for sun-jdk and sun-jre could build classes.jsa
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Java (show other bugs)
Hardware: x86 Linux
: High enhancement (vote)
Assignee: Java team
URL: http://java.sun.com/javase/6/docs/tec...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-24 13:39 UTC by Andrew Cowie
Modified: 2008-03-27 20:28 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cowie 2008-01-24 13:39:01 UTC
Apparently there is something in Sun's JVM called "Class Data Sharing", which involves preloading the rt.jar classes and writing a memory image of them down to disk, which is later mmaped as read-only and thus able to be shared memory between running VMs, with a view to saving memory across a system and (more to the point) reducing start-up time for systems running `java -client`.

The referenced pages mention that Sun's "installer" builds classes.jsa on the target machine at installation, but it describes the (undocumented) option to build it yourself as necessary,

# java -client -Xshare:dump

It writes classes.jsa to the JRE's system directory, so you'll need to be root.

My own local testing showed a small but noticeable startup speed improvement. Perhaps others could try this and report.

AfC
Comment 1 Krzysztof Pawlik (RETIRED) gentoo-dev 2008-01-24 13:54:01 UTC
There's no Client VM for amd64 for example.
Comment 2 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2008-01-24 13:58:44 UTC
Nice idea though, we just need to come up with nice USE flag name + description (the long description in metadata.xml would probably help here). The flag would be obviously masked on amd64 because nelchael is right.
Comment 3 Andrew Cowie 2008-01-24 22:24:55 UTC
For what it's worth, by all appearances the thing just (politely) fails if the VM doesn't support it (Try `java -server -Xshare:dump` to see what I mean); could just include it in the ebuild; if it works it works, if not, no biggie. Not so sure you need a whole USE flag for it.

Incidentally, more testing has shown the startup benefit is definitely significant, and the simple fact of page sharing between VMs is exciting.

If you want to see it using the shared data, try:

$ java -client -verbose:class -Xshare:off HelloWorld

(ie, the normal state of affairs) vs

$ java -client -verbose:class -Xshare:on HelloWorld

(force it, and compare what it says when loading classes)

AfC

P.S. I've always forced my build and launcher systems to specify -client; most people thought I was weird for it as it was the "default"; interestingly on my current system the `java` front end has decided that -server is the default.
Comment 4 Alistair Bush (RETIRED) gentoo-dev 2008-01-25 05:14:49 UTC
(In reply to comment #3)
> Not so sure you need a whole USE flag for it.

we would have to be able to support the default option, as we don't know the side effects.  Plus we could always enable the flag by default and then ppl could disable it if they really wanted to.

> 
> Incidentally, more testing has shown the startup benefit is definitely
> significant, and the simple fact of page sharing between VMs is exciting.
> 

Numbers, we need numbers  (well, I want numbers)


Poor me and my amd64 vms :(
Comment 5 Alistair Bush (RETIRED) gentoo-dev 2008-01-25 05:23:47 UTC
For reference, here is some doco's

http://java.sun.com/javase/6/docs/technotes/guides/vm/class-data-sharing.html
Comment 6 Andrew Cowie 2008-01-25 06:11:39 UTC
(In reply to comment #5)
> For reference, here are some docs

That is the URL I put in the bug's URL field :)

AfC
Comment 7 Andrew Cowie 2008-02-15 05:47:50 UTC
Turns out that Sun's 1.6 JRE also supports Class Data Sharing for it's server VM. (as I found out when I ran `java -Xshare:dump` and forgot to supply `-client` onyl to have it succeed and write:

/opt/sun-jdk-1.6.0.04/jre/lib/i386/server/classes.jsa

Running again as `java -client -Xshare:dump` resulted in:

/opt/sun-jdk-1.6.0.04/jre/lib/i386/client/classes.jsa

being created. Huh.

AfC
Comment 8 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2008-03-26 22:04:27 UTC
I just noticed the emul-linux-x86-java:1.5 ebuilds do this, and a bit of search revealed that we already did it in 1.5 JDK's (client only) until it disappeared for some unknown reason in 1.5.0.09...
Comment 9 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2008-03-26 22:06:40 UTC
(In reply to comment #7)
> Turns out that Sun's 1.6 JRE also supports Class Data Sharing for it's server
> VM. (as I found out when I ran `java -Xshare:dump` and forgot to supply
> `-client` onyl to have it succeed and write:

Not on amd64 :(

gehinom ~ # GENTOO_VM=sun-jre-bin-1.6 java -Xshare:dump
Error occurred during initialization of VM
Dumping a shared archive is not supported on the Server JVM.
gehinom ~ # GENTOO_VM=sun-jre-bin-1.6 java -client -Xshare:dump
Error occurred during initialization of VM
Dumping a shared archive is not supported on the Server JVM.

But we can add it for x86.
Comment 10 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2008-03-27 20:28:22 UTC
OK, it's added in sun-jdk, sun-jre-bin (for x86) and the emul-linux package (amd64). In 1.6 for both client and server, in 1.5 for client only. JRE's already had it for client VM because the construct.sh script creates it - just added to 1.6 JRE's for server VM. Moved it from construct.sh to the ebuild.