Folks -
After seeing the thread
on evals hurting performance a couple of weeks ago, I tried to remove them from a rule
set we are using (running Drools 4.0.4), and have had
limited success.
An example is shown below. We're using evals
every time we make a call to "rulesUtil", a helper class we have for checking
strings for keywords. Two questions:
1. Does using inline evals (like below) hurt
performance as much as using non-inline evals?
2. If so, any thoughts for how to rewrite this
rule to avoid using the eval?
rule
'my rule'
salience 790
activation-group "priorityRule"
when
ruleUtil : RulesUtil( )
s1 : Sensor( source == "X, $rfp : RFP , eval(
ruleUtil.containsKeywordString($rfp, "Y" )) , $tcn : TCN)
s2 : Sensor( TCN != $tcn, source ==
"Z"
then
System.out.println("my rule");
priority.setPriorityName("A");
end
Thanks,
David Warren
Start by eliminating the evals and writing your
constraints properly inside the patterns. Drools 3+ is orders of magnitude
faster than Drools 2.x, but you need to leverage its power in your rules. Please
read the manual as the version 3 was a completely rewrite of version 2. Version
4 is an improvement over 3.
As an example, look at this:
http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html
[]s
Edson
2008/9/5 Rout, Sushanta (ThoughtMill)
<Sushanta.Rout@ihg.com>
We
were using Drools 2.5 version earlier. Now we have switched to drools
4.0.7. But we see significant issues
with performance like drools 4.0.7
is three times slower than 2.5 . Has
anybody encountered the issue?
Here is a sample of the rule, we have
some more similar to this.
rule "test"
dialect "java"
activation-group
"group1"
when
$croNumberDetailsRequest :
CRONumberDetailsRequest()
$resdirectPhoneNumber : ResdirectPhoneNumber()
eval($resdirectPhoneNumber.getType().getId()
== 5
&&
$resdirectPhoneNumber.isValidForBrand($croNumberDetailsRequest.getBrand(
))
&&
$croNumberDetailsRequest.getRegion() != null
&&
$resdirectPhoneNumber.isValidRegion($croNumberDetailsRequest.getRegion()
)
&&
$croNumberDetailsRequest.getLocale() != null
&&
$resdirectPhoneNumber.isValidForLocaleId($croNumberDetailsRequest.getLoc
ale())
&&
$resdirectPhoneNumber.isValidSlot($croNumberDetailsRequest.getSlot()));
then
ResultList.add($resdirectPhoneNumber);
end
_______________________________________________
rules-users
mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a
division of Red Hat @
www.jboss.com
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users