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

[engine] Split SelectDependencies into SelectDependencies and SelectTransitive #4334

Merged
merged 23 commits into from Mar 15, 2017

Conversation

peiyuwang
Copy link
Contributor

Problem

This is a refactoring change with no functionalities added. it will simplify #4283 so we could optimize just for SelectTransitive.

Solution

Introduce SelectTransitive with identical attributes with SelectDependencies (for now), and split the if else switch in node handling into each node. With that, transitive flag is not needed.

Result

Test all passes.

Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks Peiyu... looks good!

@@ -121,13 +120,26 @@ def __repr__(self):
field_name_portion = ', {}'.format(repr(self.field))
else:
field_name_portion = ''
return '{}({}, {}{}{}{})'.format(type(self).__name__,
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I don't think this overridden repr is still used anywhere... may be able to remove it.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Oh, correction... it's used only in unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea

field_types_portion)


class SelectTransitive(datatype('Dependencies', ['product', 'dep_product', 'field', 'field_types']),
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

s/Dependencies/Transitive/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed.

}

fn store(&self, dep_product: &Value, dep_values: Vec<&Value>) -> Value {
// Not an inner node, or not a traversal.
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Comment is probably stale. But also, you can probably just inline this into the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inlined.

@stuhood stuhood merged commit 2d7a690 into pantsbuild:master Mar 15, 2017
peiyuwang added a commit that referenced this pull request Mar 22, 2017
…esses within SelectTransitive (#4349)

### Problem

As described in #4283, the issue with recursively executing `SelectTransitive` is lots of calls to `store_list` creating massive intermediate lists that increases memory footprint as well as impacts perf.

### Solution

Same idea as in #4265 using `loop_fn` rewrite `SelectTransitive` to execute iteratively. One small difference is in order to use `OrderMap` and `HashSet` for state tracking and outputs are in `Value`s, those `Values` are turned into `Key`s.

ps: previous PR #4334 paved way for this optimization by splitting `SelectTransitive` from `SelectDependencies(...transitive=true)`.

### Result

All existing tests pass. Have verified there is only one `ST` node through viz.

Two follow up items
* #4358 reenable cycle detection
* #3925 Remove BFA now not only is a clean up task, but has performance benefits because the second round hydration is on `Address` which is redundant.
@peiyuwang peiyuwang deleted the peiyu/split-select-dependencies branch March 22, 2017 04:30
lenucksi pushed a commit to lenucksi/pants that referenced this pull request Apr 25, 2017
…ransitive (pantsbuild#4334)

### Problem

This is a refactoring change with no functionalities added. it will simplify pantsbuild#4283 so we could optimize just for `SelectTransitive`.

### Solution

Introduce `SelectTransitive` with identical attributes with `SelectDependencies` (for now), and split the `if` `else` switch in node handling into each node. With that, `transitive` flag is not needed.

### Result

Test all passes.
lenucksi pushed a commit to lenucksi/pants that referenced this pull request Apr 25, 2017
…esses within SelectTransitive (pantsbuild#4349)

### Problem

As described in pantsbuild#4283, the issue with recursively executing `SelectTransitive` is lots of calls to `store_list` creating massive intermediate lists that increases memory footprint as well as impacts perf.

### Solution

Same idea as in pantsbuild#4265 using `loop_fn` rewrite `SelectTransitive` to execute iteratively. One small difference is in order to use `OrderMap` and `HashSet` for state tracking and outputs are in `Value`s, those `Values` are turned into `Key`s.

ps: previous PR pantsbuild#4334 paved way for this optimization by splitting `SelectTransitive` from `SelectDependencies(...transitive=true)`.

### Result

All existing tests pass. Have verified there is only one `ST` node through viz.

Two follow up items
* pantsbuild#4358 reenable cycle detection
* pantsbuild#3925 Remove BFA now not only is a clean up task, but has performance benefits because the second round hydration is on `Address` which is redundant.
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.

None yet

3 participants