Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64-bit Java VM runs app 10x slower

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.

like image 1000
craiglurey Avatar asked Dec 02 '09 17:12

craiglurey


People also ask

Can 64 bit Java run 32 bit programs?

If you have installed Widows OS with 64bits, your IE will also be that of the same bit allowing you to run 32bits programs on it. However you cannot run 64bits program if your OS and IE belong to a 32bit architecture. Also you will not be able to install programs belonging to both bits on the same laptop.

Why is JVM slow?

2.1 Possible Causes for Slow JVM StartupThe application might be waiting to import files. A large number of methods might have to be compiled. There might be a problem in code optimization (especially on single-CPU machines). The problem might be caused by the Java application and not the JVM.

Can Java run in 32 bit?

The Java Platform was designed to allow applications to run on different hardware stacks and operating systems without changes. Java is available on Microsoft Windows in 64 and 32 bit versions, allowing users to get the appropriate version for their system.

How long does it take to start a JVM?

If you run Hello World application it takes 0.15 seconds on my machine. However, Java is better suited to running as a client or a server/service which means the startup time isn't as important as the connection time (about 0.025 ms) or the round trip time response time (<< 0.001 ms).


1 Answers

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.

like image 197
Joel Avatar answered Oct 14 '22 16:10

Joel