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

Projects
None yet
2 participants
@illicitonion
Copy link
Contributor

commented Apr 30, 2019

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.

illicitonion added some commits Apr 30, 2019

Optimise cycle detection for the no-cycle case
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 illicitonion requested review from stuhood and cosmicexplorer Apr 30, 2019

@illicitonion

This comment has been minimized.

Copy link
Contributor Author

commented Apr 30, 2019

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.

@stuhood
Copy link
Member

left a comment

Thank you!

@illicitonion illicitonion merged commit c823939 into pantsbuild:master Apr 30, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@illicitonion illicitonion deleted the twitter:dwagnerhall/pantsd-swap branch Apr 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.