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

Two targets can swap positions with pantsd (again) #7642

Merged
merged 2 commits into from
Apr 30, 2019

Conversation

illicitonion
Copy link
Contributor

Re-landing #7617 without slowing down the happy path of no cycles.

Before this PR, nothing would remove the edges of a dirty node, so if
two nodes swapped positions in the graph (e.g. if a dependency between
two targets inverted), a cycle would be detected.

With this PR, if we detect a cycle, but detect that there may be dirty
edges in play, we fully clear that node (including removing its edges),
which will cause it being re-triggered from scratch.

This is specifically in place to handle the cycle scenario - the dirty
bit, and dependency Generations are still the primary mechanism for
handling re-use of old versions.

There's an ugliness here that we still don't remove obsolete edges, so
if Generation 2 of a node has differing dependencies from Generation 1,
the dependency from Generation 1 will still dirty Generation 2. We may
want to consider solving that separately as/when it becomes a
significant issue, or we may want to re-work this PR to do something
like that... This PR happens to cover a part of that problem, but only
where it causes definitive problems (a fake cycle) rather than also
where it causes performance problems.

There's probably a slightly more principled solution here along the
lines of:

  • Rather than using () as an edge weight in the graph, use the
    Generation of the dependee Node as an edge weight.
  • When doing cycle detection, compare the edge weight against the
    generation of the node, and ignore obsolete edges.
    but I would want to think about that a lot more before doing it...

This re-landing optimises for the no cycle case, which is very strongly expected to be the common case in Pants, as cycles represent errors.

Perform the (cheaper) Dijkstra's algorithm before the (expensive) Bellman-Ford.

If there's no cycle, we don't do the expensive cycle reporting.
@illicitonion
Copy link
Contributor Author

Note that the commits are separately useful; the first is a pure revert, and the second is the modifications on what the old commit did.

Copy link
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.

Thank you!

@illicitonion illicitonion merged commit c823939 into pantsbuild:master Apr 30, 2019
@illicitonion illicitonion deleted the dwagnerhall/pantsd-swap branch April 30, 2019 15:52
stuhood added a commit that referenced this pull request Oct 29, 2019
#8422)

### Problem

See #5739: currently, rendering a cycle in the graph requires enabling `--print-exception-stacktrace`. But `--print-exception-stacktrace` is annoying for end users.

### Solution

Use the cyclic path that @illicitonion added in #7642 to render an error directly. And in a separate commit, remove `EntryKey`, which was only used for "recording" cycles in the `Graph`... from an era where we actually looked at the complete dump of the runtime graph, I think?

### Result

`--print-exception-stacktrace` is no longer necessary to see the "path" involved in a cycle. Fixes #5739.
wisechengyi pushed a commit that referenced this pull request Nov 1, 2019
#8422)

### Problem

See #5739: currently, rendering a cycle in the graph requires enabling `--print-exception-stacktrace`. But `--print-exception-stacktrace` is annoying for end users.

### Solution

Use the cyclic path that @illicitonion added in #7642 to render an error directly. And in a separate commit, remove `EntryKey`, which was only used for "recording" cycles in the `Graph`... from an era where we actually looked at the complete dump of the runtime graph, I think?

### Result

`--print-exception-stacktrace` is no longer necessary to see the "path" involved in a cycle. Fixes #5739.
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.

2 participants