Skip to content
This repository has been archived by the owner on Mar 12, 2018. It is now read-only.

[Vortex-29] Configurable optimizer #53

Merged
merged 9 commits into from
Mar 7, 2017
Merged

Conversation

wonook
Copy link
Contributor

@wonook wonook commented Mar 6, 2017

This PR:

  • Makes the optimizer configurable
  • Introduce instantiation policy.
    • Composed of a list of passes.
    • Each pass traverses the DAG to tag each operators/edges with attributes.
  • Two policies available for now: Pado and Disaggregation
  • Introduce Pair class as a util.

Resolves #29

@jooykim jooykim changed the title 29 configurable optimizer [Vortex-29] Configurable optimizer Mar 6, 2017
public final class DisaggregationPass implements Pass {
public DAG process(final DAG dag) throws Exception {
dag.doTopological(operator -> {
final Optional<List<Edge>> inEdges = dag.getInEdgesOf(operator);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out!

* It runs a list of passes sequentially to optimize the DAG.
*/
private static final class Policy {
private final Iterator<Pass> passes;
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using a List instead? Then maybe we can use lambdas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can lambdas throw exceptions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so. (http://stackoverflow.com/questions/37726874/why-cant-i-throw-an-exception-in-a-java-8-lambda-expression)
If exception handling is needed, using a simple foreach loop might be a good option.

}
});
private DAG process(final DAG dag) throws Exception {
DAG optimizedDAG = passes.next().process(dag);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentionally placed outside the while loop to throw a NoSuchElementException, when passes is empty?
If so, how about instead we proactively check for that and also check whether passes is actually null in L35?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll fix this point

@johnyangk
Copy link
Contributor

LGTM. Left some minor comments.

Copy link
Contributor

@johnyangk johnyangk left a comment

Choose a reason for hiding this comment

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

LGTM

@johnyangk johnyangk merged commit dbcac35 into master Mar 7, 2017
@wonook wonook deleted the 29-ConfigurableOptimizer branch March 7, 2017 09:45
@bgchun
Copy link

bgchun commented Mar 8, 2017

Can one transform the DAG (e.g., change the graph structure) in a pass? If not, what API should the optimizer provide?

@wonook
Copy link
Contributor Author

wonook commented Mar 8, 2017

@bgchun Yes, we can. A Pass class has an interface of:

public interface Pass {
  DAG process(final DAG dag) throws Exception;
}

which returns an optimized DAG, after receiving and processing an input DAG.
If we build a new DAG inside a pass, it is possible to change the graph structure using a Pass. Currently, we only have examples where a pass simply tags each operators/edges with attributes, but it is possible.

@bgchun
Copy link

bgchun commented Mar 8, 2017

Good. Do we have examples?

@wonook
Copy link
Contributor Author

wonook commented Mar 8, 2017

@bgchun Not currently, but I will address this with #56

wonook added a commit that referenced this pull request Feb 28, 2018
- Makes the optimizer configurable
  - Receiving the policy as a parameter is left as an issue #52
- Introduce instantiation `policy`.
  - Composed of a list of `pass`es.
  - Each pass traverses the DAG to tag each operators/edges with attributes.
- Two policies available for now: `Pado` and `Disaggregation`
- Introduce `Pair` class as a util.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants