Optimization

To increase the efficiency of CTR programs, the prototype has implemented two optimizations:

     Backtracking Elimination
     Query Compilation


1.  During the execution of a concurrent transaction, the CTR interpreter tries all possible interleavings of the processes until one succeeds. This is also applicable to concurrent transactions which execute in isolation.
    In some instances, all interleavings produce the same result and backtracking is not necessary. This is the case, for instance, when the operations in concurrent processes commute. In such cases, only one interleaving should be tried.
    The first optimization implements an algorithm that eliminates needles backtracking during program execution. This is achieved by replacing the operator isolate with the operator isolate1,  which increases the execution efficiency by eliminating the search through other interleavings.
    Backtracking elimination is applied using an optimization command with the format:

        opt1_trans(program_name).

where program_name is the CTR program that is optimized.  Since the optimization uses as input the transaction-base object file, the program has to be compiled before optimization.


2.   The second optimization available with the prototype replaces certain CTR formulas with equivalent Prolog terms. After CTR programs are compiled and the elimination of backtracking takes place, the programs can be further optimized using the query compilation process.
    The only formulas that are translated, in some instances, are the ones executing queries in isolation, so the optimization is a query compilation. By translating CTR formulas into Prolog terms, which are executed more efficiently, the optimized programs have a better performance.
    Query compilation is performed using the following optimization command:

        opt2_trans(program_name).

where program_name is the CTR program that is optimized.  This optimization creates a transaction-base and a database optimized object files.