在对一个应用程序进行了一些更改后,它的性能显著下降,在调查后发现其中一个最频繁调用的方法不再被编译。打开:-XX:+LogCompilation
显示,在更改之前,此方法已经:排队等待编译、编译并成功内联到调用者; 然而在更改后,没有记录编译尝试的记录,并且内联尝试显示:
inline_fail reason='not compilable (disabled)'
原始方法如下所示,其中_maxRepeats
是作为Map
声明的实例变量(没有泛型,编写时间很久),使用时键是DadNode
类的对象,值是Integer
。
private int cnsGetMaxRepeats(DadNode dn) {
if (_maxRepeats != null) {
Integer max = (Integer)_maxRepeats.get(dn);
if (max != null) {
return max;
}
}
return dn.getMaxOccurs().getValue();
}
修改涉及将_maxRepeats
map更改为使用泛型: Map<Integer, Integer>
并且该方法添加了一个新参数:
private int cnsGetMaxRepeats(int childIdx, DadNode dn) {
if (_maxRepeats != null) {
Integer max = _maxRepeats.get(childIdx);
if (max != null) {
return max;
}
}
return dn.getMaxOccurs().getValue();
}
使用显式调用 Integer.valueOf
和 Integer.intValue
来避免自动装箱不会有任何区别;该方法仍然无法编译。
我可以“用棍子戳它”直到我得到一个做我想做的事情(并且也可编译)的解决方案,但是这种禁用背后的标准是什么?
-XX:ReservedCodeCacheSize
- GeneLogCompilation
长期以来一直是PrintCompilation
... - Eugene