I see. Thanks Rajnikant. I appreciate the assistance. I hope there would be a way to maybe make this more internal to the KnowledgeBase object itself, or define another object for this type of caching instead of creating this complexity outside. Does anyone have another approach? Or is it basically that everyone is &quot;putting&quot; up with the delays of adding a new KnowledgePackage to an existing KnowledgeBase? Thanks.<br>

<br><div class="gmail_quote">2010/5/3 Rajnikant Gupta <span dir="ltr">&lt;<a href="mailto:capricorn.raj@gmail.com">capricorn.raj@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div>As I said earlier It <b>may</b> or <b>may not</b> be relevant in your case. Usually caching improves performance significantly in drools.</div>
<div> </div>
<div> In case of our application it does so by a very significant factor.</div><div><div></div><div class="h5">
<div><br clear="all">Regards,<br><br>Rajnikant Gupta<br><a href="http://rkthinks.wordpress.com/" target="_blank">http://rkthinks.wordpress.com/</a><br><br><br></div>
<div class="gmail_quote">2010/5/3 Moe Alkhafaji <span dir="ltr">&lt;<a href="mailto:moe.alkhafaji@medcpu.com" target="_blank">moe.alkhafaji@medcpu.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="padding-left: 1ex; margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204);">
<div bgcolor="#FFFFFF">
<div>Hmmm, so you are suggesting I keep caches all possible combinations of KnowledgePackages? If I have 100 possible KnowledgePackages and they are loaded and unloaded dynamically that means I will have to have 100 choose n where n goes from 1 to 100. That will make me go out of memory easy no?</div>



<div>
<div><br></div>
<div>Thanks. <br><br>Sent from my iPhone</div></div>
<div>
<div></div>
<div>
<div><br>On May 3, 2010, at 2:07 AM, Rajnikant Gupta &lt;<a href="mailto:capricorn.raj@gmail.com" target="_blank">capricorn.raj@gmail.com</a>&gt; wrote:<br><br></div>
<div></div>
<blockquote type="cite">
<div>
<div>It may look something like this:</div>
<div> </div>
<div>Map <b><font color="#3366ff">knowledgeBaseCacheMap</font></b> = new HashMap();</div>
<div> </div>
<div>this.knowledgeBase = knowledgeBaseCacheMap.get(&quot;&lt;SOME_IDENTIFIER&gt;&quot;);</div>
<div> </div>
<div>if(this.knowledgeBase == null){</div>
<div>   this.knowledgeBase.addKnowledgePackages(packages);</div>
<div>   <b><font color="#3366ff">knowledgeBaseCacheMap.put(&quot;&lt;SOME_IDENTIFIER&gt;&quot;, this.knowledgeBase)</font></b></div>
<div>}</div>
<div> </div>
<div>By doing this the packages get added to the knowledgeBase only for the first time. From second request onwards you get the same knowledgeBase each time without the need for adding the packages again. </div>
<div> </div>
<div>But this is valid only if you are not changing your rules. If your rules are changing from time to time, you may have to look at caching at more lower levels. </div>
<div> </div>
<div>I am not sure whether this can be helpful in your case but this is often helpful.</div>
<div> </div>
<div><br clear="all">Regards,<br><br>Rajnikant Gupta<br><a href="http://rkthinks.wordpress.com/" target="_blank"></a><a href="http://rkthinks.wordpress.com/" target="_blank">http://rkthinks.wordpress.com/</a><br><br><br>


</div>
<div class="gmail_quote">2010/5/3 Moe Alkhafaji <span dir="ltr">&lt;<a href="mailto:moe.alkhafaji@medcpu.com" target="_blank"></a><a href="mailto:moe.alkhafaji@medcpu.com" target="_blank">moe.alkhafaji@medcpu.com</a>&gt;</span><br>



<blockquote class="gmail_quote" style="padding-left: 1ex; margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204);">
<div bgcolor="#FFFFFF">
<div>Thanks for the reply. But I don&#39;t understand what you mean by caching the KnowledgeBase. This is about adding a pre compiled KnowledgePackage to a KnowledgeBase. So, how does caching a KnowledgeBase makes addition of new KnowledgePackage faster? Please excuse my ignorance if I am not catching what you are suggesting. Maybe a couple of lines of code to demonstrate your suggestion would be greatly appreciated. Thanks. <br>


<br>Sent from my iPhone</div>
<div>
<div></div>
<div>
<div><br>On May 3, 2010, at 1:24 AM, Rajnikant Gupta &lt;<a href="mailto:capricorn.raj@gmail.com" target="_blank"></a><a href="mailto:capricorn.raj@gmail.com" target="_blank">capricorn.raj@gmail.com</a>&gt; wrote:<br><br>


