为什么是64位JVM比32位的速度更快?

为什么是64位JVM比32位的速度更快?

问题描述:

最近我一直在做我公司的数据库产品的写入性能,对于一些基准,我发现,简单地切换到64位JVM给出了一致的20-30%的性能提升。

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 consistent 20-30% performance increase.

我不能进入的细节对我们的产品,但基本上它是一个面向列的数据库,用于存储日志的优化。基准涉及喂养它原木和时间需要多长时间来对它们进行分析,并将其存储在数据库结构化数据的几GB。该处理是非常沉重的CPU和I / O,虽然很难在什么比说了。

I'm not allowed to go into much detail about our product, but basically it's a column-oriented DB, optimised for storing logs. The benchmark involves feeding it a few gigabytes of raw logs and timing how long it takes to analyse them and store them as structured data in the DB. The processing is very heavy on both CPU and I/O, although it's hard to say in what ratio.

有关安装的几个注意事项:

A few notes about the setup:

Processor: Xeon E5640 2.66GHz (4 core) x 2
RAM: 24GB
Disk: 7200rpm, no RAID
OS: RHEL 6 64bit
Filesystem: Ext4
JVMs: 1.6.0_21 (32bit), 1.6.0_23 (64bit)
Max heap size (-Xmx): 512 MB (for both 32bit and 64bit JVMs)

常量为JVM的:

Constants for both JVMs:

  • 在相同的操作系统(64位RHEL)
  • 在相同的硬件(64位CPU)
  • 最大堆大小固定为512 MB(因此速度增加不是由于使用更大的堆64位JVM)

为了简单起见,我关闭了所有的多线程选择我们的产品,所以pretty的多少全部过程都发生在单线程的方式。 (当我打开多线程,当然该系统得到了更快,但32位和64位性能之间的比率停留大约相同。)

For simplicity I've turned off all multithreading options in our product, so pretty much all processing is happening in a single-threaded manner. (When I turned on multi-threading, of course the system got faster, but the ratio between 32bit and 64bit performance stayed about the same.)

所以,我的问题是......为什么我会看到一个20%-30%的速度提升使用64位JVM时?有人看到了类似的结果之前?

So, my question is... Why would I see a 20-30% speed improvement when using a 64bit JVM? Has anybody seen similar results before?

我的直觉,直至现在一直如下:

My intuition up until now has been as follows:

  • 64位指针较大,所以L1和L2更容易缓存溢出,因此在64位JVM性能较差。

  • 64bit pointers are bigger, so the L1 and L2 caches overflow more easily, so performance on the 64bit JVM is worse.

JVM使用一些花哨的指针COM pression技巧,以缓解上述问题,尽可能多地。在这里太阳网站详细信息。

The JVM uses some fancy pointer compression tricks to alleviate the above problem as much as possible. Details on the Sun site here.

在JVM是允许在64位模式,从而加快东西稍微运行时使用更多的寄存器。

The JVM is allowed to use more registers when running in 64bit mode, which speeds things up slightly.

鉴于以上三点,我希望64位的性能要稍微慢一些,大约等于32位JVM。

Given the above three points, I would expect 64bit performance to be slightly slower, or approximately equal to, the 32bit JVM.

任何想法?先谢谢了。

编辑:澄清有关的基准测试环境的一些要点

Clarified some points about the benchmark environment.

不知道你的硬件,我只是把一些野生刺

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

  • 您指定的CPU,可以使用微code到'的emulate一些x86指令 - 最明显的是的x87 ISA
  • 64使用代替的x87数学SSE数学,我注意到%10%20加速在这种情况下,一些数学为主的C ++应用程序。数学差异可能,如果你使用的是真正的杀手锏 strictfp
  • 内存。 64位给你更多的地址空间。也许在GC上的64位模式,少一点侵略性,因为你有额外的内存。
  • 是您​​的操作系统是在64B模式,并通过一些包装工具运行32B的JVM?
  • 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?