Sunday, February 24, 2008

RETE Nodes indexing in Drools

Michal Bali has written a short explanation on alpha and beta node indexing:
RETE Nodes indexing in Drools

1 comment:

  1. That write up is ok, but it doesn't capture the whole story.

    There's a bit more to it than that post. The basic principle of beta node hashing is to use the joins of the node to calculate the index. This means that an index join is performed whenever the node receives new facts from either side. There are cases where this style of indexing leads to slower performance than other designs. For example, if all the facts are similar and the join matches all facts from the opposite side, it ends up being slower than the design used by JESS.

    Since Drools and Jamocha both use the same basic design for beta node hashing, both exhibit this behavior. In that case, the fastest performance is to not Hash the memories. Luckily, most real world data tends to be pseudo-random, so it's only in limited cases that JESS style indexing is faster. For those cases, simply turning off the indexing in drools should result in better performance. The downside is that hashing is either on or off.

    I've been contemplating making it hashing a rule property in Jamocha. This way, some rules in the set have the hashing and some have it off. Making it a rule property would give the user greater level of control and produce more "tunable" performance.