Does Java 64 bit perform better than the 32-bit version?

23,788

Solution 1

Define your workload and what "perform" means to you.

This is sort of a running annoyance to me, as a performance geek of long standing. Whether or not a particular change "performs better" or not is dependent, first and foremost, on the workload, ie, what you're asking the program to do.

64 bit Java will often perform better on things with heavy computation loads. Java programs, classically, have heavy I/O loads and heavy network loads; 64 bit vs 32 bit may not matter, but operating systems usually do.

Solution 2

Almost always 64 bits will be slower.

To quote Sun from the HotSpot FAQ:

The performance difference comparing an application running on a 64-bit platform versus a 32-bit platform on SPARC is on the order of 10-20% degradation when you move to a 64-bit VM. On AMD64 and EM64T platforms this difference ranges from 0-15% depending on the amount of pointer accessing your application performs.

There are more details at the link.

Solution 3

64-bit perform better if you need much more than 1.2 GB. On some platforms you can get up to 3 GB but if you want 4 - 384 GB for example, 64-bit is your only option.

I believe Azul supports a 384 GB JVM, does anyone know if you can go higher?

Solution 4

I know that this question is quite old and the voted answers were probably correct at the time when they were written. But living in 2018 now, things have changed.

I just had an issue with a Java client application running on Win 10 64Bit on a Java 8 32Bit JVM. It was reading 174 MB of data from an HttpsURLConnection's InputStream in 26s which is awfully slow. The server and network were proven not to be the cause of this.

Thinking "Hey, there cannot be a huge difference between 32Bit and 64Bit JRE" it took some time until I tried having the very same code executed by a 64Bit JVM. Fortunately, in the end I did it: It was reading the very same 174MB in 5s!

I don't know if I could make it even faster, but the key take-away is this:

  • jre1.8.0_172 32Bit : 6.692MB/s
  • jre1.8.0_172 64Bit : 34.8MB/s

for the very same jar file being executed on Windows 10 64Bit.

I have no idea what could be the reason for this, but I can answer this question by "Yes, 64Bit Java is better than 32Bit Java". See also the numbers in the answer of my question regarding this issue.

Solution 5

Some improvements: operations with doubles on 64 bits compute equally fast as floats on 32 bits, as well as operations on long at 64 bit compared to int.

So if you are running code with tons of longs you might see a real improvement.

Share:
23,788
Joshua
Author by

Joshua

Software Engineer Sr. MS in Computer Science from DePaul University.

Updated on June 30, 2020

Comments

  • Joshua
    Joshua almost 4 years

    I noticed Sun is providing a 64-bit version of Java. Does it perform better than the 32-bit version?

  • Cheeso
    Cheeso about 15 years
    Can't believe the answer is this simple. For me 64 bit is more suited to loads where 64-bit address space is a help and not a hindrance. There is a 2x cost for every pointer, which can be outweighed if you need LOTS of data. a web server object cache is a great example of where 64 bit wins.
  • Charlie Martin
    Charlie Martin about 15 years
    Darron, you have a citation for that? Since I worked for Sun for 10 years, and since the answer is basically "it depends on the workload and what kind of performance you care about measuring", I -- how to put this -- don't believe you.
  • Darron
    Darron about 15 years
  • Darron
    Darron about 15 years
    I suspect the cause is that most of the time the increased sizes of objects (because of pointer sizes) swamps the benefits from more efficient operations on longs and doubles.
  • Charlie Martin
    Charlie Martin about 15 years
    Okay, I see how you got there, but it still comes down to the 64-bit will perform better on some workloads, worse on others, and it's a wash on yet others. In other words, "dependent first and foremost on the workload".
  • karmakaze
    karmakaze about 11 years
    The comments here appear to be somewhat outdated. The 2x pointer size argument is invalid as UseCompressedOops is enabled by default. The performance gain is not just from amount of addressable memory and wider data handling: the 64-bit jvm has more registers to use which is much faster than accessing memory.
  • Charlie Martin
    Charlie Martin about 11 years
    The answer though is "it's dependent on the problem."
  • johnny
    johnny almost 11 years
    1.2GB or what? memory?
  • Vishy
    Vishy almost 11 years
    @johnny Yes, 1.2 GB of memory on 32-bit Windows systems.
  • phuclv
    phuclv over 8 years
    it's almost always faster on x86_64, as indicated in the above paragraph
  • Suici Doga
    Suici Doga almost 8 years
    I installed 64-bit Java and Android Studio became really fast.Also some people say it increases FPS in Java games like Minecraft
  • Charlie Martin
    Charlie Martin almost 8 years
    I'd expect graphics-intensive programs to be faster. The guts of graphics programs really come down to doing a crapload of 4x4 matrix multiplies, and pushing a lot of data to fast memory. The 64-bit instruction set on Intel has instructions that better fit the graphics, and the graphics data pipeline is bigger.