<div>As I said earlier It <strong>may</strong> or <strong>may not</strong> 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><br clear="all">Regards,<br><br>Rajnikant Gupta<br><a href="http://rkthinks.wordpress.com/">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">moe.alkhafaji@medcpu.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<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 class="im">
<div><br></div>
<div>Thanks. <br><br>Sent from my iPhone</div></div>
<div>
<div></div>
<div class="h5">
<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 <strong><font color="#3366ff">knowledgeBaseCacheMap</font></strong> = 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>   <strong><font color="#3366ff">knowledgeBaseCacheMap.put(&quot;&lt;SOME_IDENTIFIER&gt;&quot;, this.knowledgeBase)</font></strong></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 href="http://rkthinks.wordpress.com/" target="_blank">http://rkthinks.wordpress.com/</a></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 href="mailto:moe.alkhafaji@medcpu.com" target="_blank">moe.alkhafaji@medcpu.com</a></a>&gt;</span><br>

<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<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 href="mailto:capricorn.raj@gmail.com" target="_blank">capricorn.raj@gmail.com</a></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 href="http://rkthinks.wordpress.com/" target="_blank">http://rkthinks.wordpress.com/</a></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 href="mailto:moe.alkhafaji@medcpu.com" target="_blank">moe.alkhafaji@medcpu.com</a></a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><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 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></a><br>
Sent from the Drools - User mailing list archive at <a href="http://nabble.com/" target="_blank"><a href="http://nabble.com/" target="_blank">Nabble.com</a></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 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a></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 href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></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 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a></a></span><br>
<span><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></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 href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a></a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></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">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>