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

Store build artifacts per architecture #1630

Merged
merged 1 commit into from
Jun 29, 2021

Conversation

tjkirch
Copy link
Contributor

@tjkirch tjkirch commented Jun 24, 2021

Description of changes:

Previously, switching between architectures would rebuild all artifacts, which
can make building and testing changes painful.

This change makes cargo and buildsys store their state in arch-specific
directories, so when you switch, they can find the last artifacts they built
for that arch.

Note because it originally confused me: we don't need to change anything about the RPM builds or the Rust/cargo used inside package builds, because the cache mount used in package builds is already arch-specific.

Testing done:

There's a relatively high blast radius for relatively few lines of code, so let me know if you can think of other tests to run.

  • Build x86_64 aws-k8s-1.20 from scratch. Confirm health.
  • Check build/state/; here's an example of a marker for a package and for a variant artifact.
   662017      0 -rw-r--r--   1 tjk      tjk             0 Jun 24 09:56 x86_64/packages/grep/bottlerocket-x86_64-grep-debugsource-3.6-1.x86_64.rpm.buildsys_marker
   923063      0 -rw-r--r--   1 tjk      tjk             0 Jun 24 10:10 x86_64/variants/aws-k8s-1.20/bottlerocket-aws-k8s-1.20-x86_64-1.1.2-18c6be33-root.verity.lz4.buildsys_marker
  • Build x86_64 again. Artifacts are reused, build is fast. (Only variant artifact state is changed, no packages.) Confirm health.
  • Build aarch64 from scratch. Confirm health.
  • Check build/state; x86 state isn't touched. Example ARM markers:
   923418      0 -rw-r--r--   1 tjk      tjk             0 Jun 24 10:20 aarch64/packages/grep/bottlerocket-aarch64-grep-debuginfo-3.6-1.x86_64.rpm.buildsys_marker
  1054430      0 -rw-r--r--   1 tjk      tjk             0 Jun 24 10:26 aarch64/variants/aws-k8s-1.20/bottlerocket-aws-k8s-1.20-aarch64-1.1.2-18c6be33.img.lz4.buildsys_marker
  • Build aarch64 again; build is fast. Confirm health.
  • Build x86_64 again; build is fast. aarch64 state isn't touched, only x86 variant artifacts. Confirm health.
  • Build aarch64 again; build is fast. x86 state isn't touched, only aarch64 variant artifacts. Confirm health.
  • Build aws-ecs-1 variant for x86 just to confirm nothing funny is going on between variants. It builds the ECS-specific packages and updates their state markers, reuses the rest. Confirm health.
  • Touch storewolf/src/main.rs, build x86_64, confirm it rebuilds os, build aarch64, confirm it rebuilds os again.

The (top-level) cargo fingerprint/cache is separated correctly; example package:

drwxr-xr-x. 2 tjk tjk 4.0K 06-24 10:18 variants/target/aarch64/debug/.fingerprint/acpid-eb8670ac655d56a0/
drwxr-xr-x. 2 tjk tjk 4.0K 06-24 09:54 variants/target/x86_64/debug/.fingerprint/acpid-eb8670ac655d56a0/

(Before, it was like that, but minus the $arch level.)

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Previously, switching between architectures would rebuild all artifacts, which
can make building and testing changes painful.

This change makes cargo and buildsys store their state in arch-specific
directories, so when you switch, they can find the last artifacts they built
for that arch.
@tjkirch tjkirch requested review from bcressey and webern June 24, 2021 18:15
Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

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

nice

@tjkirch tjkirch merged commit d1854a7 into bottlerocket-os:develop Jun 29, 2021
@tjkirch tjkirch deleted the build-track-arch branch June 29, 2021 21:23
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.

5 participants