Fusion uses exactly the same principles as the core engine; however the event (facts of type "event") "life-cycle" is managed by the engine. You'd still need to partition to get parallelism otherwise the possibility of dependencies between rules\facts\events in each process still arise.<div>
<br><div class="gmail_quote">2010/10/13 Tim Jones <span dir="ltr"><<a href="mailto:jones.tim36@gmail.com">jones.tim36@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I wasn't sure what was possible as I didn't know the inner workings of the algorithm. Thanks, you've cleared up my understanding quite a bit.<br><br>Do you happen to know if Fusion is any different? Or is it still a case of having to partition the data/streams to get parallelism?<br>
<br><br>Cheers,<br>Tim<br><br><div class="gmail_quote">2010/10/13 Swindells, Thomas <span dir="ltr"><<a href="mailto:TSwindells@nds.com" target="_blank">TSwindells@nds.com</a>></span><div><div></div><div class="h5">
<br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)">How would you expect Drools to multithread?</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)">From what I understand drools operates in two steps:</span></p>
<p><span style="font-size:11pt;color:rgb(31, 73, 125)"><span>1.<span style="font-family:"Times New Roman";font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal">
</span></span></span><span style="font-size:11pt;color:rgb(31, 73, 125)">When facts are inserted drools constructs and update Rete graph, generating an ordered list of ‘activations’ of rules (and the corresponding data)
which can be fired.</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)">There is a possibility here that inserts from multiple threads could be made thread safe (if it isn’t already).</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>
<p><span style="font-size:11pt;color:rgb(31, 73, 125)"><span>2.<span style="font-family:"Times New Roman";font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-size-adjust:none;font-stretch:normal">
</span></span></span><span style="font-size:11pt;color:rgb(31, 73, 125)">When fireAllRules is called it loops over the activation list, executing the then part of the rule. This execution may insert or update facts causing
activations to be added or removed.</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)">Because rules can alter the activation of other rules there isn’t any easy way to perform multithreading without introducing race conditions and errors. You
can’t execute two activations concurrently because the first (higher priority) activation may perform an update which invalidates the other activation or invalidates the preconditions which would almost certainly cause null pointer exceptions and the like.
</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)">Of course if your actions don’t have side effects (as far as rules is concerned) then there is nothing stopping your actions from dispatching tasks to a worker
thread pool which could then perform the actions concurrently.</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)">Thomas</span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:rgb(31, 73, 125)"> </span></p>
<div style="border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color blue;border-width:medium medium medium 1.5pt;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-style:solid none none;border-color:rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;border-width:1pt medium medium;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10pt" lang="EN-US">From:</span></b><span style="font-size:10pt" lang="EN-US"> <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>Tim Jones<br>
<b>Sent:</b> 13 October 2010 07:41<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] Parallel processing of large batches of facts</span></p>
</div>
</div><div><div></div><div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">Interesting suggestions. Couple of questions:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Is drools not internally able to multithread a single execution of fireallrules?</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Does CEP offer performance benefits, or is it just a different way of structuring the problem?</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Cheers,</p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Tim</p>
</div>
<div>
<p class="MsoNormal">2010/10/12 Michael Anstis <<a href="mailto:michael.anstis@gmail.com" target="_blank">michael.anstis@gmail.com</a>></p>
<p class="MsoNormal">Can the aggregation or timestamp range be used to partion your data?<br>
<br>
e.g. if you're looking for a data pattern where a fact matches X and Y and Z can the most course constraint, say X, not be used to partion?<br>
<br>
So you may have pre-processing (to partion the data) before hitting other finer grained rules?<br>
<br>
Would CEP in stream mode provide an opportunity either?<br>
<br>
2010/10/12 Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>>
</p>
<div>
<div>
<p class="MsoNormal"> </p>
<div>
<blockquote style="border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color rgb(204, 204, 204);border-width:medium medium medium 1pt;padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="margin-bottom:12pt">If you have to use a stateful session, with new objects being generated in RHS code and triggering more rules, then you've had it (since there is no way to split the 100k facts).<br>
<br>
If you don't create new facts in RHS code, you should investigate stateless sessions. It should be more efficient.<br>
<br>
Also, think about what you RHS code does. Can this processing be delegated to another thread? After a rule has fired, the "fate" of this activation is firmly established; rather than executing (timeconsuming i/o?) operations inline, queue the collected date
to a processor thread and let this one crunch it.<br>
<br>
(I've only thought about this for a few minutes, so there may be other options.)<br>
<br>
-W</p>
<div>
<p class="MsoNormal">2010/10/12 Tim Jones <<a href="mailto:jones.tim36@gmail.com" target="_blank">jones.tim36@gmail.com</a>></p>
<div>
<div>
<p class="MsoNormal">Hello,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I’m working on a project that needs a high performance rules system for processing batches of objects. Typically I’ll have a dozen or so rules, the most complex of which will aggregate
several objects based on timestamps and specified data patterns. The objects will come in batches of a few 100ks. The system is reset back to the starting point after each batch is processed.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">My guess at doing this with Drools is that you load up all the rules and enter all the objects as “facts”. You then hit fireallrules and sit back and wait. Doing this, I only get
so much performance and I can see that its only using a single thread. Is there a way to process the whole lot in a parallel, or multithreaded way? Unfortunately there's no natural way to partition the objects that would make things easier.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Cheers,</p>
<p class="MsoNormal">Tim</p>
<p class="MsoNormal"> </p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt">_______________________________________________<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></p>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><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></p>
</blockquote>
</div>
<p class="MsoNormal"> </p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><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></p>
</div>
<p class="MsoNormal"> </p>
</div></div></div>
</div>
<br>
<hr>
<font color="Gray" face="Arial" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the <a href="mailto:postmaster@nds.com" target="_blank">postmaster@nds.com</a> and delete it from your system as well as any copies. The content of e-mails as well as traffic data
may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</div>
<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>
<br></blockquote></div></div></div><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></blockquote></div><br></div>