使用Java 8在Drools 6.2中禁用JIT [英] Disable JIT in Drools 6.2 with Java 8

查看:292
本文介绍了使用Java 8在Drools 6.2中禁用JIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Drools版本6.2.0.Final来解析我们的一些规则。但有时当我们进行大量运行时,Drools会调用导致失败的JIT编译器。我们的Junit测试中包含了这个内容,我们收到以下错误

We are working with Drools version 6.2.0.Final for parsing some of our rules. But sometimes when we have a lot of runs, Drools invokes the JIT compiler which is causing failures. We have this covered in our Junit tests and we are getting the following error

java.lang.NoSuchMethodError: org.mvel2.compiler.BlankLiteral.<init>(Ljava/lang/String;)V
at ConditionEvaluatoref4dc802b6174038b0307f5e6196e229.evaluate(Unknown Source)
at org.drools.core.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:248)
at org.drools.core.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:204)
at org.drools.core.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at org.drools.core.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:494)
at org.drools.core.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:384)
at org.drools.core.reteoo.ObjectTypeNode.propagateAssert(ObjectTypeNode.java:298)
at org.drools.core.phreak.PropagationEntry$Insert.execute(PropagationEntry.java:93)
at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:96)
at org.drools.core.phreak.SynchronizedPropagationList.flush(SynchronizedPropagationList.java:69)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.flushPropagations(StatefulKnowledgeSessionImpl.java:1993)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1289)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1294)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1281)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1260)
at org.drools.core.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:306)

我们在Java 7中也遇到了这个错误,但是通过使用选项来逃避这个错误

We got this error in Java 7 as well but escaped this by using the option

KieBaseConfiguration kbConfig = KieServices.Factory.get().newKieBaseConfiguration();
kbConfig.setOption(PermGenThresholdOption.get(0));

设置此选项已禁用JIT,我们的代码运行正常。但是由于Java 8完全删除了PermGen选项,我无法找到实现相同功能的选项。这导致规则在执行大量运行时失败。

Setting this option disabled JIT and our code was working fine. But since Java 8 has removed the PermGen option altogether, I am not able to figure out an option to achieve the same thing. This is causing the rules to fail when a lot of runs are executed.

我已经尝试了很多选项来禁用它但无法使其工作。

I have tried a lot options to disable it but could not make it work.

- OptimizerFactory.setDefaultOptimizer(OptimizerFactory.SAFE_REFLECTIVE);
- System.setProperty("-Ddrools.dialect.java.compiler", "JANINO");
- System.setProperty("-Djava.compiler", "NONE");
- System.setProperty("-Dmvel2.disable.jit", "true");
- kbConfig.setOption(RuleEngineOption.PHREAK);

一些帮助将非常有帮助。

Some help will be really helpful.

推荐答案

经过大量的调试后,我们发现我们的一条规则导致了问题。但规则是有效的,我们不能丢弃它。

Well after doing a lot of debugging we found that one of our rule was causing the problem. But the rule was valid and we could not discard it.

最后我找到了一种方法来禁用JIT编译器来解决我们的问题并且错误消失了。这与Esteban Aliverti提到的解决方案不同。下面提到的那个适用于我们的案例,适用于大多数情况。

Finally I found a way to disable the JIT compiler which solved our problem and the error was gone. This is a different solution from what was mentioned by Esteban Aliverti. The one mentioned below worked for our case and would work for most of the cases.

我使用以下方法来禁用JIT编译器:

I used the following way to disable the JIT compiler:

KieBaseConfiguration kbConfig = KieServices.Factory.get().newKieBaseConfiguration();
kbConfig.setOption(ConstraintJittingThresholdOption.get(-1));

实际说明如下:

0 -> force immediate synchronous jitting (it's adviced to use this only for testing purposes).
-1 (or any other negative number) -> disable jitting
Default value is 20.

因此,一旦我们将ConstraintJittingThresholdOption设置为-1,它会禁用JIT编译器。

So once we set the ConstraintJittingThresholdOption as -1, it disables the JIT compiler.

这篇关于使用Java 8在Drools 6.2中禁用JIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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