Closed aalexandrov closed 7 years ago
Actually we could use a somewhat hacky solution to bring the separate hierarchies together. Since Scala's Constant(Literal(_))
is polymorphic we could wrap the comprehension nodes in constants and then use a modified form of traversal that works on union types (or possibly do 2 passes - one for Scala nodes and one for Emma nodes).
I think we can close this now
Alright. I've linked the issue on the wiki for future reference.
This is a meta-issue that should track the planned changes in the IR.
Throughout the discussion in this issue, we will use the following schema based on the
MostConsistentClassifier
workflow:Motivation
Most of the transformation-based optimizations in Emma can only be applied if certain conditions apply. Deciding whether the conditions are satisfied typically involves some form of dataflow analysis on top of lifted code.
Example: Fold-Group Fusion
Consider the following code that produces two aggregates over the
emails
grouped by theirip
value:The code is eligible to fold-group fusion (FGF) as all
g.values
uses appear within the context of chain of (zero or more)map
applications ending in afold
.While (FGF) of the variation above works at the moment, the following variations will not be considered eligible, as at the moment there is no direct and simple way to consider constant propagation in the Scala expressions referenced in comprehended terms:
Example: Join Ordering
Another scenario where a better IR might be beneficial is join ordering. Consider the following code
In order to reduce the amount of communication cost when this expression is compiled to a join cascade, we might want to apply
x1
right after we joine
ands
, prune all extra fields, and only after that join withr
.In effect, this means that the head expressions is split into multiple parts and parts of it might be applied on top of a
rhs
of aggregator during thecombinator
rewrite phase.Approach
In order to make the compiler oblivious to such code modifications, I propose to extend the current comprhension IR in the following strategy.
emma-examples
. Lift, normalize, and transform the whole quoted three rather than only the comprehended expressions.use-def
anddef-use
chains. A good candidate seems to be direct style in let-normal form for a good overview and a short introduction to this IR, please refer to Chapter 6 in the SSA Book.Refactoring Plan
The refactoring of the code should be based on the following refactoring plan. Each item will be tracked by a separate issue:
emma.ir