[jboss-jira] [JBoss JIRA] (DROOLS-1028) Drools 6.3.0.Final - high memory usage
Bill Tuminaro (JIRA)
issues at jboss.org
Mon Jan 18 19:50:00 EST 2016
[ https://issues.jboss.org/browse/DROOLS-1028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150273#comment-13150273 ]
Bill Tuminaro edited comment on DROOLS-1028 at 1/18/16 7:49 PM:
----------------------------------------------------------------
When I went to put together a sample rule file, I discovered a colleague has made some changes to our rule syntax that dramatically reduced our memory requirements. The original rule sample rule file is named SampleRuleFile,drl the one with the new syntax is named NewSampleFile.drl.
Below is one of the rules from the Original rule file, the bold lines are the lines that are now omitted from the new rule syntax.
rule "1199"
when
$SPEntity : SPEntity ( anchorId == 2002 , $SPEntity_NewSSP: getAttributeInteger("NewSSP"), $SPEntity_entityId: entityId, $SPEntity_timestamp : timestamp >= 1452890353970 )
if ($SPEntity.containsTriggeredRule("1199") ) break[doNothing]
else if (RulesManagerHelper.isFirstProbe(2002, $SPEntity_timestamp)) break[suppressFirstProbe]
not LastEntity( curr#SPEntity.getAttributeInteger("NewSSP") == $SPEntity_NewSSP )
*$SSEntity : SSEntity ($SSEntity_entityId : entityId == 2002)*
*not SSEntity($SSEntity_entityId == entityId, this after $SSEntity)*
then
RuleLogger.traceInfo(1199, drools.getRule().getName(), "==== " + drools.getRule().getName() + " was fired =====");
{
List<Entity> cel = null;
*List<Entity> tel = null;*
List<PMEntity> pel = null;
cel = new ArrayList<Entity>();
*if(tel == null)*
*tel = new ArrayList<Entity>();*
*tel.add($SSEntity);*
cel.add($SPEntity);
RuleEngineUtils.printEntity($SPEntity);
if($SPEntity.containsTriggeredRule("1199")) {
RuleLogger.traceInfo(1199, drools.getRule().getName(), "Suppressed duplicate. Exit.");
RuleEngineUtils.printEntity($SPEntity);
return;
}
RuleEngineUtils.triggerAlert(1199, cel, null, *tel,* pel, RuleEngineUtils.Severity.MSGID);
}
$SPEntity.addTriggeredRule("1199");
then[doNothing]
RuleLogger.traceInfo(1199, drools.getRule().getName(), "Suppressed duplicate");
then[suppressFirstProbe]
RuleLogger.traceInfo(1199, drools.getRule().getName(), "Suppress first probe");
end
I hope this format is usable for you. Please let me know what else I can do to help.
-BillT
was (Author: billt408):
When I went to put together a sample rule file, I discovered a colleague has made some changes to our rule syntax that dramatically reduced our memory requirements. The original rule sample rule file is named SampleRuleFile,drl the one with the new syntax is named NewSampleFile.drl.
Below is one of the rules from the Original rule file, the bold lines are the lines that are now omitted from the new rule syntax.
rule "1199"
when
$SPEntity : SPEntity ( anchorId == 2002 , $SPEntity_NewSSP: getAttributeInteger("NewSSP"), $SPEntity_entityId: entityId, $SPEntity_timestamp : timestamp >= 1452890353970 )
if ($SPEntity.containsTriggeredRule("1199") ) break[doNothing]
else if (RulesManagerHelper.isFirstProbe(2002, $SPEntity_timestamp)) break[suppressFirstProbe]
not LastEntity( curr#SPEntity.getAttributeInteger("NewSSP") == $SPEntity_NewSSP )
*$SSEntity : SSEntity ($SSEntity_entityId : entityId == 2002)*
*not SSEntity($SSEntity_entityId == entityId, this after $SSEntity)*
then
RuleLogger.traceInfo(1199, drools.getRule().getName(), "==== " + drools.getRule().getName() + " was fired =====");
{
List<Entity> cel = null;
* List<Entity> tel = null;*
List<PMEntity> pel = null;
cel = new ArrayList<Entity>();
* if(tel == null)
tel = new ArrayList<Entity>();
tel.add($SSEntity);*
cel.add($SPEntity);
RuleEngineUtils.printEntity($SPEntity);
if($SPEntity.containsTriggeredRule("1199")) {
RuleLogger.traceInfo(1199, drools.getRule().getName(), "Suppressed duplicate. Exit.");
RuleEngineUtils.printEntity($SPEntity);
return;
}
RuleEngineUtils.triggerAlert(1199, cel, null, *tel,* pel, RuleEngineUtils.Severity.MSGID);
}
$SPEntity.addTriggeredRule("1199");
then[doNothing]
RuleLogger.traceInfo(1199, drools.getRule().getName(), "Suppressed duplicate");
then[suppressFirstProbe]
RuleLogger.traceInfo(1199, drools.getRule().getName(), "Suppress first probe");
end
I hope this format is usable for you. Please let me know what else I can do to help.
-BillT
> Drools 6.3.0.Final - high memory usage
> --------------------------------------
>
> Key: DROOLS-1028
> URL: https://issues.jboss.org/browse/DROOLS-1028
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 6.1.0.Final, 6.3.0.Final
> Environment: Drools 6.3.0.Final on Windows, AIX and Linux
> Reporter: Bill Tuminaro
> Assignee: Mario Fusco
> Attachments: newSampleFile.drl, SampleRuleFile.drl, screenshot-1.png
>
>
> We have an application that completely wraps the drools run-time. The code creates rules, compiles them and manages the run-time. We are experiencing very high memory utilization in an environment with about 1000 rules. Memory continuously grows as we insert facts, I know this is expected, however the amount of growth seems unusually large. In one scenario, memory consumption jumps 200 MB after inserting about 4800 facts (each fact consumes about 200 bytes) and calling fireallrules. We are currently running with the phreak algorithm. I wrote some code that iterates over the facthandles to count the number of right tuple references once the insertion and fireallrules has completed. It shows over 10 million references. Can someone review the attached code to tell me if the approach is sound? Also, how do I identify the entire set of right tuples in memory, I would like to write some code to produce some data about them to give me some insight into what is causing so many right tuples and right tuple references to be created. If we can narrow this down, I would like to write a reproducer to isolate the large memory usage.
> for (Object obj : kSession.getObjects()) {
> if (obj == null) {
> RuleLogger.traceDebug( className, methodName,"Null object");
> }
> DefaultFactHandle factHandle = (DefaultFactHandle)kSession.getFactHandle(obj);
> if (factHandle != null) {
> RightTuple previous = factHandle.getLastRightTuple();
> int rtCount = 0;
> if (previous != null ) {
> ++rtCount;
> while (true) {
> previous = (RightTuple) previous.getNext();
> if (previous == null)
> break;
> ++rtCount;
> }
> }
> totalRighttuples += rtCount;
> }
> }
> ...
> String msg = "printStats() - WM has " +nm.length() + " nodes in NM array, " + activeNodesInNm + " active nodes, " + totalsmNetworkNodes+ " network nodes, " + totalsmPathMemories + " path memories, " +
> + totalRighttuples + " rightTuple references";
> Sample output:
> printStats() - WM has 14328 nodes in NM array, 4711 active nodes, 26396 network nodes, 4640 path memories, 10754655 rightTuple references
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list