Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply lists of rules recursively #570

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jingjingwang
Copy link
Contributor

An algebra was defined as a list of lists of rules but then got flattened. This limits recursive optimizations that consist of multiple rules, for example, PushApply + RemoveUnusedColumn were repeated twice, which still produces redundant columns if the query contains more than two joins. This PR removes the flattening and applied a list of rules recursively until no change. It fixes the PushApply + RemoveUnusedColumn problem and also several bugs disclosed by this change.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 9ed2b5a on recursively_apply_rules_as_list into ** on master**.

Copy link
Contributor

@senderista senderista left a comment

Choose a reason for hiding this comment

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

mostly questions :)

@@ -1731,6 +1732,8 @@ def insert_split_before_heavy(self, op):
encounter a heavyweight operator."""
if isinstance(op, MyriaAlgebra.fragment_leaves):
return op
if isinstance(op, algebra.Split):
Copy link
Contributor

Choose a reason for hiding this comment

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

was this a bug?

@@ -1524,7 +1524,8 @@ def add_hyper_shuffle():
if not isinstance(expr, algebra.NaryJoin):
return expr
# check if HC shuffle has been placed before
shuffled_child = [isinstance(op, algebra.HyperCubeShuffle)
shuffled_child = [isinstance(op, algebra.HyperCubeShuffle) or
isinstance(op, algebra.OrderBy)
Copy link
Contributor

Choose a reason for hiding this comment

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

was this a bug?

Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this only happen if OrderByBeforeNaryJoin was somehow applied before HCShuffleBeforeNaryJoin?

@@ -1638,7 +1638,7 @@ def __init__(self, array_rep, memory_scan_class=GrappaMemoryScan):

def fire(self, expr):
if isinstance(expr, algebra.Scan) \
and not isinstance(expr, GrappaFileScan):
and not isinstance(expr, cppcommon.CBaseFileScan):
Copy link
Contributor

Choose a reason for hiding this comment

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

was this a bug?

@@ -2314,6 +2314,8 @@ class GrappaWhileCondition(rules.Rule):
result of the condition table"""

def fire(self, expr):
if isinstance(expr, GrappaDoWhile):
Copy link
Contributor

Choose a reason for hiding this comment

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

was this a bug?

expr = recursiverule(expr)

for rules in rules_lists:
for i in range(20):
Copy link
Contributor

Choose a reason for hiding this comment

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

If this lands in an infinite recursion, it'll blow the python stack soon enough, right? Do we really need an explicit cutoff?

@@ -847,9 +833,6 @@ def __str__(self):
# For now, run twice and finish with PushApply.
Copy link
Contributor

Choose a reason for hiding this comment

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

remove obsolete comment

accessed = sorted(set(itertools.chain(*(accessed_columns(e)
for e in emits))))
new_cols = [child.output_columns[p] for p in accessed]
Copy link
Contributor

Choose a reason for hiding this comment

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

could you explain why you removed all this code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants