Using Jet to Natively Compile

Started by psiegel, June 10, 2003, 19:57:10

Previous topic - Next topic

psiegel

Cas, I was wondering what kind of ratio you have of jar to exe file size?  Before I decide to purchase Jet, I decided to download the demo version of Jet Pro to see how well it works.  It took my ~200K jar and turned it into a 3.4 MB exe.  That seems like a significant increase to me, and I'm sort of hoping I missed some setting somewhere to make it yet smaller.

I know I've obliterated all references to AWT in the code, as the resulting exe runs fine on a machine with no java at all.  Also, there's no media files packed into that jar, it's purely byte code.  

Are you getting similar results?  If not, any clue what kind of mistakes I might be making that causes so much bloat?

Paul

princec

It can bring in AWT stuff even when you don't realise it! But AF weighs in at about 4.5mb for the JAR and 5.5mb for the EXE.

Just one tiny reference to a weeny bit of AWT seems to bring in approximately 4 megs of stuff.

Cas :)

psiegel

Is there a good way to hunt this stuff down?  I  tried sifting through my usage file (.usg)  but see no references to java.awt.  Plus I thought the thing wouldn't run on a machine without java if it included any of the awt classes.  I know this is not the case, as I have a test machine that has never had java installed on it and the game runs fine.

4.5 to 5.5 MB sounds like not much bloat.  200k to 3.4 MB is a much bigger ratio.  However, I'm curious how much of your app is resource files.  I know you pack all your resources into the jar/exe.  In my case, I've kept all the resource files extenral, leaving only .class files in my jar.  That's why it's so darn small.

I assume Jet will pack some extra stuff into the exe, I'm just trying to put my finger on how much of that to expect, and whether it's a constant amount, or a factor of the original byte code size.

Paul

princec

It's completely dependent on the classes that get dragged in in your usg file. Our data is about 3MB or so compressed, and the bytecode's another 1MB, so there's about 1.5MB of stuff Jet brings in from various places.

Cas :)

psiegel

I guess I'll have to scour through the usage file and see what exactly is in there.  Do you have any tips on how to trim it down?  For instance, would changing an import from java.foo.* to java.foo.Bar potentially decrease size by ensuring only the one class is imported?  I don't know if the usage file just scours the imports, or if it actually listens to what the ClassLoader is pulling up.

Paul

psiegel

Ok, I've been trying and trying to get Jet to make my executable a little bit smaller.  Still my 800 KB turns into a 3.4 MB exe.  And I'll note, that 800 KB jar includes all the lwjgl classes.  So clearly I'm getting about 2.5 MB of extra stuff from Jet.  Now, you claim to be only getting 1.5 MB of stuff from Jet.  I'd really like to drop that extra MB myself.

Finally, I made a simple Hello World app.  A single println(), that's all the thing does.  1 KB class file.  Run through Jet using JetPerfect, I get a 2.5 MB exe.  

Perhaps it's the JDK I've installed Jet on top of?  I'm using JDK 1.4.1_01.  What are you using?

Paul

princec

1.4.1_01 also.

Tell you what, when I get a spare moment I'll compile Hello World too and see what I get. Then we can see if you're doing something wrong.

Oooh, and I might not have mentioned it but I use very low inlining - it vastly increases the size of the exe. I turn it up for the full version again but it makes an almost totally imperceptible change in performance.

Cas :)

psiegel

Well, this makes my findings even more interesting!  I switched Jet over to JDK 1.3.1 and recompiled Hello World, using all the same settings as before.  Total exe size: 700 KB.  That's an incredible improvement.

Now, I wonder if my actual code will compile under 1.3.1?  In fact, it raises an interesting question - how low can I go?  What's the minimum JDK version required for LWJGL?

Paul

psiegel

Ok, I switched back to JDK 1.4.1 and set my inlining to low.  Sure enough, my complete project has dropped in size about 1 MB.  The 800 KB jar now compiles to a 2.4 MB exe.

I am still curious though about what the minimum JVM version is for LWJGL.  I'm wondering now if I set my inlining down AND switch to an older JVM, perhaps I can really trim that size down.

Paul

cfmdobbie

I think 1.4 will be the minimum - you need NIO buffers.  Unless, did Sun ever produce an NIO add-on for <=1.3?
ellomynameis Charlie Dobbie.

psiegel

Ah, you're right, I don't think they came about until 1.4.  Oh well, at least the inlining settings are having an effect.  I think I can deal with an extra 1 MB of Jet VM.  It's certainly a lot smaller than Sun's!

Paul

dleskov

Quote from: "princec"It's completely dependent on the classes that get dragged in in your usg file. Our data is about 3MB or so compressed, and the bytecode's another 1MB, so there's about 1.5MB of stuff Jet brings in from various places.
Cas :)

Java bytecode is a very compact program representation. The equivalent optimised Pentium code produced by Excelsior JET can be  5-10 times the size of the original jar, especially if you enable inlining.

What JetPerfect does is it reads your classes and the Java API classes required to run your app and compiles only the methods that have a chance to be executed. i.e. they are reachable from main() or called via reflection (that is what the usage list is about.) So the resulting EXE contains code for methods of both your classes and classes from rt.jar. If your app is not using the entire Java 2 API, its EXE is likely to be smaller than jar+JRE.