List Info

Thread: Will the alternative lead to a better performance?




Will the alternative lead to a better performance?
user name
2007-03-23 13:10:42
Hi,

Consider that I have 500 instances of interface userI. Now, there are 3000 rules currently written based on a combination of these instances.

if {
     $a : userI (name = "A")
     $b : userI (name = "B")
}
then
{
 //do some actions
}

How many tests are needed for a match in the RETE network for this rule?

If I created 500 classes, one for each object, such as UserA implements userI and so on... my rule will look like:

if {
     $a : UserA()
     $b : UserB()
}
then
{
 //do some actions
}

Will this lead to better performance since there will only be one such instance of this object?

As for class-loading concerns, will there be a parsing/memory penalty to be paid for having 500 classes now instead of one?

Thanks!
Re: Will the alternative lead to a better performance?
country flaguser name
United States
2007-03-23 13:24:38
 
   Stephen,

   As long as you use an "==" constraint as your
example shows, the 
first alternative will be more performatic. This is because
drools 
indexes facts based on your constraints. So, your first case
will 
require a single "==" comparison to find user name
"A" and a single 
comparison to find user name "B". Of course, if
you have huge amound of 
objects where hashcode for name start to clash, you may have
more than 
one comparison, but the effect is negligible when compared
to all other 
costs of having that many facts.

   Second alternative works and will also hash object types,
but it will 
create a lot more infrastructure classes and Rete Nodes to
deal with 
your 500 different classes. So it is a worst alternative for
the 
proposed scenario.

   []s
   Edson


Premkrishna Stephen wrote:

> Hi,
>
> Consider that I have 500 instances of interface userI.
Now, there are 
> 3000 rules currently written based on a combination of
these instances.
>
> if {
>      $a : userI (name = "A")
>      $b : userI (name = "B")
> }
> then
> {
>  //do some actions
> }
>
> How many tests are needed for a match in the RETE
network for this rule?
>
> If I created 500 classes, one for each object, such as
UserA 
> implements userI and so on... my rule will look like:
>
> if {
>      $a : UserA()
>      $b : UserB()
> }
> then
> {
>  //do some actions
> }
>
> Will this lead to better performance since there will
only be one such 
> instance of this object?
>
> As for class-loading concerns, will there be a
parsing/memory penalty 
> to be paid for having 500 classes now instead of one?
>
> Thanks!
>
>--------------------------------------------------------
----------------
>
>_______________________________________________
>rules-users mailing list
>rules-userslists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat  www.jboss.com


_______________________________________________
rules-users mailing list
rules-userslists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )