[rules-users] 答复: 答复: Performance consideration in rule writing

Zhuo Li milanello1998 at gmail.com
Mon Dec 26 10:08:41 EST 2011


Hi, Wolfgang,

 

Thanks for the message. I think I’m clear about the listener piece now!

 

Best

Abe

 

发件人: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] 代表 Wolfgang Laun
发送时间: 2011年12月26日 23:01
收件人: Rules Users List
主题: Re: [rules-users] 答复: Performance consideration in rule writing

 

This ought to be another thread/another subject.

2011/12/26 Zhuo Li <milanello1998 at gmail.com>

Any question is also about performance consideration. See below example:

 

Rule “1”

         Dialect “mvel”

         Salience 300

         No-loop true

         When

                   $acctsrc: data(sourceid==1)

                   $reposrc:
data((sourceid==2||sourceid==5)&&amount==acctsrc.amount)

         Then

                   …

         End

 

Two questions here:

1.       In this kind of join conditions, is there any best practice to
follow in the rule? I heard from somebody that I need to put data who have
less # of transactions first in my when expression. For example, if I have
less number of $reposrc transactions in facts, I should put it ahead of
$acctsrc to gain better performance. Is this valid?

Correct: narrowing down the number of joins is best practice.
 

2.       Do we know how to create an event listener in the rule for logging
purpose rather than standard log4j? It was recommended in some other
articles as well. Is this also valid?
(http://www.technologyblue.com/docs/presentations/DroolsBestPractices.pdf);

An event listener as provided by Drools for rule and WM events is not to be
confused with a logging service, so your question doesn't make much sense.
The big difference is that a listener gets informed about all it is set up
to listen to, whereas calls to Looger.info() need to be written wherever
logging should be done. This could be in listener code reacting to an event,
or anyplace else, as in the RHS of some rules in the quoted presentation.

 

Ultimately, is there any place I can find a best practice of rule
development as a generic guide?


Not a single place that I know of. Perhaps if you post this as a separate
thread with a fitting topic.
 
-W

 

Best

Abe

 

发件人: Zhuo Li [mailto:milanello1998 at gmail.com] 
发送时间: 2011年12月26日 16:51
收件人: 'Rules Users List'
主题: Performance consideration in rule writing

 

Hi, team,

 

I have some quick questions here regarding performance best practices of
rule writing. See below two pieces of rules:

 

Rule “1”

         Salience 100

         No-loop true

         When $txn : data(sourceid == 5&&txnjustify==”995”
&&eval(creditOption($txn)==1)&&eval(isGCSwitch($txn))&&isCurrencyEquals($txn
)==0&&compareToPostThreshold($txn)==2);

         Then

                   …

         End

 

Rule “2”

         Salience 100

         No-loop true

         When $txn : data(sourceid == 5&&txnjustify==”995”
&&eval(creditOption($txn)==1)&&eval(isGCSwitch($txn))&&isCurrencyEquals($txn
)==0&&compareToPostThreshold($txn)==1);

         Then

                  …

         End

 

Questions:

1.       Will I gain better performance if I put the rule differentiator
condition “compareToPostThreshold($txn)==2” at the beginning of both rule
1 and 2? 

2.       I saw salaboy’s video claiming that to avoid using eval() in the
rule. Do we have any alternative way to do that from a performance
consideration or I’d better collect/ prepare all the data before I send
them into the session?

3.       What’s you guys’ naming convention for rule’s salience?

 

PS: my Drools version is 5.2.0.

 

Best regards

Abe


_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111226/bd829884/attachment.html 


More information about the rules-users mailing list