Skip to content

Introduce conditional planner rules (ConditionalCascadesRule)#4332

Open
RobertBrunel wants to merge 1 commit into
FoundationDB:mainfrom
RobertBrunel:conditional-1
Open

Introduce conditional planner rules (ConditionalCascadesRule)#4332
RobertBrunel wants to merge 1 commit into
FoundationDB:mainfrom
RobertBrunel:conditional-1

Conversation

@RobertBrunel

Copy link
Copy Markdown
Contributor

A conditional rule bundles an ordered list of inner rules. It acts as one rule that receives special treatment by the planner. The inner rules are tried in order, stopping as soon as one rule yielded a new expression and falling through to the next rule only when the current on made no progress. In other words, each inner rule runs only under the “condition” that no prior rule made any progress. In effect, only the first useful rule is applied.

The motivation behind this is that, by carefully grouping strictly prioritized or mutually exclusive transformations this way, we can substantially prune the planner search space and reduce the memo size.

This change adds only the ConditionalCascadesRule abstraction and the necessary planner plumbing to dispatch such rules. It is not added to any rule set.

  • Add a new ConditionalCascadesRule class, as well as ConditionalExplorationCascadesRule and ConditionalImplementationCascadesRule subclasses.
  • Add a corresponding ConditionalTransformExpression task that implements the mechanism of trying the rules in the conditional chain one at a time.
  • Change all Task.execute() implementations to return a boolean signaling whether the task made progress.
  • Propagate that boolean through executeRuleCall() so the surrounding Transform task can report whether any change to the planner state was made.

@RobertBrunel RobertBrunel self-assigned this Jul 10, 2026
@RobertBrunel RobertBrunel added the enhancement New feature or request label Jul 10, 2026

@Override
public boolean execute() {
if (super.execute()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also take into account shouldExecute() here, and immediately prune all the inner rules if false?

if (!shouldExecute()) {
  return false;
}

A conditional rule bundles an ordered list of inner rules. It acts as one rule that receives special treatment by the planner. The inner rules are tried in order, stopping as soon as one rule yielded a new expression and falling through to the next rule only when the current on made no progress. In other words, each inner rule runs only under the “condition” that no prior rule made any progress. In effect, only the _first_ useful rule is applied.

The motivation behind this is that, by carefully grouping strictly prioritized or mutually exclusive transformations this way, we can substantially prune the planner search space and reduce the memo size.

This change adds only the `ConditionalCascadesRule` abstraction and the necessary planner plumbing to dispatch such rules. It is not added to any rule set.

* Add a new `ConditionalCascadesRule` class, as well as `ConditionalExplorationCascadesRule` and `ConditionalImplementationCascadesRule` subclasses.
* Add a corresponding `ConditionalTransformExpression` task that implements the mechanism of trying the rules in the conditional chain one at a time.
* Change all `Task.execute()` implementations to return a boolean signaling whether the task made progress.
* Propagate that boolean through `executeRuleCall()` so the surrounding `Transform` task can report whether any change to the planner state was made.

Co-authored-by: Normen Seemann <nseemann@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant