[rules-users] optimization on a lot of simple rules
nesta
nesta.fdb at 163.com
Mon Jul 20 00:15:53 EDT 2009
Because only one Decision instance is in working memory, so I change the
rule, and make Decision as global, not a fact. The rule is changed as
follows:
global Decision decision;
rule 1
when
Product( id ==1, usage == 1)
then
$decision.setValue(1);
end
.....
Scenario:
1000 rules
1000 times execution
The result shows it improves a lot. The previous rulesets spend more than
100ms, but this time they spend only 10ms.
So I guess that more time is cost in JoinNode ( between Product and Decision
). Is it reasonable?
dave sinclair wrote:
>
> This particular example will benefit from node sharing for the usage
> attribute and indexing of the id attribute on Product. If you are seeing
> something different, please post your results.
>
> On Sun, Jul 19, 2009 at 9:15 AM, nesta <nesta.fdb at 163.com> wrote:
>
>>
>> Hi,
>>
>> I am a newbie in drools. There are a lot of simple rules in a scenario.
>> For example
>> rule 1
>> when
>> Product( id ==1, usage == 1)
>> $decision : Decision()
>> then
>> $decision.setValue(1);
>> end
>>
>> rule 2
>> when Product( id ==2, usage == 1)
>> $decision : Decision()
>> rule 3
>> when Product( id ==3, usage == 1)
>> $decision : Decision()
>> rule 4
>> when Product( id ==4, usage == 1)
>> $decision : Decision()
>> rule 5
>> when Product( id ==5, usage == 1)
>> $decision : Decision()
>> ......
>>
>> I have a Product fact whose id = 5 and usage = 1, in my first thinking,
>> only
>> rule 5 is matched, there should be not much more different between 1 rule
>> and a lot of rules in runtime.
>>
>> But the result shows that they are different. More rules will cost more
>> time. If there are 1 thousand rules, some Node and Sink will execute 1
>> thousand times.
>>
>> My question is how to optimize this scenario?
>> --
>> View this message in context:
>> http://www.nabble.com/optimization-on-a-lot-of-simple-rules-tp24556724p24556724.html
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/optimization-on-a-lot-of-simple-rules-tp24556724p24563706.html
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list