<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3395" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2>Folks - 
</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial><FONT color=#0000ff><FONT 
size=2>After&nbsp;<SPAN class=096121117-15092008>seeing the&nbsp;</SPAN>thread 
on&nbsp;<SPAN class=096121117-15092008>e</SPAN>vals&nbsp;<SPAN 
class=096121117-15092008>hurting performance </SPAN>a couple of weeks ago<SPAN 
class=096121117-15092008>, 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 face=Arial color=#0000ff 
size=2></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=096121117-15092008>An example is shown below.&nbsp; We're using evals 
every time we make a call to "rulesUtil", a helper class we have for checking 
strings for keywords.&nbsp; Two questions:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=096121117-15092008></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=096121117-15092008>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 face=Arial color=#0000ff size=2><SPAN 
class=096121117-15092008>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 face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2></FONT>&nbsp;</DIV><FONT color=#0000ff size=2><FONT color=#960000 size=1>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff 
size=2>rule</FONT></FONT><FONT face=Arial> 'my rule'</FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT 
face=Arial>salience</FONT></B></FONT><FONT face=Arial> 790</FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT 
face=Arial>activation-group</FONT></B></FONT><FONT face=Arial> <FONT 
color=#008000>"priorityRule"</DIV></FONT></FONT>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT 
face=Arial>when</FONT></DIV></B></FONT>
<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>"X</FONT>, $rfp : RFP , <B><FONT 
color=#960000>eval</B></FONT></FONT><FONT face=Arial>( 
ruleUtil.containsKeywordString($rfp, <FONT color=#008000>"Y"</FONT> )<SPAN 
class=096121117-15092008>)</SPAN> , $tcn : TCN)</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial>s2 : Sensor( TCN != $tcn, source == 
<FONT color=#008000>"Z"</FONT></FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT 
face=Arial>then</FONT></DIV></B></FONT>
<DIV dir=ltr align=left><FONT face=Arial>System.out.println(<FONT 
color=#008000>"my rule");</FONT></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial>priority.setPriorityName(<SPAN 
class=096121117-15092008>"A"</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></FONT>
<DIV dir=ltr align=left><FONT face=Arial><FONT size=2><FONT color=#0000ff><FONT 
face=Arial color=#0000ff size=2></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=096121117-15092008>Thanks,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=096121117-15092008>David Warren</SPAN></FONT></DIV><FONT face=Arial 
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org 
[mailto:rules-users-bounces@lists.jboss.org] <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">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">Sushanta.Rout@ihg.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">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 "test"<BR>&nbsp; &nbsp; &nbsp; 
  &nbsp;dialect "java"<BR>&nbsp; &nbsp; &nbsp; &nbsp;activation-group 
  "group1"<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">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">www.jboss.com</A><BR></DIV></BODY></HTML>