Why is the 64bit JVM faster than the 32bit one?

前端 未结 5 721
灰色年华
灰色年华 2020-12-05 11:13

Recently I\'ve been doing some benchmarking of the write performance of my company\'s database product, and I\'ve found that simply switching to a 64bit JVM gives a consiste

相关标签:
5条回答
  • 2020-12-05 12:03

    My best guess, based on a quick google for 32- vs 64-bit performance charts, is that 64 bit I/O is more efficient. I suppose you do a lot of I/O...

    If memcpy is involved when moving the data, it's probably more efficient to copy longs than ints.

    0 讨论(0)
  • 2020-12-05 12:08

    Without knowing your hardware I'm just taking some wild stabs

    • Your specific CPU may be using microcode to 'emulate' some x86 instructions -- most notably the x87 ISA
    • x64 uses sse math instead of x87 math, I've noticed a %10-%20 speedup of some math-heavy C++ apps in this case. Math differences could be the real killer if you're using strictfp.
    • Memory. 64 bits gives you much more address space. Maybe the GC is a little less agressive on 64 bits mode because you have extra RAM.
    • Is your OS is in 64b mode and running a 32b jvm via some wrapper utility?
    0 讨论(0)
  • 2020-12-05 12:11

    Realize that the 64-bit JVM is not magic pixie dust that makes Java apps go faster. The 64-bit JVM allows heaps >> 4 GB and, as such, only makes sense for applications which can take advantage of huge memory on systems which have it.

    Generally there is either a slight improvement (due to certain hardware optimizations on certain platforms) or minor degradation (due to increased pointer size). Generally speaking there will be a need for fewer GC's -- but when they do occur they will likely be longer.

    In memory databases or search engines that can use the increased memory for caching objects and thus avoid IPC or disk accesses will see the biggest application level improvements. In addition a 64-bit JVM will also allow you to run many, many more threads than a 32-bit one, because there's more address space for things like thread stacks, etc. The maximum number of threads generally for a 32-bit JVM is ~1000but ~100000 threads with a 64-bit JVM.

    Some drawbacks though:
    Additional issues with the 64-bit JVM are that certain client oriented features like Java Plug-in and Java Web Start are not supported. Also any native code would also need to be compatible (e.g. JNI for things like Type II JDBC drivers). This is a bonus for pure-Java developers as pure apps should just run out of the box.

    More on this Thread at Java.net

    0 讨论(0)
  • 2020-12-05 12:13

    From: http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#64bit_performance

    "Generally, the benefits of being able to address larger amounts of memory come with a small performance loss in 64-bit VMs versus running the same application on a 32-bit VM. This is due to the fact that every native pointer in the system takes up 8 bytes instead of 4. The loading of this extra data has an impact on memory usage which translates to slightly slower execution depending on how many pointers get loaded during the execution of your Java program. The good news is that with AMD64 and EM64T platforms running in 64-bit mode, the Java VM gets some additional registers which it can use to generate more efficient native instruction sequences. These extra registers increase performance to the point where there is often no performance loss at all when comparing 32 to 64-bit execution speed.
    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."

    0 讨论(0)
  • 2020-12-05 12:13

    The 64-bit instruction set has 8 more registers, this should make the code faster overall.

    But, since processsors nowaday mostly wait for memory or disk, i suppose that either the memory subsystem or the disk i/o might be more efficient in 64-bit mode.

    0 讨论(0)
提交回复
热议问题