<div dir="ltr"><br>&nbsp;&nbsp; David,<br><br>&nbsp;&nbsp; Eval is really bad for perf, but still, sometimes it is the only way to do things like call methods. So, in your case, it all depends on what &quot;containsKeywordString()&quot; method is doing?<br>
&nbsp;<br>&nbsp;&nbsp; Also, is RulesUtil just a utility class? I mean with no data you reason over? if so, I strongly advise you to make it a global, instead of matching it in the rule like a fact.<br><br>&nbsp;&nbsp; Regarding evals, inline evals are just a bit lighter than top level evals, but there is an important difference:<br>
<br>* inline evals MUST be time consistent, i.e., they must evaluate to the same value everytime they are called.<br>* top level evals can deal with changes appropriately <br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">
2008/9/15 Warren, David [USA] <span dir="ltr">&lt;<a href="mailto:warren_david@bah.com">warren_david@bah.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial">Folks - 
</font></div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"></font>&nbsp;</div>
<div dir="ltr" align="left"><font face="Arial"><font color="#0000ff"><font size="2">After&nbsp;<span>seeing the&nbsp;</span>thread 
on&nbsp;<span>e</span>vals&nbsp;<span>hurting performance </span>a couple of weeks ago<span>, I tried to remove them&nbsp;from a rule 
set&nbsp;we&nbsp;are using (running Drools 4.0.4), and&nbsp;have&nbsp;had 
limited success.</span></font></font></font><font color="#0000ff" size="2" face="Arial"></font></div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span>An example is shown below.&nbsp; We&#39;re using evals 
every time we make a call to &quot;rulesUtil&quot;, a helper class we have for checking 
strings for keywords.&nbsp; Two questions:</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span></span></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span>1.&nbsp;Does using inline evals (like below) hurt 
performance as much as using non-inline evals?</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span>2.&nbsp;If so, any thoughts for how to rewrite this 
rule to avoid using the eval?</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"></font>&nbsp;</div><font color="#0000ff" size="2"><font color="#960000" size="1">
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial">rule</font></div></font><font face="Arial"> &#39;my rule&#39;</font></font></div>
<div dir="ltr" align="left"><b><font color="#960000"><font face="Arial">salience</font></font></b><font face="Arial"> 790</font></div>
<div dir="ltr" align="left"><b><font color="#960000"><font face="Arial">activation-group</font></font></b><font face="Arial"> <font color="#008000">&quot;priorityRule&quot;</font></font></div>
<div dir="ltr" align="left"><b><font color="#960000"><font face="Arial">when</font></font></b></div>
<div dir="ltr" align="left"><font face="Arial">ruleUtil : RulesUtil( )</font></div>
<div dir="ltr" align="left"><font face="Arial">s1 : Sensor( source == <font color="#008000">&quot;X</font>, $rfp : RFP , <b><font color="#960000">eval</font></b></font><font face="Arial">( 
ruleUtil.containsKeywordString($rfp, <font color="#008000">&quot;Y&quot;</font> )<span>)</span> , $tcn : TCN)</font></div>
<div dir="ltr" align="left"><font face="Arial">s2 : Sensor( TCN != $tcn, source == 
<font color="#008000">&quot;Z&quot;</font></font></div>
<div dir="ltr" align="left"><b><font color="#960000"><font face="Arial">then</font></font></b></div>
<div dir="ltr" align="left"><font face="Arial">System.out.println(<font color="#008000">&quot;my rule&quot;);</font></font></div>
<div dir="ltr" align="left"><font face="Arial">priority.setPriorityName(<span>&quot;A&quot;</span></font><font face="Arial">);</font></div>
<div dir="ltr" align="left"><font face="Arial"></font>&nbsp;</div><font face="Arial">
<div dir="ltr" align="left">end</div></font>
<div dir="ltr" align="left"><font face="Arial"><font size="2"><font color="#0000ff"><font color="#0000ff" size="2" face="Arial"></font></font></font></font>&nbsp;</div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span>Thanks,</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" size="2" face="Arial"><span>David Warren</span></font></div><font color="#0000ff" size="2" face="Arial"></font><font color="#0000ff" size="2" face="Arial"></font><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font size="2" face="Tahoma"><b>From:</b> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> 
[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>] <b>On Behalf Of </b>Edson 
Tirelli<br><b>Sent:</b> Friday, September 05, 2008 2:59 PM<br><b>To:</b> Rules 
Users List<br><b>Subject:</b> Re: [rules-users] Drools, Performance issues on 
4.0.7 Vs 2.5<br></font><br></div>
<div></div>
<div dir="ltr"><br>&nbsp;&nbsp; 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.<br><br>&nbsp;&nbsp; As an example, look at this: <a href="http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html" target="_blank">http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html</a><br>
<br>&nbsp;&nbsp; 
[]s<br>&nbsp;&nbsp; Edson<br><br>
<div class="gmail_quote">2008/9/5 Rout, Sushanta (ThoughtMill) <span dir="ltr">&lt;<a href="mailto:Sushanta.Rout@ihg.com" target="_blank">Sushanta.Rout@ihg.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">We 
  were using Drools 2.5 version earlier. Now we have switched to drools<br><a href="http://4.0.7." target="_blank">4.0.7.</a> But we see significant issues 
  with performance like drools 4.0.7<br>is three times slower than 2.5 . Has 
  anybody encountered the issue?<br><br>Here is a sample of the rule, we have 
  some more similar to this.<br>rule &quot;test&quot;<br>&nbsp; &nbsp; &nbsp; 
  &nbsp;dialect &quot;java&quot;<br>&nbsp; &nbsp; &nbsp; &nbsp;activation-group 
  &quot;group1&quot;<br>&nbsp; &nbsp; &nbsp; &nbsp;when<br>&nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp;$croNumberDetailsRequest : 
  CRONumberDetailsRequest()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp;$resdirectPhoneNumber : ResdirectPhoneNumber()<br>&nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;eval($resdirectPhoneNumber.getType().getId() 
  == 5 
  &amp;&amp;<br><br>$resdirectPhoneNumber.isValidForBrand($croNumberDetailsRequest.getBrand(<br>)) 
  &amp;&amp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; $croNumberDetailsRequest.getRegion() != null 
  &amp;&amp;<br><br>$resdirectPhoneNumber.isValidRegion($croNumberDetailsRequest.getRegion()<br>) 
  &amp;&amp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; $croNumberDetailsRequest.getLocale() != null 
  &amp;&amp;<br><br><br>$resdirectPhoneNumber.isValidForLocaleId($croNumberDetailsRequest.getLoc<br>ale()) 
  &amp;&amp;<br><br>$resdirectPhoneNumber.isValidSlot($croNumberDetailsRequest.getSlot()));<br><br>&nbsp; 
  &nbsp; &nbsp; &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp;ResultList.add($resdirectPhoneNumber);<br>end<br><br>_______________________________________________<br>rules-users 
  mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Edson Tirelli<br>JBoss Drools Core Development<br>JBoss, a 
division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>