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

Fix dirtying of uncacheable nodes #17079

Merged
merged 2 commits into from
Oct 3, 2022

Conversation

stuhood
Copy link
Member

@stuhood stuhood commented Oct 1, 2022

As reported in #17060, the same @rule running within a single "session"/"run" of Pants was not correctly re-running due to changed inputs. The @rule is uncacheable (via its output type being EngineAwareReturnType.cacheable = False), for the purposes of a logging side-effect.

The @rule was failing to re-run due to a bug in the dirtying of uncacheable rules that had likely existed since #13199 split Node::restartable out from Node::cacheable. When the restartable property was introduced, it took over controlling whether a Node could be interrupted while running. But the Entry::dirty codepath was still incorrectly preventing uncacheable Nodes from being dirtied.

[ci skip-build-wheels]

@stuhood stuhood added the category:bugfix Bug fixes for released features label Oct 1, 2022
…pantsbuild#13199 behavior: now we stop dirtying at `!restartable` nodes instead.

[ci skip-build-wheels]
@stuhood stuhood force-pushed the stuhood/uncacheable-dirtying branch from dea2a17 to 52bf5a0 Compare October 1, 2022 04:14
@stuhood stuhood marked this pull request as ready for review October 1, 2022 05:19
@stuhood
Copy link
Member Author

stuhood commented Oct 1, 2022

While this bug has existed a while, it was only actually triggered for the first time by the lint/fmt changes on main, so I think we should skip cherry-picking it for now.

@stuhood stuhood enabled auto-merge (squash) October 1, 2022 05:24
@thejcannon
Copy link
Member

I was toying mentally with the idea of removing the uncacheability from the Result type, with the motivation being that users would be able to deduce which tools actually ran and which were cached. This makes it seem that if we removed the uncacheability we'd be looking again at the "bug". If that's true, then A) woah thats tricky, and B) I think #17060 should also be considered a bugfix for this issue (even though I changed the motivation for the change)

@stuhood
Copy link
Member Author

stuhood commented Oct 2, 2022

This makes it seem that if we removed the uncacheability we'd be looking again at the "bug". If that's true

That would not be true, no. Cacheable nodes have ~always been dirtied correctly: the bug was only that uncacheable nodes were not dirtied as well.

@stuhood
Copy link
Member Author

stuhood commented Oct 2, 2022

See https://github.com/pantsbuild/pants/tree/main/src/rust/engine/graph#invalidation for more information on the expected semantics.

@thejcannon
Copy link
Member

thejcannon commented Oct 2, 2022

Ah ok that makes sense. The fact that it is uncacheable, ironically made it cached. And if it wasn't uncacheable it wouldn't have been cached.

Copy link
Contributor

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -43,13 +43,18 @@ pub trait Node: Clone + Debug + Display + Eq + Hash + Send + 'static {
/// If a node's output is cacheable based solely on properties of the node, and not the output,
/// return true.
///
/// Nodes which are not cacheable will be recomputed once (at least, in case of dirtying) per
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Nodes which are not cacheable will be recomputed once (at least, in case of dirtying) per
/// Nodes which are not cacheable will be recomputed once (or, in case of dirtying, possibly more than once) per

Copy link
Member Author

Choose a reason for hiding this comment

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

Mm, yea: that would be clearer: will follow up. Thanks!

@stuhood stuhood merged commit ebcd741 into pantsbuild:main Oct 3, 2022
@stuhood stuhood deleted the stuhood/uncacheable-dirtying branch October 3, 2022 17:04
stuhood added a commit to stuhood/pants that referenced this pull request Oct 29, 2022
As reported in pantsbuild#17060, the same `@rule` running within a single "session"/"run" of Pants was not correctly re-running due to changed inputs. The `@rule` is uncacheable (via its output type being `EngineAwareReturnType.cacheable = False`), for the purposes of a logging side-effect.

The `@rule` was failing to re-run due to a bug in the dirtying of uncacheable rules that had likely existed since pantsbuild#13199 split `Node::restartable` out from `Node::cacheable`. When the `restartable` property was introduced, it took over controlling whether a Node could be interrupted while running. But the `Entry::dirty` codepath was still incorrectly preventing `uncacheable` `Node`s from being dirtied.

[ci skip-build-wheels]
stuhood added a commit that referenced this pull request Oct 31, 2022
As reported in #17060, the same `@rule` running within a single "session"/"run" of Pants was not correctly re-running due to changed inputs. The `@rule` is uncacheable (via its output type being `EngineAwareReturnType.cacheable = False`), for the purposes of a logging side-effect.

The `@rule` was failing to re-run due to a bug in the dirtying of uncacheable rules that had likely existed since #13199 split `Node::restartable` out from `Node::cacheable`. When the `restartable` property was introduced, it took over controlling whether a Node could be interrupted while running. But the `Entry::dirty` codepath was still incorrectly preventing `uncacheable` `Node`s from being dirtied.

Fixes #17377.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants