Performance implications of the precondition behavior
- Last Updated: June 9, 2021
- 1 minute read
- Corticon
- Version 7.2
- Documentation
A rule fires whenever data sharing the rule's scope exists that satisfies the rule's conditions. In other words, to fire any rule, the rule engine must first collect the data that shares the rule's scope, and then check if any of it satisfies the rule's conditions. So, even in a Rulesheet where no rules fire, the rules engine may have still needed to work hard to come to that conclusion. And, hard work requires time, even for a high-performance rules engine like Corticon.
A Filter expression acting only as a filter never stops Rulesheet execution; it limits the amount of data used in rule evaluations and firings. In other words, it reduces the set of data that is evaluated by the rule engine, but it does not actually stop the rule engine's evaluation of remaining rules. Even if a filter successfully filters out all data from a given data set, the rule engine still evaluates this empty set of data against the available remaining rules. Of course, no rules fire, but the evaluation process occurs and takes time.
Filter expressions also acting as preconditions change this. Now, if no data survives the filter (remember, Filter expressions always act as filters even when also acting as preconditions), then Rulesheet execution stops. No additional evaluations are performed by the rules engine. That Rulesheet is done, and the rules engine begins working on the next Rulesheet. This can save time and improve engine performance when the Rulesheet contains many additional rules that would have been evaluated were the expression in filter-only mode (the default mode).