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

bazel: more hygenic build deps #31013

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

ParkMyCar
Copy link
Member

@ParkMyCar ParkMyCar commented Jan 12, 2025

This PR changes our Bazel build so the dependencies we use in build scripts are more hygenic. Specifically, it moves the codegen module from the ore crate into a new ore-build crate, and tweaks our generated BUILD.bazel files.

Bazel builds a Cargo Build Script, and it's dependencies, in the exec configuration which is the config for the host currently running the build. So when a crate is used in a build script it generally gets built twice, once for the platform the build is targeting, and once for the host running the build. Previously we were using the ore crate in a few build scripts, which results in ore and all of it's dependencies being build twice. With remote caching this isn't too bad, but it resulted in unnecessary fetching from S3, and when ore is changed, unnecessary re-building.

When building environmentd, clusterd, and balancerd at the same time, the number of Bazel actions is reduced from 4,692 to 3,947.

Motivation

Faster builds

Tips for reviewers

Just review the first commit, the second is just the changes from running bin/bazel gen

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@ParkMyCar ParkMyCar force-pushed the bazel/hygenic-build-deps branch from 669418e to 1047c1f Compare January 13, 2025 00:35
@ParkMyCar ParkMyCar marked this pull request as ready for review January 13, 2025 01:08
@ParkMyCar ParkMyCar requested review from a team, aljoscha, jkosh44, teskje and benesch as code owners January 13, 2025 01:08
Copy link
Contributor

@def- def- left a comment

Choose a reason for hiding this comment

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

No complaints from QA side, but I don't know enough about Rust building to fully approve,

Copy link
Contributor

@aljoscha aljoscha left a comment

Choose a reason for hiding this comment

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

🙌

* move 'codegen' module from 'mz-ore' to a new 'mz-ore-build' crate
* update cargo-gazelle so it only provide build dependencies to build scripts
@ParkMyCar ParkMyCar force-pushed the bazel/hygenic-build-deps branch from 1047c1f to 75807ee Compare January 13, 2025 13:59
@ParkMyCar ParkMyCar enabled auto-merge (squash) January 13, 2025 13:59
@ParkMyCar ParkMyCar merged commit ffaf116 into MaterializeInc:main Jan 13, 2025
86 checks passed
@ParkMyCar ParkMyCar deleted the bazel/hygenic-build-deps branch January 17, 2025 15:56
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.

4 participants