Java VM调优- Xbatch和- xcomp。

时间:2022-04-16 14:33:44

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:

我正在查看运行Alfresco的JVM配置选项,主要是关于Alfresco Wiki的文档。其中一个建议是使用JVM标记-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.

如果希望有Hotspot预编译类,可以添加[-Xcomp和-Xbatch]。但是,这将显著增加服务器启动时间,但会突出显示可能稍后会被攻击的缺少的依赖项。

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

从我在其他地方读到的关于-Xcomp和-Xbatch的标记,我想知道它们是否真的提供了任何好处。

  • -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.
  • -Xcomp通过最大的优化来预先编译所有的代码,从而避免了VM将通过系统的标准运行的任何分析。
  • -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.
  • -Xbatch停止后台编译,这意味着在编译完成之前,导致代码被编译块的线程。但是,在编译完成后,预先阻塞的线程将不会运行已编译的代码,它仍然会运行解释代码。这是Java 6 (Mustang)的一个变化——在Mustang之前,当编译完成时,在编译后的代码中,可以保证在编译后的代码中运行的线程被阻塞。因此,我猜测-Xbatch标志的推荐是在旧vm上运行Alfresco的一个遗留。

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

有人有什么想法吗?我的倾向是去掉这两种标志,并依赖VM来把事情做好。

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.

我想添加两件事,首先,我还没有获得一个露天的实例测试这个,其次我真的不知道是什么规格的机器托管Alfresco以外,通过查看其他配置选项,它必须是一个64位的虚拟机。尽管如此,我希望社区能够有一些有用的输入,也许从一个通用的热点调优的角度来看。

2 个解决方案

#1


21  

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.

一般来说,最好让HotSpot编译器自己调优。即使使用服务器VM (-server)也默认为64位和一些“服务器类”机器。

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

-Xbatch主要用于调试,正如Steve Goldman的博客所描述的:

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.

因此,即使在前mustang时代,-Xbatch开关也不是一个特别有用的开关。对于jvm开发人员来说,这有些用处,因为它会使运行更容易预测和重现。

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

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

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.

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

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.

如果不考虑性能,我从未见过使用这些标志来检测丢失的依赖项(如果某些代码仍然被解释的话,它可能不会起作用),因此,我将处理这两者。

#2


0  

Alfresco is an Enterprise Content Management. I am not sure how the flags affects its performance. Then a note in the same page said..

Alfresco是一个企业内容管理。我不确定国旗如何影响它的性能。然后在同一页的一张纸条上写着……

-- This will, however, significantly increase the server startup time, but will highlight missing dependencies that can be hit later. ...

但是,这将显著增加服务器启动时间,但会突出显示可能稍后会被攻击的缺少的依赖项。

IMHO, The author did not really mean a performance gain. He/she wrote it as means to check all dependencies are in place.

IMHO,作者并不是指绩效的增加。他/她把它写成检查所有依赖项的方法。

#1


21  

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.

一般来说,最好让HotSpot编译器自己调优。即使使用服务器VM (-server)也默认为64位和一些“服务器类”机器。

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

-Xbatch主要用于调试,正如Steve Goldman的博客所描述的:

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.

因此,即使在前mustang时代,-Xbatch开关也不是一个特别有用的开关。对于jvm开发人员来说,这有些用处,因为它会使运行更容易预测和重现。

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

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

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.

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

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.

如果不考虑性能,我从未见过使用这些标志来检测丢失的依赖项(如果某些代码仍然被解释的话,它可能不会起作用),因此,我将处理这两者。

#2


0  

Alfresco is an Enterprise Content Management. I am not sure how the flags affects its performance. Then a note in the same page said..

Alfresco是一个企业内容管理。我不确定国旗如何影响它的性能。然后在同一页的一张纸条上写着……

-- This will, however, significantly increase the server startup time, but will highlight missing dependencies that can be hit later. ...

但是,这将显著增加服务器启动时间,但会突出显示可能稍后会被攻击的缺少的依赖项。

IMHO, The author did not really mean a performance gain. He/she wrote it as means to check all dependencies are in place.

IMHO,作者并不是指绩效的增加。他/她把它写成检查所有依赖项的方法。