<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><head><META content="text/html; charset=us-ascii" http-equiv="Content-Type">

<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META content="MSHTML 6.00.6000.16981" name=GENERATOR></head><BODY>
<DIV>
<DIV><FONT color=#0000ff face=Verdana size=2><SPAN class=175012121-22032010>It 
will be 1 trillion activations unless there is an index on the "id" property of 
the classes. If the right index is used, it should scan all objects of one 
class, and through indexes figure out the corresponding related objects of other 
classes. I am not sure if we can somehow tell rete to create indexes on certain 
attributes. I read a nice&nbsp;article on indexing in drools, which mentioned 
about Rete Beta node indexing. I am not sure if this is what drools is doing 
internally. Any suggestions/ideas?</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Verdana size=2><SPAN class=175012121-22032010></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face=Verdana size=2><SPAN class=175012121-22032010><A href="http://blog.decaresystems.ie/index.php/2008/02/24/rete-nodes-indexing-in-drools/">http://blog.decaresystems.ie/index.php/2008/02/24/rete-nodes-indexing-in-drools/</A></SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Verdana size=2><SPAN class=175012121-22032010></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face=Verdana size=2><SPAN class=175012121-22032010>Thanks,</SPAN></FONT></DIV>
<DIV><SPAN class=175012121-22032010><FONT color=#0000ff face=Verdana size=2>Malay</FONT></SPAN></DIV><BR>
<DIV align=left class=OutlookMessageHeader dir=ltr lang=en-us>
<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>Wolfgang 
Laun<BR><B>Sent:</B> Monday, March 22, 2010 3:17 PM<BR><B>To:</B> Rules Users 
List<BR><B>Subject:</B> Re: [rules-users] Drools stateless session 
question<BR></FONT><BR></DIV>
<DIV></DIV>You have calculated it correctly: 10000 A's * 10000 B's * 10000 C's 
results in 1,000.000,000.000 activations, which is (almost) a mind-boggling 
figure. I can't imagine what benefit this trillion of activations is going to 
have for your application. Even if you have the memory for all that, assuming 
that firing of one of these activations and processing of the RHS statements can 
be done in one microsecond, this is going to take days to complete, and it'll 
create a huge data set of A/B/C combinations for just this one rule.<BR><BR>Are 
you sure that you are on the right track?!<BR><BR>-W<BR><BR><BR>
<DIV class=gmail_quote>On Mon, Mar 22, 2010 at 7:46 PM, Shah, Malay <SPAN dir=ltr>&lt;<A href="mailto:Malay.Shah@morganstanley.com">Malay.Shah@morganstanley.com</A>&gt;</SPAN> 
wrote:<BR>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Thanks 
  W. Let me give you a rule that is causing us issues. Lets say we have 
  classes:<BR><BR>class A<BR>{<BR>&nbsp; &nbsp; &nbsp; &nbsp;int a;<BR>&nbsp; 
  &nbsp; &nbsp; &nbsp;String id;<BR>}<BR>Class B<BR>{<BR>&nbsp; &nbsp; &nbsp; 
  &nbsp;int &nbsp;b;<BR>&nbsp; &nbsp; &nbsp; &nbsp;String id;<BR>}<BR>Class 
  C<BR>{<BR>&nbsp; &nbsp; &nbsp; &nbsp;int c;<BR>&nbsp; &nbsp; &nbsp; 
  &nbsp;String id;<BR>}<BR><BR>and we have 12000 objects each. These objects are 
  connected using "id" property.<BR>If the rule is something like:<BR><BR>Rule 
  "ABC"<BR>When<BR>&nbsp; &nbsp; &nbsp; &nbsp;Obj_A: A(a!=1) &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//10000 object "A" instances 
  have a!=1<BR>&nbsp; &nbsp; &nbsp; &nbsp;Obj_B: B(b!=2,Obj_A.id = id) &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//10000 object "B" instances have 
  b!=2<BR>&nbsp; &nbsp; &nbsp; &nbsp;Obj_C: C(c!=3,Obj_B.id = id) &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp;//10000 object "C" instances have 
  c!=3<BR>Then<BR>&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Rule 
  fired");<BR>End<BR><BR>This means there would be a join between A, B and C 
  objects (10000 A's * 10000 B's * 10000 C's) to evaluate the rule. In such 
  cases, we see very high org.drools.reteoo.LeftTuple object count while 
  profiling the app. Is there a way to make the rete algo perform this 
  evaluation serially, or in batches, or use some object swapping mechanism to 
  limit creation of intermediate LeftTuple objects? Would the rete algo use 
  indexes in this case? That would potentially decrease these intermediate 
  objects. Currently, we use 5G heap and that is not enough for evaluating this 
  rule.<BR><BR>Regards,<BR>Malay<BR><BR>-----Original Message-----<BR>From: <A href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</A> 
  [mailto:<A href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</A>] 
  On Behalf Of Wolfgang Laun<BR>Sent: Monday, March 22, 2010 12:39 PM<BR>To: 
  Rules Users List<BR>Subject: Re: [rules-users] Drools stateless session 
  question<BR><BR>You have misunderstood the documentation. All eight items in 
  the enumeration you cite from are steps performed internally by the Drools 
  engine. The only thing you have to do is request sequential 
  mode.<BR><BR>Without an idea about the rule set you are using it's difficult 
  to advise how to reduce memory consumption.<BR><BR>-W<BR><BR><BR>2010/3/22 
  Shah, Malay &lt;<A href="mailto:Malay.Shah@morganstanley.com">Malay.Shah@morganstanley.com</A>&gt;:<BR>&gt; 
  Hi All,<BR>&gt;<BR>&gt; We have an application that uses drools stateless 
  session over a set<BR>&gt; of 35000 objects (taking about 40 MB heap) of 
  different types. During<BR>&gt; profiling, I saw that for rules that perform 
  joins between two huge<BR>&gt; object types data sets, lots of 
  org.drools.reteoo.LeftTuple objects<BR>&gt; causing out of memory errors. We 
  are using 5G heap, and have set<BR>&gt; property drools.sequential=true too. 
  Is there any way we can decrease<BR>&gt; the memory usage while applying these 
  rules? Drools documentation<BR>&gt; mentions &nbsp;for sequential mode, we 
  should do the following, some of<BR>&gt; them I am not sure how to 
  set:<BR>&gt;<BR>&gt;<BR>&gt; Turn off all node memories, except the 
  right-input Object memory.<BR>&gt;<BR>&gt; Disconnect the LeftInputAdapterNode 
  propagation, and have the Object<BR>&gt; plus the Node referenced in a Command 
  object, which is added to a list<BR>&gt; on the WorkingMemory for later 
  execution.<BR>&gt;<BR>&gt; Assert all objects, when all assertions are 
  finished and thus<BR>&gt; right-input node memories are populated check the 
  Command list and execute each in turn.<BR>&gt;<BR>&gt; <A href="http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/inde" target=_blank>http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/inde</A><BR>&gt; 
  x.html#d0e1295<BR>&gt;<BR>&gt; Do we need to set some properties in 
  RuleBaseConfiguration to make<BR>&gt; sure node memories are switched off? It 
  would be great if we can<BR>&gt; somehow decrease the memory usage for 
  stateless sessions? Has anybody<BR>&gt; come across such memory issues before? 
  Correct me if I am wrong, but I<BR>&gt; think 35000 objects is not a lot of 
  data for causing such issues.<BR>&gt;<BR>&gt; Thanks<BR>&gt; Malay<BR>&gt; 
  ________________________________<BR>&gt;<BR>&gt; NOTICE: If received in error, 
  please destroy, and notify sender.<BR>&gt; Sender does not intend to waive 
  confidentiality or privilege. Use of<BR>&gt; this email is prohibited when 
  received in error. We may monitor and<BR>&gt; store emails to the extent 
  permitted by applicable law.<BR>&gt;<BR>&gt; 
  ________________________________<BR>&gt;<BR>&gt; NOTICE: If received in error, 
  please destroy, and notify sender.<BR>&gt; Sender does not intend to waive 
  confidentiality or privilege. Use of<BR>&gt; this email is prohibited when 
  received in error. We may monitor and<BR>&gt; store emails to the extent 
  permitted by applicable law.<BR>&gt;<BR>&gt; 
  _______________________________________________<BR>&gt; rules-users mailing 
  list<BR>&gt; <A href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR>&gt; 
  <A href="https://lists.jboss.org/mailman/listinfo/rules-users" target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR>&gt;<BR>&gt;<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><BR>--------------------------------------------------------------------------<BR>NOTICE: 
  If received in error, please destroy, and notify sender. Sender does not 
  intend to waive confidentiality or privilege. Use of this email is prohibited 
  when received in error. We may monitor and store emails to the extent 
  permitted by applicable 
  law.<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></DIV>
<DIV>
<HR>
</DIV>
<P CLASS="BulletedList" STYLE="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0in; mso-list: none; tab-stops: .5in"><SPAN STYLE="FONT-SIZE: 8pt; COLOR: gray; mso-bidi-font-family: Arial"><FONT COLOR="gray" FACE="Arial" SIZE="1">NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.&nbsp;We<SPAN STYLE="FONT-SIZE: 7.5pt; COLOR: gray; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"> may monitor and store emails to the extent permitted by applicable law.</SPAN></FONT></SPAN></P>
<DIV></DIV></BODY></HTML>