[rules-users] Drools 4 poor performance scaling?
Ron Kneusel
oneelkruns at hotmail.com
Mon Jun 30 17:04:53 EDT 2008
A small update. I ran the example below starting with 90 rules and running down to 1. The execution time remains the same so I don't think the problem has to do with something left over from the previous call to fireAllRules(). This really should be a simple example and I am still at a loss as to why it doesn't work quickly.
Again, any help appreciated!
Ron
----------------------------------------
>> -----Original Message-----
>> From: rules-users-bounces at lists.jboss.org
>> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Ron Kneusel
>> Sent: Thursday, June 26, 2008 12:47 PM
>> To: rules-users at 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 rule0000
>> 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 HelloWorldExample.java code from the manual
>> and the setup for the rule base is the same as in the manual. As the
>> number of facts increases runtime increases dramatically:
>>
>> facts -- runtime (ms)
>> 10 -- 168
>> 20 -- 166
>> 30 -- 344
>> 40 -- 587
>> 50 -- 1215
>> 60 -- 1931
>> 70 -- 2262
>> 80 -- 3000
>> 90 -- 4754
>>
>> with a maximum memory use of about 428 MB RAM. By contrast, if I use
>> sequential stateless sessions, everything runs in about 1-5 ms.
>>
>> Is there something in my set up that would cause this, or is this how
>> one would expect Drools to scale? I read about people using thousands
>
>> of facts so I suspect I'm setting something up incorrectly.
>>
>> Any help appreciated!
>>
>> Ron
_________________________________________________________________
Need to know now? Get instant answers with Windows Live Messenger.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_062008
More information about the rules-users
mailing list