After having a baseline for the Rule Designer ready, now it is time for performance optimization for the next release (R6). In recent weeks, I started working on performance optimization of FlexRule. One of the issues you may face using any Business Rule Engine is performance.

The goal for R6 is performance improvement, but what makes our goal very challenging to achieve is that we already had a huge performance improvement in version 1.4 for different engines as follows: 1) Procedural and Inference, 2) Interlink procedures and 3) RuleFlow.

To measure the performance (as our reference), I used the sample for an invoice application which comes with the FlexRule framework installer. I had to change the code a bit to add a Stopwatch to the execution method of the code in order to measure the execution time.
In this particular application, for each request (pressing GO button) we executed 3 rules. Therefore each value (in milliseconds) is the amount of time spent to execute three rules and return the values back to the application context.
The results for three different groups are as follows:

  1. FlexRule version 1.2 and blow – R2 and R3
  2. FlexRule version 1.4 to 1.5 (So far 1.5.5 is the latest version) – R4 and R5
  3. The new version 1.X.6 (Release 6) – R6

The performance improvement falls into two general areas for us:

  1. Execution of a rule for first time
  2. Re-executing the same rule

Procedural Engine:

The basic concept behind the procedural engine is that each procedure can have some input and output parameters, and also that they can get executed by passing the input parameters. At the end of the execution the output parameters will have the values to be collected from the execution context. The procedure parameters can be standard CLR types as well as your own custom types. This is the engine to execute procedural logic, such as If-Then-Else, Formula Calculations, Loop and While. The rule procedure can manipulate object properties, execute methods from CLR types and more.

In release R4, we had managed to improve the performance for the first execution more than 50%, and in recent improvements for R6 we managed to improve it 27% more so far. In recent improvements we now have 54ms for the first execution time which was originally 198ms in R4/R5 and had been 396ms in R2/R3.

After first execution of the rule in R2/R3, we measured performance for re-executing rules at 207ms, which became 9ms in the current release (R4 and R5). We have managed to improve it to 6.5ms so far.

proc

Execution of three rules using procedural engine

 

Interlink Rules:

 

Regarding interlink rules – in FlexRule this refers to the rules that execute the other rules. This means the execution of the entire procedure inside a hosted rule. The root (hosted) rule is now responsible for loading the linked rule from the provided source, creating the rule model, activating the model, and creating or sharing the execution context, as well as executing the linked rule.

 

We have achieved the following results for interlink rules on the first execution – in R2/R3 to R4/R5 we reduced it from 445ms to 110ms. For re-execution of the rules, we reduced it from 256.6ms to 61.6ms.

 

The good news about the new release is that we have had an incredible improvement in both areas. The first time execution has been reduced to 70ms and re-execution to 9.8ms.

inter
Execution of three rules using procedural engine and inter link rules

 

Rule Flow:

 

Regarding the scenarios that the execution of multiple rules needs to manage, Rule Flow Engine is a good choice. It provides the rules to be executed based on a flow and logic that is responsible for executing the underlying rules (In this case we have used a procedural engine) based on the implemented logic.

 

We have had poor performances in R2 and R3 for the first-time execution of flows at 1027ms and 1192.3ms for the re-execution of flow. We improved it significantly in R4 and R5 by reducing it to 340ms for first time execution and 271.0ms for re-execution.

 

The other good news is that we have managed to improve the rule flow engine a lot. We reduced first time execution to 255ms and 29.8ms for re-execution of the flow in R6.

flow
Execution of three rules using procedural embedded into a flow engine

 

All of the above mentioned results were measured on my Dell laptop with the following specifications:

OS: Windows 7 (32 bit)
RAM: 4 GB
Processor: Intel Core 2 Due 2.50 GHz

The results so far are shown in the chart below and I am hoping I still can improve it for this release, but I am happy with the achievements so far.

r6
Execution of three rules for “Invoice Sample” using FlexRule R6

 

 

 

 

 

Last updated September 22nd, 2020 at 11:39 am, Published October 2nd, 2011 at 11:39 am