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

Require that a target's interpreter_constraints are a subset of their dependencies' (Cherry-pick of #15373) #15407

Merged
merged 1 commit into from May 11, 2022

Conversation

stuhood
Copy link
Sponsor Member

@stuhood stuhood commented May 11, 2022

As described in #15241: we currently compute per-target interpreter constraints by doing per-target graph walks, which is both a scalability bottleneck (because you can almost never use the constraints directly on a target: you must compute them), and complex for users to reason about.

This change adds a ValidateDependenciesRequest union, which allows backends to validate the computed dependencies of a target. The python backend uses validation to deprecate the condition from #15241. When that deprecation triggers, most/all callsites which currently use create_from_compatibility_fields, create_from_targets, or the new compute_from_targets can instead directly consume the ICs of a root target in the graph.

This change also (temporarily) adds an InterpreterConstraints.compute_from_targets method which computes (in transitive-dependency-linear time) that the dependencies of a target have a superset of its own interpreter_constraints. This method allows us to (again, temporarily: see above) apply the optimization of avoiding set merging if targets are already valid.

Reduces the runtime of un-memoized-but-cached ./pants check :: by 10%.

Fixes #15241, fixes #15301, fixes #11072.

…ir dependencies' (pantsbuild#15373)

As described in pantsbuild#15241: we currently compute per-target interpreter constraints by doing per-target graph walks, which is both a scalability bottleneck (because you can almost never use the constraints directly on a target: you must compute them), and complex for users to reason about.

This change adds a `ValidateDependenciesRequest` union, which allows backends to validate the computed dependencies of a target. The python backend uses validation to deprecate the condition from pantsbuild#15241. When that deprecation triggers, most/all callsites which currently use `create_from_compatibility_fields`, `create_from_targets`, or the new `compute_from_targets` can instead directly consume the ICs of a root target in the graph.

This change also (temporarily) adds an `InterpreterConstraints.compute_from_targets` method which computes (in transitive-dependency-linear time) that the dependencies of a target have a superset of its own `interpreter_constraints`. This method allows us to (again, temporarily: see above) apply the optimization of avoiding set merging if targets are already valid. 

Reduces the runtime of un-memoized-but-cached `./pants check ::` by 10%.

Fixes pantsbuild#15241, fixes pantsbuild#15301, fixes pantsbuild#11072.
# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@stuhood stuhood merged commit 11f23f7 into pantsbuild:2.12.x May 11, 2022
@stuhood stuhood deleted the cherry-pick-15373-to-2.12.x branch May 11, 2022 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants