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

Merged

Conversation

alex-torok
Copy link
Contributor

@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.

❤️

1. Output detailed hash data as json
2. Use a different serialization format for targethashes to avoid
   ambiguity
@alex-torok
Copy link
Contributor 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
@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
Contributor 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
Contributor Author

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

@alex-torok
Copy link
Contributor Author

@tinder-maxwellelliott - should be passing now (at least it is on my machine)

@tinder-maxwellelliott tinder-maxwellelliott merged commit 43ac136 into Tinder:master Oct 15, 2024
8 checks passed
@erikkerber
Copy link

I don't know if it was an intentional side-effect, but the format changes mean hashes generated pre-8.0.1 will fail parsing on 8.0.1+. We noticed since we store digests per commit on CI to speed everything up.

It's pretty transient on our part because we fall back to no work avoidance when bazel-diff fails, but others might be a little surprised.

@honnix
Copy link
Contributor

honnix commented Oct 24, 2024

I don't know if it was an intentional side-effect, but the format changes mean hashes generated pre-8.0.1 will fail parsing on 8.0.1+. We noticed since we store digests per commit on CI to speed everything up.

It's pretty transient on our part because we fall back to no work avoidance when bazel-diff fails, but others might be a little surprised.

We are having the same problem. This change is indeed surprising. I'm wondering what could be a migration path.

@alex-torok
Copy link
Contributor Author

This PR changed how hashes are calculated -- you'll get a different hash value for an old commit on the new version of bazel-diff compared to the old version of bazel-diff.

If you version bazel-diff outside of your repo (i.e use a new version of bazel-diff for calculate-hashes on older commits), then you'd hit cache consistency issues. Versioning it in the repo would just mean that when you bump it, you'd create an 'all targets changed' commit.

If you want the backwards compatibility, you'd need to update the TargetHash parsing to work when reading old hash values - https://github.com/alex-torok/bazel-diff/blob/50b1609cb7ec9db2050bad00e518d6abad3b82dd/cli/src/main/kotlin/com/bazel_diff/hash/TargetHash.kt#L37-L40

We discussed this, but I think I just missed getting it in with a testcase.

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
5 participants