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

Implement target distance metrics #230

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

alex-torok
Copy link

@alex-torok alex-torok commented Sep 29, 2024

Add target distance metrics to measure how far away an impacted target is from a directly impacted target. I tried to keep the commits relatively concise, so reviewing them one-by-one from the beginning may be easier than looking at all of the changes at once.

Fixes #223

The new fields in TargetHash and TargetDigest are to track the direct srcs/attrs hash separately from the overall hash. Currently, the directHash is not used at all.
Add e2e test for dump distances

TODO: It would be nice if there was a better e2e test here -- Ask
Maxwell how he generates the integration workspace data.
@CLAassistant
Copy link

CLAassistant commented Sep 29, 2024

CLA assistant check
All committers have signed the CLA.

@alex-torok alex-torok changed the title Implement target distance metrics WIP: Implement target distance metrics Sep 29, 2024
@alex-torok alex-torok changed the title WIP: Implement target distance metrics Implement target distance metrics Sep 29, 2024
Copy link
Collaborator

@tinder-maxwellelliott tinder-maxwellelliott 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 so much for doing this, I am really excited to try this out

README.md Outdated Show resolved Hide resolved
Take a look at the following bazelcon talks to learn more about `bazel-diff`:

* [BazelCon 2023: Improving CI efficiency with Bazel querying and bazel-diff](https://www.youtube.com/watch?v=QYAbmE_1fSo)
* BazelCon 2024: Not Going the Distance: Filtering Tests by Build Graph Distance: Coming Soon
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

@@ -136,6 +136,14 @@ class GenerateHashesCommand : Callable<Int> {
)
var ignoredRuleHashingAttributes: Set<String> = emptySet()

@CommandLine.Option(
names = ["-d", "--depsFile"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should have a longer flag name here that is more descriptive?

Copy link
Author

Choose a reason for hiding this comment

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

I updated it to --depEdgesFile. Is that sufficient / do you have any other suggestions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That sounds good

1. Output detailed hash data as json
2. Use a different serialization format for targethashes to avoid
   ambiguity
@alex-torok
Copy link
Author

@tinder-maxwellelliott - I added a new E2E test that better showcases target / package distances with a new test workspace.

I don't think there is anything else I need to do here.

@alex-torok alex-torok force-pushed the add-direct-hash-to-rule-hasher branch from 8adcef4 to e8eef2a Compare October 5, 2024 15:50
Comment on lines 248 to 250
mapOf("label" to "//A:gen_two", "targetDistance" to 1.0, "packageDistance" to 0.0),
mapOf("label" to "//A:two.sh", "targetDistance" to 2.0, "packageDistance" to 0.0),
mapOf("label" to "//A:two", "targetDistance" to 3.0, "packageDistance" to 0.0),
Copy link
Author

@alex-torok alex-torok Oct 5, 2024

Choose a reason for hiding this comment

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

NOTE: GeneratedFiles contribute to targetDistance. I could see the argument for not doing that and instead having the code rewire the dependencies so that //A:two directly depends on //A:gen_two and the GeneratedFile doesn't contribute to targetDistance.

The odd behavior here is due to GeneratedFiles taking the hash of the target that generated them. I.e. - if A:gen_two is directly modified, so is A:two.sh, but if A:one is directly modified, A:two.sh has a target distance of 2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good

@alex-torok alex-torok force-pushed the add-direct-hash-to-rule-hasher branch from e8eef2a to a60e006 Compare October 5, 2024 15:52
@tinder-maxwellelliott
Copy link
Collaborator

@alex-torok There have been some changes in main for BCR support, once those are resolved I can merge this

@alex-torok
Copy link
Author

@tinder-maxwellelliott Let me know if there is anything else I can do to help land this.

@tinder-maxwellelliott
Copy link
Collaborator

@tinder-maxwellelliott Let me know if there is anything else I can do to help land this.

Looks like there are some test failures

cli/BUILD Outdated Show resolved Hide resolved
@alex-torok
Copy link
Author

I think I fixed it, but won't be able to run it locally and see until later today.

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.

Proposal: Add target distance metrics
3 participants