views:

272

answers:

1

I have a Java app which is packaged up using JarBundler. The app is fairly CPU intensive (lots of big Collection.sort() calls).

On Mac OS, the app runs slow and sluggish when using the 64-bit JavaApplicationStub. This JavaApplicationStub file is launching the Java 64-bit VM.

I found an old JavaApplicationStub file which is 32-bit only. I replaced it in the Bundle, and the app runs 10x faster! (consequently, the 32-bit VM is utilized when the application runs).

Does this make any sense? Why is the 64-bit VM so much slower? Does it make sense to build an app and hack the JavaApplicationStub file like this?

Advise is appreciated.

+1  A: 

See this post on the benefits/disadvantages of running a 64bit JVM. In summary pointer dereferencing & memory de-allocation can take longer - and you are moving around larger data-structures (i.e. 64, not 32 bit, which serves you no advantage to you unless you are explicity making use of them).

Also see this relevant article, where they discuss decreases in performance of up to 85% when moving to 64bit, which is in-line with what you are experiencing:

The reason for this decrease in performance is actually very much related to the increase in memory. The memory references under the covers of Java became twice the size increasing the size of memory structures in the WAS runtime and your application's objects. Unfortunately the processor memory cache sizes didn't get larger at the same time. This means more memory cache misses, which means more busy work for the hardware dealing with the larger memory, which means worse application performance.

Joel
So if sticking to 32-bit is the answer, then what is the best way to enforce this? Should JavaApplicationStub be reverted to the 32-bit version, or should it be executed with different VM parameters?
simpliway
I'm not a JavaApplicationStub/mac user and couldn't find any docs relating to it, but on the standard Sun jvm there isn't a 'run 64bit jvm in 32bit mode' option as far as i can tell ( http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp#BehavioralOptions ) so just use the 32 bit build, if you can.
Joel