</div>
<div></div>
<blockquote type="cite">
<div>
<div>Hi,</div>
<div> </div>
<div>Yes, adding packages to knowledgeBase does take some time. You can probably try caching your knowledgeBase. By doing this all, but first, requests should be significantly fast.</div>
<div> </div>
<div> </div>
<div> </div>
<div><br clear="all">Regards,<br><br>Rajnikant Gupta<br><br><a href="http://rkthinks.wordpress.com/" target="_blank"></a><a href="http://rkthinks.wordpress.com/" target="_blank"></a><a href="http://rkthinks.wordpress.com/" target="_blank">http://rkthinks.wordpress.com/</a><br>


<br><br></div>
<div class="gmail_quote">On Mon, May 3, 2010 at 11:36 AM, malkhafaji <span dir="ltr">&lt;<a href="mailto:moe.alkhafaji@medcpu.com" target="_blank"></a><a href="mailto:moe.alkhafaji@medcpu.com" target="_blank"></a><a href="mailto:moe.alkhafaji@medcpu.com" target="_blank">moe.alkhafaji@medcpu.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="padding-left: 1ex; margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204);"><br>Hello,<br><br>I am trying to add knowledge packages to an existing KnowledgeBase. My<br>

largest DRL file has 110 rules. I noticed that it may take up to 5 seconds<br>
just to execute the following statement:<br><br>this.knowledgeBase.addKnowledgePackages(packages);<br><br>where &quot;packages&quot; is just a list of one knowledge package representing one<br>drl. The nature of my rules is that I initially load a small set of rules<br>


and then at runtime my rules may load other DRLs. The problem is each DRL<br>loading command (this.knowledgeBase.addKnowledgePackages(packages)) takes a<br>few seconds and I have no idea why. Although, all those DRLs are already<br>


compiled (at startup time). It is the line I pasted above that takes the<br>longest time out of anything else I do.<br><br>Any idea why just merely adding a KnowledgePackage list to a KnowledgeBase<br>can take this much time? Do you guys have any suggestions on how I can<br>


reduce this time? I tried to create another dummy KnowledgeBase and get the<br>KnowledgePackage from it at runtime and add that to my KnowedgeBase above<br>(thinking that would reduce the time maybe), but not at all.<br>

<br>
Any ideas would be great. The API does not have much info on what that add<br>method exactly does behind the scenes, and how I can get around the long<br>delays. This is very frustrating to me, and I am not sure where to look.<br>


Thanks for ANY help at all.<br><font color="#888888">--<br>View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/addKnowledgePackages-Delay-tp772574p772574.html" target="_blank"></a><a href="http://drools-java-rules-engine.46999.n3.nabble.com/addKnowledgePackages-Delay-tp772574p772574.html" target="_blank"></a><a href="http://drools-java-rules-engine.46999.n3.nabble.com/addKnowledgePackages-Delay-tp772574p772574.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/addKnowledgePackages-Delay-tp772574p772574.html</a><br>


Sent from the Drools - User mailing list archive at <a href="http://nabble.com/" target="_blank"></a><a href="http://nabble.com/" target="_blank">Nabble.com</a>.<br>_______________________________________________<br>rules-users mailing list<br>


<a href="mailto:rules-users@lists.jboss.org" target="_blank"></a><a href="mailto:rules-users@lists.jboss.org" target="_blank"></a><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"></a><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"></a><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>


</font></blockquote></div><br></div></blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br><span>rules-users mailing list</span><br><span><a href="mailto:rules-users@lists.jboss.org" target="_blank"></a><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a></span><br>


<span><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"></a><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></span><br>


</div></blockquote></div></div></div><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank"></a><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"></a><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></blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br><span>rules-users mailing list</span><br><span><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a></span><br><span><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></span><br>


</div></blockquote></div></div></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><br>
</div></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>Moe Alkhafaji<br>Chief Technology Officer, MedCPU<br>Phone: (630) 290-1113<br>Email: <a href="mailto:cto@medcpu.com">cto@medcpu.com</a><br><br>This message contains information which may be confidential. Unless you are the addressee, you may not use, copy or disclose to anyone the message or any information contained in this message. If you have received this email in error, please notify <a href="mailto:cto@medcpu.com">cto@medcpu.com</a> and please delete the message immediately. In order for the contents of this message to be binding on behalf of MedCPU it must be confirmed in writing by an authorized signatory of MedCPU. Our company accepts no liability for the content of this email unless it is so confirmed. The views or opinions presented herein do not necessarily represent those of the company.<br>