Re: [rules-users] Caching of JBoss Rules bytecode field readers
The getters are generated by this class: http://fisheye.jboss.org/browse/JBossRules/branches/4.0.x/drools-core/src/main/java/org/drools/base/ClassFieldExtractorFactory.java?r=15671 It creates a ClassLoader using the RuleBase classloader as the parent. The generated classes are also stored in the cache: http://fisheye.jboss.org/browse/JBossRules/branches/4.0.x/drools-core/src/main/java/org/drools/base/ClassFieldExtractorCache.java?r=15671 However this cache is a singleton so I guess if you have two rulebases which reference different threads and then you execute on another thread - the cache is on the executing thread, the code generation on the referenced threads. mark Keith Bennett wrote: Thanks for the explanation, Mark. Sorry if it appeared that the focus of my poorly worded question was why Strings were used for the key. Using Strings makes total sense to me. I was really just trying to better understand how caching is implemented to help me better understand why I'm having the problem I originally posted about. Can you explain to me how, through the JBoss Rules API, I can always ensure that I'm not picking anything up from an internal cache when I deploy new rules? I want to always make sure that the rules from the new drl file I place in the classpath are always picked up, not anything that was previously cached internally by JBoss Rules. Thanks. Keith On Wed, Jul 9, 2008 at 9:15 AM, Mark Proctor <[EMAIL PROTECTED]> wrote: We generate bytecode readers for performance, it would be possible to plugin a reflection based reader that would avoid this issue, but we don't have plans to this due to time - we would accept a patch. With regards to why the String for the key, why not? What other key would you imagine we should keep? I guess we could alos look into a classloader specific var to hold the cache. Shows the classes we use to generate field accessors. http://fisheye.jboss.org/browse/JBossRules/tags/4.0.7.19894.GA/drools-core/src/main/java/org/drools/util/asm If you do an import of the project into eclipse you can see where those classes are used from and maybe come up with a solution - please make sure there are no performance loses. Mark Keith Bennett wrote: I found a link that might explain what is happening with the problem I described in another posting (included below): http://jira.jboss.com/jira/browse/JBRULES-1009 Mark Proctor, if you read this posting, can you please explain in more detail how and why JBoss Rules generates bytecode field readers and caches them by string name? I would appreciate it. Could this explain the issue I'm experiencing as described below? I have scoured the documentation and have tried many different approaches to solving this problem, to no avail. I absolutely can not get the new version of a .drl file to load with just an application restart in Tomcat. I have to restart Tomcat each time. In my mind, this has to be a classloader issue. I just don't know how to get around it. I would really appreciate any help! Keith -- Forwarded message -- From: Keith Bennett <[EMAIL PROTECTED]> Date: Wed, Jul 2, 2008 at 9:47 AM Subject: New rules in source file not loaded when application redeployed To: Rules Users List I am packaging my rules as a drl source file in a jar that is then bundled in a war file that is then deployed to Tomcat. In my implementation, the rulebase is cached the first time it is used in my application, but when I add new rules to the source file and rebuild my application then redeploy it on Tomcat, the new version of the rules don't get loaded into the rulebase. Why and how is an older version of the rules being loaded into the rulebase when I redeploy my application in Tomcat? As FYI, I have developed a business rules service that initializes the rulebase upon a Spring container startup by loading the drl file from the classpath. Is there an internal Drools static cache that is scoped to something other than my application? The only thing I can do to load the new rules is restart Tomcat. When I do this, the new version of the drl source file is loaded and used, so I'm thinking the problem I'm having is somehow related to the class loaders Tomcat uses, but I can't find information about what Drools might be doing internally with a static cache or something like that. Can anyone explain what might be happening and how to configure Drools and/or my application to get around this problem I'm having? I definitely appreciate any help you can provide! Keith ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.
Re: [rules-users] Compilation error: "Syntax error, insert "; " to complete BlockStatements "
Kris, that may be silly but have you tried to add the ";" after 'addCharge($event, $amount)'? If you use the Java dialect for the RHS this IS mostly Java (it's just copied over into the generated code). If in doubt, use "-Ddrools.dump.dir=generated code. --I Am 09.07.2008 um 21:59 schrieb Kris Nuttycombe: Hi, all, I'm new to Drools, and am a bit confused by the compilation error that I'm getting. From the line number, it appears to be in a generated Java file instead of in my rules file, so I'm having a hard time debugging the issue. Here is the full error: Rule Compilation error : [Rule name=Assert Total Accumulator for Order, agendaGroup=init, salience=0, no-loop=false] com/gaiam/gcsi/rules/Rule_Assert_Total_Accumulator_for_Order_0.java (7:429) : Syntax error, insert ";" to complete BlockStatements Here is the rule that's being referred to: rule "Add charge amounts to total." agenda-group "calc_total" when $total : Total() $event : ProgramBillingEvent( $amount : amount) then modify( $total ) { addCharge($event, $amount) } end I'm working from the example modify block discussed in the docs at http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html/ch02s05.html#d0e961 - I haven't been able to find other documentation referring to this construct. What am I doing wrong? Thanks, Kris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Problem using RuleAgent
I'm having a problem with the RuleAgent... I'm using a RuleAgent to load rules and create a rulebase, but i'm finding that in the time it takes to load all 30 or so files that I'm using for my rules, my main thread starts running strings against the rules before all of the rules have been initially loaded. Is there an easy way to block until all rule-loading operations are completed? This would be important for rule changes too, though not as much so as on the initial load. I'm thinking a listener sounds like the right way to go, but I'm not very familiar with multi-threaded programming and so I don't really know how to go about implementing that. Would somebody mind giving me a hand? Thanks, ___ Brian Trezise Staff Software Engineer IntelliData, Inc 3173 s. uravan way aurora, colorado 80013 T: 720.524.4864 [EMAIL PROTECTED] ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Compilation error: "Syntax error, insert "; " to complete BlockStatements "
Hi, all, I'm new to Drools, and am a bit confused by the compilation error that I'm getting. From the line number, it appears to be in a generated Java file instead of in my rules file, so I'm having a hard time debugging the issue. Here is the full error: Rule Compilation error : [Rule name=Assert Total Accumulator for Order, agendaGroup=init, salience=0, no-loop=false] com/gaiam/gcsi/rules/Rule_Assert_Total_Accumulator_for_Order_0.java (7:429) : Syntax error, insert ";" to complete BlockStatements Here is the rule that's being referred to: rule "Add charge amounts to total." agenda-group "calc_total" when $total : Total() $event : ProgramBillingEvent( $amount : amount) then modify( $total ) { addCharge($event, $amount) } end I'm working from the example modify block discussed in the docs at http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html/ch02s05.html#d0e961 - I haven't been able to find other documentation referring to this construct. What am I doing wrong? Thanks, Kris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Caching of JBoss Rules bytecode field readers
Thanks for the explanation, Mark. Sorry if it appeared that the focus of my poorly worded question was why Strings were used for the key. Using Strings makes total sense to me. I was really just trying to better understand how caching is implemented to help me better understand why I'm having the problem I originally posted about. Can you explain to me how, through the JBoss Rules API, I can always ensure that I'm not picking anything up from an internal cache when I deploy new rules? I want to always make sure that the rules from the new drl file I place in the classpath are always picked up, not anything that was previously cached internally by JBoss Rules. Thanks. Keith On Wed, Jul 9, 2008 at 9:15 AM, Mark Proctor <[EMAIL PROTECTED]> wrote: > We generate bytecode readers for performance, it would be possible to plugin > a reflection based reader that would avoid this issue, but we don't have > plans to this due to time - we would accept a patch. With regards to why the > String for the key, why not? What other key would you imagine we should > keep? I guess we could alos look into a classloader specific var to hold the > cache. > > Shows the classes we use to generate field accessors. > http://fisheye.jboss.org/browse/JBossRules/tags/4.0.7.19894.GA/drools-core/src/main/java/org/drools/util/asm > > If you do an import of the project into eclipse you can see where those > classes are used from and maybe come up with a solution - please make sure > there are no performance loses. > > Mark > Keith Bennett wrote: >> >> I found a link that might explain what is happening with the problem I >> described in another posting (included below): >> http://jira.jboss.com/jira/browse/JBRULES-1009 >> >> Mark Proctor, if you read this posting, can you please explain in more >> detail how and why JBoss Rules generates bytecode field readers and >> caches them by string name? I would appreciate it. Could this >> explain the issue I'm experiencing as described below? >> >> I have scoured the documentation and have tried many different >> approaches to solving this problem, to no avail. I absolutely can not >> get the new version of a .drl file to load with just an application >> restart in Tomcat. I have to restart Tomcat each time. In my mind, >> this has to be a classloader issue. I just don't know how to get >> around it. I would really appreciate any help! >> >> Keith >> >> >> -- Forwarded message -- >> From: Keith Bennett <[EMAIL PROTECTED]> >> Date: Wed, Jul 2, 2008 at 9:47 AM >> Subject: New rules in source file not loaded when application redeployed >> To: Rules Users List >> >> >> I am packaging my rules as a drl source file in a jar that is then >> bundled in a war file that is then deployed to Tomcat. In my >> implementation, the rulebase is cached the first time it is used in my >> application, but when I add new rules to the source file and rebuild >> my application then redeploy it on Tomcat, the new version of the >> rules don't get loaded into the rulebase. >> >> Why and how is an older version of the rules being loaded into the >> rulebase when I redeploy my application in Tomcat? As FYI, I have >> developed a business rules service that initializes the rulebase upon >> a Spring container startup by loading the drl file from the classpath. >> Is there an internal Drools static cache that is scoped to something >> other than my application? The only thing I can do to load the new >> rules is restart Tomcat. When I do this, the new version of the drl >> source file is loaded and used, so I'm thinking the problem I'm having >> is somehow related to the class loaders Tomcat uses, but I can't find >> information about what Drools might be doing internally with a static >> cache or something like that. >> >> Can anyone explain what might be happening and how to configure Drools >> and/or my application to get around this problem I'm having? I >> definitely appreciate any help you can provide! >> >> Keith >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] One question about "NOT"
Senlin Liang wrote: Hi all, I checked the manual about "not", and it says: ==quote== not' is first order logic's Non-Existential Quantifier and checks for the non existence of something in the Working Memory. Think of 'not' as meaning "there must be none of...". " ==end== So there is no negation-as-failure, no stable model semantics, no well founded semantics in Drools. Is it the case? This is the standard way that a Production Rule system works, and often very hard for "formal" logiticians to understand, they get in a bit of a tizz about it - wanting it to work like prolog. When in reality the way production rules do 'not' is very practice for end users. I'll be adding backward chaining later this year, the foundations are there, we can look into your issues as part of this if you like. If you can think how to improve standard PR behaviour, let me know. Mark Thanks, Senlin ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] One question about "NOT"
Hi all, I checked the manual about "not", and it says: ==quote== not' is first order logic's Non-Existential Quantifier and checks for the non existence of something in the Working Memory. Think of 'not' as meaning "there must be none of...". " ==end== So there is no negation-as-failure, no stable model semantics, no well founded semantics in Drools. Is it the case? Thanks, Senlin ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] Drools 4 poor performance scaling?
I wonder whether is's a "benefit" of truth maintenance? If a new fact is inserted into working memory that could cause an activation of a rule that contains an accumulate (or collect) to change then the whole accumulate (or collect) operator is executed again?!? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch, Eric Sent: 09 July 2008 14:41 To: Rules Users List Subject: RE: [rules-users] Drools 4 poor performance scaling? FYI for the group. We seem to have solved our performance problem. I'll describe our problem space a bit some people have some context. We load up about 1200 Jobs with about 3000 Stops and about 1500 Vehicles with about 2000 Workers. We then calculate Scores for each Vehicle for each Job. Some combinations get excluded for various reasons, but we end up with 700k - 900k total facts. We do score totaling and sorting using accumulators. One of our teams members (nice find Dan) decided to try to isolate the accumulation rules until all our other facts are loaded. Those rules now have a "not ColdStarting()" condition and our startup code inserts a ColdStarting fact as the first fact and retracts it when all the Jobs and Workers have been loaded. This changed our startup time from over 50 minutes to under 5. There's some sort of strange propagation and looping going on with accumulation on the fly, at least with our facts and rules. I'll put an entry on the wiki as well. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch, Eric Sent: Monday, June 30, 2008 11:46 AM To: Rules Users List Subject: RE: [rules-users] Drools 4 poor performance scaling? We are having a similar problem, although our fact count is much higher. Performance seems pretty good and consistent until about 400k facts, then performance degrades significantly. Part of the degradation is from bigger and more frequent GCs, but not all of it. Time to load first 100k facts: ~1 min Time to load next 100k facts: ~1 min Time to load next 100k facts: ~2 min Time to load next 100k facts: ~4 min This trend continues, going from 600k to 700k facts takes over 7 minutes. We're running 4.0.7 on a 4 CPU box with 12 GB, 64 bit RH Linux and 64 bit JRockit 5. We've allocated a 9 GB heap for the VM using large pages, so no memory paging is happening. JRockit is started w/ the -XXagressive parameter, which enables large pages and the more efficient hash function in HashMap which was introduced in Java5 update 8. http://e-docs.bea.com/jrockit/jrdocs/refman/optionXX.html The end state is over 700k facts, with the possibility of nearly 1M facts in production. After end state is reached and we issue a few GC requests, if looks like our memory per fact is almost 9k, which seems quite high as most of the facts are very simple. Could that be due to our liberal use of insertLogical and TMS? We've tried performing a "commit" every few hundred fact insertions by issuing a fireAllRules periodically, and that seems to have helped marginally. I tried disabling shadow proxies and a few of our ~390 test cases fail and one loops indefinitely. I'm pretty sure we could fix those, but don't want to bother if this isn't a realistic solution. Any thoughts? Thanks Eric -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ron Kneusel Sent: Thursday, June 26, 2008 12:47 PM To: rules-users@lists.jboss.org Subject: [rules-users] Drools 4 poor performance scaling? I am testing Drools 4 for our application and while sequential mode is very fast I get very poor scaling when I increase the number of facts for stateful or stateless sessions. I want to make sure I'm not doing something foolish before deciding on whether or not to use Drools because from what I am reading online it should be fast with the number of facts I have. The scenario: I have 1000 rules in a DRL file. They are all of the form: rule rule when Data(type == 0, value> 0.185264); Data(type == 3, value < 0.198202); then insert(new AlarmRaised(0)); warnings.setAlarm(0, true); end where the ranges checked on the values and the types are randomly generated. Then, I create a Stateful session and run in a loop timing how long it takes the engine to fire all rules as the number of inserted facts increases: // Run for(j=0; j < 100; j+=5) { if (j==0) { nfacts = 1; } else { nfacts = j; } System.out.println(nfacts + ":"); // Get a working memory StatefulSession wm = ruleBase.newStatefulSession(); // Global - output warnings = new Alarm(); wm.setGlobal("warnings", warnings); // Add facts st = (new Date()).getTime(); for(i=0; i < nfacts; i++) { wm.insert(new Data(rand.nextInt(4), rand.ne
Re: [rules-users] wordnet in drools
I would imagine that the performance issues are due to emulating backward chaining/query like behaviour in a forward chaining engine. I imagine this is also true with regards to the email "one question about Transitive Closures". We need to build in support for proper backward chaining querries to get an equal comparison on performance. Mark Paul Fodor wrote: I am new to Drools and I wonder if anyone used WordNet from Drools. Basically, I want to make some simple joins, such as, find words that are in the same synset, all hypernyms of a word, hyponyms, meronyms of verbs, adjectives, etc. I haven't heard of it being applied with Drools. Do let me know your findings if you produce anything interesting. Hi Mark, We couldn't find any implementation for WordNet from Drools, so we wrote an implementation. Anyone, please feel free to use it (attached below). If you want some additional functions, feel free to let me know. It is an interface to WordNet for Drools using a SQL database (MySQL). The computation times are pretty good compared with other Java based rule engines, but an order of magnitude slower than C-based Prolog systems. I wonder if this is not an indexing problem for Java objects (we create about 300,000 instances of the same class to store the WordNet ontology). We can also consult the database directly (without putting the WordNet ontology in JVM), but that is slower than having all objects in main memory (beside the same tests for the Prolog systems had the whole ontology in the main memory, so we want to do the same for Drools). Regards, Paul Fodor WordNetInterface_rules.drl: package drools import drools.WordNetInterface.S; import drools.WordNetInterface.G; import drools.WordNetInterface.Hyp; import drools.WordNetInterface.Mm; import drools.WordNetInterface.Ent; import drools.WordNetInterface.Sim; import drools.WordNetInterface.Ant; import drools.WordNetInterface.Reach; rule "CoordinateTerms" salience 10 when s1 : S( si : synset_id, w1 : word) s2 : S( synset_id == si, word != w1, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllGlosses" salience 10 when s : S( si : synset_id, w : word) g : G( synset_id == si, gl : gloss) then insert( new Reach(w,gl) ); //System.out.println( "Reach " + w + "," + gl ); end rule "testAllHypernyms" salience 10 when s1 : S( si1 : synset_id, w1 : word) h : Hyp( synset_id1 == si1, si2 : synset_id2) s2 : S( synset_id == si2, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllHyponyms" salience 10 when s1 : S( si1 : synset_id, w1 : word) h : Hyp( synset_id2 == si1, si2 : synset_id1) s2 : S( synset_id == si2, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllMeronyms" salience 10 when s1 : S( si1 : synset_id, w1 : word) m : Mm( synset_id2 == si1, si2 : synset_id1) s2 : S( synset_id == si2, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllHolonyms" salience 10 when s1 : S( si1 : synset_id, w1 : word) m : Mm( synset_id1 == si1, si2 : synset_id2) s2 : S( synset_id == si2, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllTroponyms" salience 10 when s1 : S( si1 : synset_id, w1 : word) en : Ent( synset_id1 == si1, si2 : synset_id2) s2 : S( synset_id == si2, w2 : word) then insert( new Reach(w1,w2) ); // System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllSimilars" salience 10 when s1 : S( si1 : synset_id, w1 : word) sim1 : Sim( synset_id1 == si1, si2 : synset_id2) s2 : S( synset_id == si2, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end rule "testAllAntonyms" salience 10 when s1 : S( si1 : synset_id, w_n1 : w_num, w1 : word) a : Ant( synset_id1 == si1, w_num1 == w_n1, si2 : synset_id2, w_n2 : w_num2) s2 : S( synset_id == si2, w_num == w_n2, w2 : word) then insert( new Reach(w1,w2) ); //System.out.println( "Reach " + w1 + "," + w2 ); end WordNetInterface.java: package drools; import java.io.InputStreamReader; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import org.drools.RuleBase; import org.drools.RuleBaseFactory; import org.drools.StatefulSession; import org.drools.audit.WorkingMemoryFileLogger; import org.drools.base.RuleNameEqualsAgendaFilter; import org.drools
Re: [rules-users] Caching of JBoss Rules bytecode field readers
We generate bytecode readers for performance, it would be possible to plugin a reflection based reader that would avoid this issue, but we don't have plans to this due to time - we would accept a patch. With regards to why the String for the key, why not? What other key would you imagine we should keep? I guess we could alos look into a classloader specific var to hold the cache. Shows the classes we use to generate field accessors. http://fisheye.jboss.org/browse/JBossRules/tags/4.0.7.19894.GA/drools-core/src/main/java/org/drools/util/asm If you do an import of the project into eclipse you can see where those classes are used from and maybe come up with a solution - please make sure there are no performance loses. Mark Keith Bennett wrote: I found a link that might explain what is happening with the problem I described in another posting (included below): http://jira.jboss.com/jira/browse/JBRULES-1009 Mark Proctor, if you read this posting, can you please explain in more detail how and why JBoss Rules generates bytecode field readers and caches them by string name? I would appreciate it. Could this explain the issue I'm experiencing as described below? I have scoured the documentation and have tried many different approaches to solving this problem, to no avail. I absolutely can not get the new version of a .drl file to load with just an application restart in Tomcat. I have to restart Tomcat each time. In my mind, this has to be a classloader issue. I just don't know how to get around it. I would really appreciate any help! Keith -- Forwarded message -- From: Keith Bennett <[EMAIL PROTECTED]> Date: Wed, Jul 2, 2008 at 9:47 AM Subject: New rules in source file not loaded when application redeployed To: Rules Users List I am packaging my rules as a drl source file in a jar that is then bundled in a war file that is then deployed to Tomcat. In my implementation, the rulebase is cached the first time it is used in my application, but when I add new rules to the source file and rebuild my application then redeploy it on Tomcat, the new version of the rules don't get loaded into the rulebase. Why and how is an older version of the rules being loaded into the rulebase when I redeploy my application in Tomcat? As FYI, I have developed a business rules service that initializes the rulebase upon a Spring container startup by loading the drl file from the classpath. Is there an internal Drools static cache that is scoped to something other than my application? The only thing I can do to load the new rules is restart Tomcat. When I do this, the new version of the drl source file is loaded and used, so I'm thinking the problem I'm having is somehow related to the class loaders Tomcat uses, but I can't find information about what Drools might be doing internally with a static cache or something like that. Can anyone explain what might be happening and how to configure Drools and/or my application to get around this problem I'm having? I definitely appreciate any help you can provide! Keith ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] Drools 4 poor performance scaling?
FYI for the group. We seem to have solved our performance problem. I'll describe our problem space a bit some people have some context. We load up about 1200 Jobs with about 3000 Stops and about 1500 Vehicles with about 2000 Workers. We then calculate Scores for each Vehicle for each Job. Some combinations get excluded for various reasons, but we end up with 700k - 900k total facts. We do score totaling and sorting using accumulators. One of our teams members (nice find Dan) decided to try to isolate the accumulation rules until all our other facts are loaded. Those rules now have a "not ColdStarting()" condition and our startup code inserts a ColdStarting fact as the first fact and retracts it when all the Jobs and Workers have been loaded. This changed our startup time from over 50 minutes to under 5. There's some sort of strange propagation and looping going on with accumulation on the fly, at least with our facts and rules. I'll put an entry on the wiki as well. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch, Eric Sent: Monday, June 30, 2008 11:46 AM To: Rules Users List Subject: RE: [rules-users] Drools 4 poor performance scaling? We are having a similar problem, although our fact count is much higher. Performance seems pretty good and consistent until about 400k facts, then performance degrades significantly. Part of the degradation is from bigger and more frequent GCs, but not all of it. Time to load first 100k facts: ~1 min Time to load next 100k facts: ~1 min Time to load next 100k facts: ~2 min Time to load next 100k facts: ~4 min This trend continues, going from 600k to 700k facts takes over 7 minutes. We're running 4.0.7 on a 4 CPU box with 12 GB, 64 bit RH Linux and 64 bit JRockit 5. We've allocated a 9 GB heap for the VM using large pages, so no memory paging is happening. JRockit is started w/ the -XXagressive parameter, which enables large pages and the more efficient hash function in HashMap which was introduced in Java5 update 8. http://e-docs.bea.com/jrockit/jrdocs/refman/optionXX.html The end state is over 700k facts, with the possibility of nearly 1M facts in production. After end state is reached and we issue a few GC requests, if looks like our memory per fact is almost 9k, which seems quite high as most of the facts are very simple. Could that be due to our liberal use of insertLogical and TMS? We've tried performing a "commit" every few hundred fact insertions by issuing a fireAllRules periodically, and that seems to have helped marginally. I tried disabling shadow proxies and a few of our ~390 test cases fail and one loops indefinitely. I'm pretty sure we could fix those, but don't want to bother if this isn't a realistic solution. Any thoughts? Thanks Eric -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ron Kneusel Sent: Thursday, June 26, 2008 12:47 PM To: rules-users@lists.jboss.org Subject: [rules-users] Drools 4 poor performance scaling? I am testing Drools 4 for our application and while sequential mode is very fast I get very poor scaling when I increase the number of facts for stateful or stateless sessions. I want to make sure I'm not doing something foolish before deciding on whether or not to use Drools because from what I am reading online it should be fast with the number of facts I have. The scenario: I have 1000 rules in a DRL file. They are all of the form: rule rule when Data(type == 0, value> 0.185264); Data(type == 3, value < 0.198202); then insert(new AlarmRaised(0)); warnings.setAlarm(0, true); end where the ranges checked on the values and the types are randomly generated. Then, I create a Stateful session and run in a loop timing how long it takes the engine to fire all rules as the number of inserted facts increases: // Run for(j=0; j < 100; j+=5) { if (j==0) { nfacts = 1; } else { nfacts = j; } System.out.println(nfacts + ":"); // Get a working memory StatefulSession wm = ruleBase.newStatefulSession(); // Global - output warnings = new Alarm(); wm.setGlobal("warnings", warnings); // Add facts st = (new Date()).getTime(); for(i=0; i < nfacts; i++) { wm.insert(new Data(rand.nextInt(4), rand.nextDouble()-0.5)); } en = (new Date()).getTime(); System.out.println("facts = " + (en-st)); // Now run the rules st = (new Date()).getTime(); wm.fireAllRules(); en = (new Date()).getTime(); System.out.println("rules = " + (en-st)); // Clean up wm.dispose(); System.out.println("\n"); } This code is based on the HelloWorldExampl