|
1 | 1 | /** |
2 | 2 | * INTERNAL: Do not use. |
3 | 3 | * |
4 | | - * The purpose of this file is to reduce the number of stages computed by the runtime, |
5 | | - * thereby speeding up the evaluation without affecting any results. |
| 4 | + * The purpose of this file is to control which cached predicates belong to the same stage. |
6 | 5 | * |
7 | | - * Computing less stages can improve performance as each stages is less likely to recompute non-cached predicates. |
| 6 | + * Combining stages can improve performance as we are more likely to reuse shared, non-cached predicates. |
8 | 7 | * |
9 | 8 | * A number of stages are grouped into an extended stage. |
10 | 9 | * An extended stage contains a number of substages - corrosponding to to how the stages would be grouped if this file didn't exist. |
11 | 10 | * Each extended stage is identified by a `cached module` in the `ExtendedStaging` module. |
12 | 11 | * |
13 | | - * The number of stages are reduced by using how the compiler groups predicates into stages. |
14 | | - * The compiler will group mutually recursive cached predicates, or cached predicates within the same `cached module`, into the same stage. |
15 | | - * This file uses the latter by creating a `cached module` with two predicates for each extended stage. |
16 | | - * The first predicate is referenced from all the `cached` predicates we want in the same extended stage, |
17 | | - * and the second predicate has references to all the `cached` predicates we want in the same extended stage. |
| 12 | +* To make a predicate `p` belong to a stage `A`: |
| 13 | +* - make `p` depend on `A::ref()`, and |
| 14 | +* - make `A::backref()` depend on `p`. |
| 15 | +* |
| 16 | +* Since `A` is a cached module, `ref` and `backref` must be in the same stage, and the dependency |
| 17 | +* chain above thus forces `p` to be in that stage as well. |
18 | 18 | * |
19 | 19 | * With these two predicates in a `cached module` we ensure that all substages will be in a single stage at runtime. |
20 | 20 | * |
|
0 commit comments