Re: [rules-users] Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object
I would like to take a look on this issue. Can you provide me a test case that show the problem? - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Mauricio "Salaboy" Salatino - On Jul 9, 2010, at 12:43, Vijay K Pandey wrote: > I guess this problem was due to a fix done in WorkItemNodeInstance? Is this > the correct behavior? If yes how do we get hold of “WorkItem” instance in the > attached listeners? > > > > http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java?r1=32801&r2= > > > > Thanks > > Vijay > > From: Vijay K Pandey > Sent: Tuesday, June 15, 2010 9:20 AM > To: 'Rules Users List' > Subject: RE: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get > hold of WorkItem object > > > > Any one on this issue? Any Drools Flow expert? > > > > Appreciate your time for taking a look at it. > > > > Thanks > > Vijay > > From: Vijay K Pandey > Sent: Thursday, June 10, 2010 12:03 PM > To: 'Rules Users List' > Subject: RE: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get > hold of WorkItem object > > > > Should I log this as a JIRA ticket. > > > > Thanks > > Vijay > > From: Vijay K Pandey > Sent: Wednesday, June 09, 2010 9:57 AM > To: 'Rules Users List' > Subject: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold > of WorkItem object > > > > Hi, > > > > There is a change done in Drools 5.1.0.M2 - > org.drools.workflow.instance.node.WorkItemNodeInstance class in the method > > > > public void triggerCompleted(WorkItem workItem) at line 196 which is > setting the workItemId as -1 > > > > this.workItemId = -1; > > > > Due to the above change the listeners which are attached to the “complete” > event of the work item – such as the method below > > > > public void beforeNodeLeft(ProcessNodeLeftEvent event) are not able to get > hold of the associated workitem object as it returns null. > > > > Is there any specific reason that workItemId is set to -1 even before the > associated listeners get triggered or is this a bug? > > > > If it was an intended change then how do I get hold of the “WorkItem” object > in the attached listeners. > > > > Thanks > > Vijay > > p.s This change was not there in the snapshot of 18th April 2010 which I was > earlier working on. Above is the only change in this class from the snapshot > of 18th April and 5.1.0.M2 > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Upgraded Guvnor to 5.1.x from 5.0 and getting expander error with DSL
I just upgraded to the latest milestone and am getting the following error: [package configuration problem][ERR 103] Line 31:0 rule 'rule_key' failed predicate: {(validateIdentifierKey(DroolsSoftKeywords.RULE))}? in rule [package configuration problem][ERR 101] Line 31:9 no viable alternative at input 'TPNOrders' in rule expander [package configuration problem][ERR 101] Line 32:0 no viable alternative at input 'import' in rule expander in rule dsl This exact set of *.brl, *.dsl, drools.package were working up until the upgrade. I've been searching the web but haven't found anything similar. Thanks! ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object
I guess this problem was due to a fix done in WorkItemNodeInstance? Is this the correct behavior? If yes how do we get hold of "WorkItem" instance in the attached listeners? http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java?r1=32801&r2= Thanks Vijay From: Vijay K Pandey Sent: Tuesday, June 15, 2010 9:20 AM To: 'Rules Users List' Subject: RE: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object Any one on this issue? Any Drools Flow expert? Appreciate your time for taking a look at it. Thanks Vijay From: Vijay K Pandey Sent: Thursday, June 10, 2010 12:03 PM To: 'Rules Users List' Subject: RE: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object Should I log this as a JIRA ticket. Thanks Vijay From: Vijay K Pandey Sent: Wednesday, June 09, 2010 9:57 AM To: 'Rules Users List' Subject: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object Hi, There is a change done in Drools 5.1.0.M2 - org.drools.workflow.instance.node.WorkItemNodeInstance class in the method public void triggerCompleted(WorkItem workItem) at line 196 which is setting the workItemId as -1 this.workItemId = -1; Due to the above change the listeners which are attached to the "complete" event of the work item - such as the method below public void beforeNodeLeft(ProcessNodeLeftEvent event) are not able to get hold of the associated workitem object as it returns null. Is there any specific reason that workItemId is set to -1 even before the associated listeners get triggered or is this a bug? If it was an intended change then how do I get hold of the "WorkItem" object in the attached listeners. Thanks Vijay p.s This change was not there in the snapshot of 18th April 2010 which I was earlier working on. Above is the only change in this class from the snapshot of 18th April and 5.1.0.M2 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] WorkItemNodeInstance and the on exit action
About the out-mapping attribute, you are right this will copy the values from the variables inside the workitem to the process level. Greetings - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Mauricio "Salaboy" Salatino - On Jul 9, 2010, at 11:22, Chris Raschl wrote: > Hi Kris, > we experienced some troubles with our drools flow integration today > (we upgraded to the lastest snapshot) and I found out that is has to > do with a fix (see [1]) you commited some time ago. > > Our problem is, that we access the data submitted by the user to > finish a human task in the on exit action of the human task node > like this: > > WorkItemNodeInstance wini = (WorkItemNodeInstance)context.getNodeInstance(); > Map result = (Map Object>)wini.getWorkItem().getResult("Result"); > > This results in a NPE because the workItemId is set to -1 in the > WorkItemNodeInstance > before getWorkItem() is called. So getWorkItem() returns null. > > Is there a better (recommended) way to work with human task data? Maybe using > an > out-mapping? > > Thanks, > chris > > [1] > http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java?r1=32801&r2= > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] WorkItemNodeInstance and the on exit action
Hi man, Did you recognize this error after update? Why are you doing that if you have the human tasks Apis to complete a task that automatically set the result values. I would like to take a look at your issue, can you provide me more info about it? Greetings - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Mauricio "Salaboy" Salatino - On Jul 9, 2010, at 11:22, Chris Raschl wrote: > Hi Kris, > we experienced some troubles with our drools flow integration today > (we upgraded to the lastest snapshot) and I found out that is has to > do with a fix (see [1]) you commited some time ago. > > Our problem is, that we access the data submitted by the user to > finish a human task in the on exit action of the human task node > like this: > > WorkItemNodeInstance wini = (WorkItemNodeInstance)context.getNodeInstance(); > Map result = (Map Object>)wini.getWorkItem().getResult("Result"); > > This results in a NPE because the workItemId is set to -1 in the > WorkItemNodeInstance > before getWorkItem() is called. So getWorkItem() returns null. > > Is there a better (recommended) way to work with human task data? Maybe using > an > out-mapping? > > Thanks, > chris > > [1] > http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java?r1=32801&r2= > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] WorkItemNodeInstance and the on exit action
Hi Kris, we experienced some troubles with our drools flow integration today (we upgraded to the lastest snapshot) and I found out that is has to do with a fix (see [1]) you commited some time ago. Our problem is, that we access the data submitted by the user to finish a human task in the on exit action of the human task node like this: WorkItemNodeInstance wini = (WorkItemNodeInstance)context.getNodeInstance(); Map result = (Map)wini.getWorkItem().getResult("Result"); This results in a NPE because the workItemId is set to -1 in the WorkItemNodeInstance before getWorkItem() is called. So getWorkItem() returns null. Is there a better (recommended) way to work with human task data? Maybe using an out-mapping? Thanks, chris [1] http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/java/org/drools/workflow/instance/node/WorkItemNodeInstance.java?r1=32801&r2= ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Implementing Timers With Drools Persistence Enabled
I am a newbie in Drools Flow. I tried your test case and it works after some modification. >From my understanding, ksession.getWorkItemManager().completeWorkItem(1, null); is incorrect. Persistent WorkItem Id depends on database primary key. In my test case, i store workItem as instance variable and use its id to invoke completeWorkItem(workItem.getId(), null) -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-Timers-With-Drools-Persistence-Enabled-tp923142p954383.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Flow
But for this you don't need drools flow. Normal rule-set is enough. Pavel 2010/7/9 santosh mukherjee : > Sorry, > but in the documentation, it was written that an internal event can be > raised over the actions of an Action Node. > Anyways, Then when and where to raise the event. Actually I want my process > to be in such a way, that whenever a certain event comes , it executes a set > of actions. > Thanks. > > 2010/7/9 Mauricio Salatino >> >> what are you trying to achieve exactly? An event will not work over an >> action node. >> Greetings. >> >> 2010/7/8 santosh mukherjee >>> >>> Hi, >>> I am a newbie to Drools flow. I am trying to generate a sample string >>> event in the action node using the snippet --> >>> context.getProcessInstance().signalEvent("java.lang.String", "hiii"); >>> But they event is not getting generated. >>> Any suggestions are welcome. >>> Thank You. >>> Santosh Mukherjee >>> ___ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >> >> >> >> -- >> - CTO @ http://www.plugtree.com >> - MyJourney @ http://salaboy.wordpress.com >> - Co-Founder @ http://www.jbug.com.ar >> >> - Salatino "Salaboy" Mauricio - >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Improving Drools Memory Performance
On 9 July 2010 14:14, Mark Proctor wrote: > You have many objects there that are not constrained; I have an inkling that the functions.*() are hiding just these contraints, It's certainly the wrong way, starting with oodles of node pairs, just to pick out connected ones by fishing for the connecting edge. And this is worsened by trying to find two such pairs which meet at some DomainSource Guesswork, hopefully educated ;-) -W > if there are > multiple versions of those objects you are going to get massive amounts > of cross products. Think in terms of SQL, each pattern you add is like > an SQL join. > > Mark > On 09/07/2010 09:20, Jevon Wright wrote: >> Hi everyone, >> >> I am working on what appears to be a fairly complex rule base based on >> EMF. The rules aren't operating over a huge number of facts (less than >> 10,000 EObjects) and there aren't too many rules (less than 300), but >> I am having a problem with running out of Java heap space (set at ~400 >> MB). >> >> Through investigation, I came to the conclusion that this is due to >> the design of the rules, rather than the number of facts. The engine >> uses less memory inserting many facts that use simple rules, compared >> with inserting few facts that use many rules. >> >> Can anybody suggest some tips for reducing heap memory usage in >> Drools? I don't have a time constraint, only a heap/memory constraint. >> A sample rule in my project looks like this: >> >> rule "Create QueryParameter for target container of DetailWire" >> when >> container : Frame( ) >> schema : DomainSchema ( ) >> domainSource : DomainSource ( ) >> instance : DomainIterator( ) >> selectEdge : SelectEdge ( eval ( >> functions.connectsSelect(selectEdge, instance, domainSource )) ) >> schemaEdge : SchemaEdge ( eval ( >> functions.connectsSchema(schemaEdge, domainSource, schema )) ) >> source : VisibleThing ( eContainer == container ) >> target : Frame ( ) >> instanceSet : SetWire ( eval(functions.connectsSet(instanceSet, >> instance, source )) ) >> detail : DetailWire ( ) >> eval ( functions.connectsDetail(detail, source, target )) >> pk : DomainAttribute ( eContainer == schema, primaryKey == true ) >> not ( queryPk : QueryParameter ( eContainer == target, name == >> pk.name ) ) >> eval ( handler.veto( detail )) >> >> then >> QueryParameter qp = handler.generatedQueryParameter(detail, target); >> handler.setName(qp, pk.getName()); >> queue.add(qp, drools); // wraps insert(...) >> >> end >> >> I try to order the select statements in an order that will reduce the >> size of the cross-product (in theory), but I also try and keep the >> rules fairly human readable. I try to avoid comparison operators like >> < and>. Analysing a heap dump shows that most of the memory is being >> used in StatefulSession.nodeMemories> PrimitiveLongMap. >> >> I am using a StatefulSession; if I understand correctly, I can't use a >> StatelessSession with sequential mode since I am inserting facts as >> part of the rules. If I also understand correctly, I'd like the Rete >> graph to be tall, rather than wide. >> >> Some ideas I have thought of include the following: >> 1. Creating a separate intermediary meta-model to split up the sizes >> of the rules. e.g. instead of (if A and B and C then insert D), using >> (if A and B then insert E; if E and C then insert D). >> 2. Moving eval() statements directly into the Type(...) selectors. >> 3. Removing eval() statements. Would this allow for better indexing by >> the Rete algorithm? >> 4. Reducing the height, or the width, of the class hierarchy of the >> facts. e.g. Removing interfaces or abstract classes to reduce the >> possible matches. Would this make a difference? >> 5. Conversely, increasing the height, or the width, of the class >> hierarchy. e.g. Adding interfaces or abstract classes to reduce field >> accessors. >> 6. Instead of using EObject.eContainer, creating an explicit >> containment property in all of my EObjects. >> 7. Creating a DSL that is human-readable, but allows for the >> automation of some of these approaches. >> 8. Moving all rules into one rule file, or splitting up rules into >> smaller files. >> >> Is there kind of profiler for Drools that will let me see the size (or >> the memory usage) of particular rules, or of the memory used after >> inference? Ideally I'd use this to profile any changes. >> >> Thanks for any thoughts or tips! :-) >> >> Jevon >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org h
Re: [rules-users] Improving Drools Memory Performance
You have many objects there that are not constrained; if there are multiple versions of those objects you are going to get massive amounts of cross products. Think in terms of SQL, each pattern you add is like an SQL join. Mark On 09/07/2010 09:20, Jevon Wright wrote: > Hi everyone, > > I am working on what appears to be a fairly complex rule base based on > EMF. The rules aren't operating over a huge number of facts (less than > 10,000 EObjects) and there aren't too many rules (less than 300), but > I am having a problem with running out of Java heap space (set at ~400 > MB). > > Through investigation, I came to the conclusion that this is due to > the design of the rules, rather than the number of facts. The engine > uses less memory inserting many facts that use simple rules, compared > with inserting few facts that use many rules. > > Can anybody suggest some tips for reducing heap memory usage in > Drools? I don't have a time constraint, only a heap/memory constraint. > A sample rule in my project looks like this: > >rule "Create QueryParameter for target container of DetailWire" > when >container : Frame( ) >schema : DomainSchema ( ) >domainSource : DomainSource ( ) >instance : DomainIterator( ) >selectEdge : SelectEdge ( eval ( > functions.connectsSelect(selectEdge, instance, domainSource )) ) >schemaEdge : SchemaEdge ( eval ( > functions.connectsSchema(schemaEdge, domainSource, schema )) ) >source : VisibleThing ( eContainer == container ) >target : Frame ( ) >instanceSet : SetWire ( eval(functions.connectsSet(instanceSet, > instance, source )) ) >detail : DetailWire ( ) >eval ( functions.connectsDetail(detail, source, target )) >pk : DomainAttribute ( eContainer == schema, primaryKey == true ) >not ( queryPk : QueryParameter ( eContainer == target, name == pk.name > ) ) >eval ( handler.veto( detail )) > > then >QueryParameter qp = handler.generatedQueryParameter(detail, target); >handler.setName(qp, pk.getName()); >queue.add(qp, drools); // wraps insert(...) > >end > > I try to order the select statements in an order that will reduce the > size of the cross-product (in theory), but I also try and keep the > rules fairly human readable. I try to avoid comparison operators like > < and>. Analysing a heap dump shows that most of the memory is being > used in StatefulSession.nodeMemories> PrimitiveLongMap. > > I am using a StatefulSession; if I understand correctly, I can't use a > StatelessSession with sequential mode since I am inserting facts as > part of the rules. If I also understand correctly, I'd like the Rete > graph to be tall, rather than wide. > > Some ideas I have thought of include the following: > 1. Creating a separate intermediary meta-model to split up the sizes > of the rules. e.g. instead of (if A and B and C then insert D), using > (if A and B then insert E; if E and C then insert D). > 2. Moving eval() statements directly into the Type(...) selectors. > 3. Removing eval() statements. Would this allow for better indexing by > the Rete algorithm? > 4. Reducing the height, or the width, of the class hierarchy of the > facts. e.g. Removing interfaces or abstract classes to reduce the > possible matches. Would this make a difference? > 5. Conversely, increasing the height, or the width, of the class > hierarchy. e.g. Adding interfaces or abstract classes to reduce field > accessors. > 6. Instead of using EObject.eContainer, creating an explicit > containment property in all of my EObjects. > 7. Creating a DSL that is human-readable, but allows for the > automation of some of these approaches. > 8. Moving all rules into one rule file, or splitting up rules into > smaller files. > > Is there kind of profiler for Drools that will let me see the size (or > the memory usage) of particular rules, or of the memory used after > inference? Ideally I'd use this to profile any changes. > > Thanks for any thoughts or tips! :-) > > Jevon > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Flow
Sorry, but in the documentation, it was written that an internal event can be raised over the actions of an Action Node. Anyways, Then when and where to raise the event. Actually I want my process to be in such a way, that whenever a certain event comes , it executes a set of actions. Thanks. 2010/7/9 Mauricio Salatino > what are you trying to achieve exactly? An event will not work over an > action node. > Greetings. > > 2010/7/8 santosh mukherjee > >> Hi, >> >> I am a newbie to Drools flow. I am trying to generate a sample string >> event in the action node using the snippet --> >> context.getProcessInstance().signalEvent("java.lang.String", "hiii"); >> >> But they event is not getting generated. >> >> Any suggestions are welcome. >> >> Thank You. >> Santosh Mukherjee >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > > -- > - CTO @ http://www.plugtree.com > - MyJourney @ http://salaboy.wordpress.com > - Co-Founder @ http://www.jbug.com.ar > > - Salatino "Salaboy" Mauricio - > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Improving Drools Memory Performance
Your sample rule is indeed causing maximum memory usage for the Rete. With your "ideas" you are definitly on the right track. Not knowing what is hidden in functions.*() or handelr.*() one can't rewrite this rule. Just some observations: (a) eval ( handler.veto( detail )) - This condition can be checked three lines up, in detail: DetailWire(). (b) container : Frame( ) - This is useless, since you get eContainer as an attribute from VisibleThing (At most, it ensures that this isn't null.) (c) I'm inclined to believe that all the functions.*() can be written as conditions on attributes, doing away with all the evals. HTH -W On 9 July 2010 10:20, Jevon Wright wrote: > Hi everyone, > > I am working on what appears to be a fairly complex rule base based on > EMF. The rules aren't operating over a huge number of facts (less than > 10,000 EObjects) and there aren't too many rules (less than 300), but > I am having a problem with running out of Java heap space (set at ~400 > MB). > > Through investigation, I came to the conclusion that this is due to > the design of the rules, rather than the number of facts. The engine > uses less memory inserting many facts that use simple rules, compared > with inserting few facts that use many rules. > > Can anybody suggest some tips for reducing heap memory usage in > Drools? I don't have a time constraint, only a heap/memory constraint. > A sample rule in my project looks like this: > > rule "Create QueryParameter for target container of DetailWire" > when > container : Frame( ) > schema : DomainSchema ( ) > domainSource : DomainSource ( ) > instance : DomainIterator( ) > selectEdge : SelectEdge ( eval ( > functions.connectsSelect(selectEdge, instance, domainSource )) ) > schemaEdge : SchemaEdge ( eval ( > functions.connectsSchema(schemaEdge, domainSource, schema )) ) > source : VisibleThing ( eContainer == container ) > target : Frame ( ) > instanceSet : SetWire ( eval(functions.connectsSet(instanceSet, > instance, source )) ) > detail : DetailWire ( ) > eval ( functions.connectsDetail(detail, source, target )) > pk : DomainAttribute ( eContainer == schema, primaryKey == true ) > not ( queryPk : QueryParameter ( eContainer == target, name == pk.name ) > ) > eval ( handler.veto( detail )) > > then > QueryParameter qp = handler.generatedQueryParameter(detail, target); > handler.setName(qp, pk.getName()); > queue.add(qp, drools); // wraps insert(...) > > end > > I try to order the select statements in an order that will reduce the > size of the cross-product (in theory), but I also try and keep the > rules fairly human readable. I try to avoid comparison operators like > < and >. Analysing a heap dump shows that most of the memory is being > used in StatefulSession.nodeMemories > PrimitiveLongMap. > > I am using a StatefulSession; if I understand correctly, I can't use a > StatelessSession with sequential mode since I am inserting facts as > part of the rules. If I also understand correctly, I'd like the Rete > graph to be tall, rather than wide. > > Some ideas I have thought of include the following: > 1. Creating a separate intermediary meta-model to split up the sizes > of the rules. e.g. instead of (if A and B and C then insert D), using > (if A and B then insert E; if E and C then insert D). > 2. Moving eval() statements directly into the Type(...) selectors. > 3. Removing eval() statements. Would this allow for better indexing by > the Rete algorithm? > 4. Reducing the height, or the width, of the class hierarchy of the > facts. e.g. Removing interfaces or abstract classes to reduce the > possible matches. Would this make a difference? > 5. Conversely, increasing the height, or the width, of the class > hierarchy. e.g. Adding interfaces or abstract classes to reduce field > accessors. > 6. Instead of using EObject.eContainer, creating an explicit > containment property in all of my EObjects. > 7. Creating a DSL that is human-readable, but allows for the > automation of some of these approaches. > 8. Moving all rules into one rule file, or splitting up rules into > smaller files. > > Is there kind of profiler for Drools that will let me see the size (or > the memory usage) of particular rules, or of the memory used after > inference? Ideally I'd use this to profile any changes. > > Thanks for any thoughts or tips! :-) > > Jevon > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Improving Drools Memory Performance
Hi everyone, I am working on what appears to be a fairly complex rule base based on EMF. The rules aren't operating over a huge number of facts (less than 10,000 EObjects) and there aren't too many rules (less than 300), but I am having a problem with running out of Java heap space (set at ~400 MB). Through investigation, I came to the conclusion that this is due to the design of the rules, rather than the number of facts. The engine uses less memory inserting many facts that use simple rules, compared with inserting few facts that use many rules. Can anybody suggest some tips for reducing heap memory usage in Drools? I don't have a time constraint, only a heap/memory constraint. A sample rule in my project looks like this: rule "Create QueryParameter for target container of DetailWire" when container : Frame( ) schema : DomainSchema ( ) domainSource : DomainSource ( ) instance : DomainIterator( ) selectEdge : SelectEdge ( eval ( functions.connectsSelect(selectEdge, instance, domainSource )) ) schemaEdge : SchemaEdge ( eval ( functions.connectsSchema(schemaEdge, domainSource, schema )) ) source : VisibleThing ( eContainer == container ) target : Frame ( ) instanceSet : SetWire ( eval(functions.connectsSet(instanceSet, instance, source )) ) detail : DetailWire ( ) eval ( functions.connectsDetail(detail, source, target )) pk : DomainAttribute ( eContainer == schema, primaryKey == true ) not ( queryPk : QueryParameter ( eContainer == target, name == pk.name ) ) eval ( handler.veto( detail )) then QueryParameter qp = handler.generatedQueryParameter(detail, target); handler.setName(qp, pk.getName()); queue.add(qp, drools); // wraps insert(...) end I try to order the select statements in an order that will reduce the size of the cross-product (in theory), but I also try and keep the rules fairly human readable. I try to avoid comparison operators like < and >. Analysing a heap dump shows that most of the memory is being used in StatefulSession.nodeMemories > PrimitiveLongMap. I am using a StatefulSession; if I understand correctly, I can't use a StatelessSession with sequential mode since I am inserting facts as part of the rules. If I also understand correctly, I'd like the Rete graph to be tall, rather than wide. Some ideas I have thought of include the following: 1. Creating a separate intermediary meta-model to split up the sizes of the rules. e.g. instead of (if A and B and C then insert D), using (if A and B then insert E; if E and C then insert D). 2. Moving eval() statements directly into the Type(...) selectors. 3. Removing eval() statements. Would this allow for better indexing by the Rete algorithm? 4. Reducing the height, or the width, of the class hierarchy of the facts. e.g. Removing interfaces or abstract classes to reduce the possible matches. Would this make a difference? 5. Conversely, increasing the height, or the width, of the class hierarchy. e.g. Adding interfaces or abstract classes to reduce field accessors. 6. Instead of using EObject.eContainer, creating an explicit containment property in all of my EObjects. 7. Creating a DSL that is human-readable, but allows for the automation of some of these approaches. 8. Moving all rules into one rule file, or splitting up rules into smaller files. Is there kind of profiler for Drools that will let me see the size (or the memory usage) of particular rules, or of the memory used after inference? Ideally I'd use this to profile any changes. Thanks for any thoughts or tips! :-) Jevon ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users