Another way to improve RetePlus performance is to rely on Just-In-Time compilation of the rule condition part to bytecode.
The Java™ development environment has two parts: a Java compiler and a Java interpreter.
To take benefit of the JIT feature, you must meet the following prerequisites:
Add the bcel.jar file to your class path.
Grant Decision Server the permission to create a class loader. In certain environments, such as applet containers or Java EE containers, such permission might not be granted by default. In this case, the rule engine throws a security exception. To overcome this issue, use a Java security policy file or install a specific security manager.
Do not use the -noverify option. This option disables the Java bytecode verifier. As a consequence, if the generated bytecode is incorrect, the error is not detected when the bytecode is loaded at compile time and fails at run time. If you do not use the -noverify option, the bytecode verifier remains enabled and the RetePlus compiler manages errors correctly.
The Java compiler generates bytecode from your source files instead of generating machine code. The Java Virtual Machine (JVM) runs this bytecode. Each item of bytecode has a precise specification that defines exactly what it does to the virtual machine.
The Java interpreter examines each item in the bytecode stream of a method and, in turn, executes a unique action.
To translate a ruleset (an .irl file) in this manner, and subsequently speed up execution, you can use a dynamic translation or Just-In-Time (JIT) compilation for the RetePlus rule tasks. The JIT technology translates the condition part of each rule to Java bytecode. The bytecode is then used to evaluate the condition tests. JIT identifies the process of translating the ILOG® Rule Language (IRL) condition parts to Java bytecode. This dynamic bytecode generation is completely transparent to the application and can even be applied to rules that refer to dynamic classes.
To use the JIT feature, set the value of the ilog.rules.engine.useJIT property to true in one of the following two ways:
Use a configuration file (see Configuration resource) which must then be loaded to the engine.
Write the useJIT property in a ruleset header, as shown in the following example:
ruleset TestCase
{
property ilog.rules.engine.useJIT = true;
in int intvalue;
out int outvalue;
};
When the useJIT property is set to true, the rule engine uses dynamic rule compilation in its internal algorithm to evaluate rules. In terms of performance, the JIT feature makes interpreted rules execute at a similar speed as compiled rules.