-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: master
Are you sure you want to change the base?
Conversation
Changes Unknown when pulling 9ed2b5a on recursively_apply_rules_as_list into ** on master**. |
There was a problem hiding this 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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this a bug?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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?
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.