Java VM调优 - Xbatch和-Xcomp [英] Java VM tuning - Xbatch and -Xcomp

查看:110
本文介绍了Java VM调优 - Xbatch和-Xcomp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看运行Alfresco的JVM配置选项,主要是这个文件在< a href =http://wiki.alfresco.com/wiki/Main_Page =noreferrer> Alfresco Wiki 。其中一个建议是使用JVM标志 -Xcomp -Xbatch 。这样做的理由是:

I am looking at the JVM configuration options for running Alfresco, mainly this document on the Alfresco Wiki. One of the recommendations is to use the JVM flags -Xcomp and -Xbatch. The justification of this is:


如果您希望Hotspot预编译类,可以添加[-Xcomp和-Xbatch]。但是,这会显着增加服务器启动时间,但会突出显示以后可能会遇到的缺失依赖项。

If you wish to have Hotspot precompile the classes, you can add [-Xcomp and -Xbatch]. This will, however, significantly increase the server startup time, but will highlight missing dependencies that can be hit later.

从我拥有的在其他地方阅读关于 -Xcomp -Xbatch 标志,我想知道他们是否确实提供了任何好处。

From what I have read elsewhere about the -Xcomp and -Xbatch flags, I am wondering whether they really provide any benefit.


  • -Xcomp 让HotSpot预先编译所有代码并进行最大程度的优化,从而优先于VM通过系统的标准运行获得的任何分析。 / li>
  • -Xbatch 停止后台编译,这意味着在编译完成之前导致代码被编译的线程。但是,在编译完成后,先前阻塞的线程将不会运行已编译的代码它仍将运行解释的代码。这是Java 6(Mustang)的一个变化 - 在Mustang之前,由于存在 -Xbatch 标志而被阻止进行编译的线程保证在编译后的代码中尽快运行编译完成了。因此,我猜测 -Xbatch 标志的建议是在旧VM上运行Alfresco的遗留物。

  • -Xcomp gets HotSpot to compile all code beforehand with maximum optimization, thus foregoing any profiling that the VM will get through the standard running of the system.
  • -Xbatch stops background compiling, meaning the thread which caused the code to be compiled blocks until the compile is complete. However, after the compile is finished, the previously-blocked thread will not run the compiled code, it will still run the interpreted code. This was a change in Java 6 (Mustang) – before Mustang, threads blocked for compiling by the presence of the -Xbatch flag were guaranteed to run in the compiled code as soon as the compile was completed. Therefore, I am guessing that the recommendation of the -Xbatch flag is a relic of running Alfresco on older VMs.

有没有人有任何想法?我倾向于摆脱这两面旗帜并依靠虚拟机来解决问题。

Does anyone have any thoughts? My inclination is to get rid of these two flags and rely on the VM to get things right.

我想补充两件事,首先我要做的不是然后我可以访问一个Alfresco实例来测试这个,其次我不知道什么样的机器托管Alfresco而不是通过查看其他配置选项它必须是64位VM。尽管如此,我希望社区能够提供一些有用的输入,可能来自一般的HotSpot调整观点。

I would like to add two things, first of all that I don't yet have access to an Alfresco instance to test this on and secondly I don't really know what spec of machine is hosting Alfresco other than that by looking at the other configuration options it must be a 64 bit VM. Despite this, I hope the community will have some useful input, perhaps from a general HotSpot-tuning point of view.

推荐答案

说来,让HotSpot编译器自我调整总是更好。即使使用服务器VM(-server)也是默认的64位和一些服务器级机器。

Generally speaking, it's always preferable to let HotSpot compiler tune itself. Even using Server VM (-server) is default for 64bits and some 'server-class' machines.

-Xbatch主要用于调试,如史蒂夫·戈德曼的博客你指出:

-Xbatch was intended mostly for debugging as described in Steve Goldman's blog you pointed:


因此-Xbatch开关即使在野马前也不是特别有用的开关。它对jvm开发人员有用,因为它可以使运行更具可预测性和可重现性。

So the -Xbatch switch is not a particularly useful switch even in the pre-mustang days. It is somewhat useful for jvm developers since it tends to make a run more predictable and reproducible.

-Xcomp删除了收集信息的能力有效编译。来自 Alex Turner的帖子

-Xcomp removes the ability to gather information for efficient compilation. From an Alex Turner's post:


从性能的角度来看,人们可能会认为-Xcomp是个好主意。但是,它不是! JIT编译器在编译之前使用这1000次迭代来收集有关如何编译方法以获得最佳效率的信息。 -Xcomp删除了这样做的能力,因此我们实际上可以看到性能下滑。

One might think that -Xcomp would be a good idea from a performance point of view. However, it is not! The JIT compiler uses those 1000 iterations before compilation to gather information on how the method should be compiled for optimal efficiency. -Xcomp removes its ability to do so and thus we can actually see performance slip.

没有表现,我从未见过使用这些标志来检测缺少的依赖项(如果某些代码仍被解释可能无法正常工作)恕我直言,我会摆脱两者。

Without performance in mind, I've never seen using those flags to detect missing dependencies (and it may not work if some code is still interpreted) so IMHO, I would get rid of both.

这篇关于Java VM调优 - Xbatch和-Xcomp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