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

Fix rust build caching and tune rpm compression #1045

Merged
merged 2 commits into from
Aug 17, 2020

Conversation

bcressey
Copy link
Contributor

Issue number:
N/A

Description of changes:
Use a separate cache for gnu and musl targets, so that they don't overwrite each other. Use fixed rustc flags to avoid letting cargo pick, which can invalidate the musl cache between builds.

Disable debuginfo compression since we don't need it. Optimize the compression of the cpio archive inside the rpms for our use case.

Testing done:
While hacking on growpart I noticed that each build was taking over five minutes which was pretty painful for iterative testing.

Changing the Rust macros to better preserve the cache dropped the time to two minutes, while adjusting the compression for debuginfo and cpio archives dropped it to one minute. I verified that all crates are marked as "fresh" in the output for subsequent runs.

Rebuild time when switching variants is now around five minutes.

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.

@bcressey bcressey requested review from iliana and tjkirch August 15, 2020 20:53
@bcressey bcressey force-pushed the fix-rust-build-cache branch from 991b3a5 to f45cdbf Compare August 15, 2020 21:23
macros/shared Outdated Show resolved Hide resolved
macros/cargo Outdated Show resolved Hide resolved
The cache directory is meant to optimize subsequent rebuilds of the
crates in the "os" package. We weren't seeing much benefit for two
reasons.

First, when building the apiclient and the migrations with the musl
target, we were clobbering the cache for the gnu target, which then
needed to be rebuilt the next time around.

Second, in 8f9306c we left it up to cargo to decide which flags to
pass to rustc for LTO. It passed `-Clinker-plugin-lto` for apiclient
but not for the migrations, so the cache was immediately invalidated
and needed to be rebuilt.

We solve these problems by using a separate cache directory for the
gnu and musl targets, and by specifying the rustc flags we expect.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
We spend a significant amount of time compressing debuginfo for
limited gain, since the eventual use case for these symbols is to
archive them for retrieval from a symbol server. Turning it off
improves overall build times.

For compressing the RPMs there are two factors at work. Disabling any
compression speeds up the build, but the larger artifacts take longer
to copy out. Using zstd strikes a reasonable balance between the time
to compress and the time to copy.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
@bcressey bcressey force-pushed the fix-rust-build-cache branch from f45cdbf to c17a8c3 Compare August 17, 2020 15:32
@bcressey bcressey merged commit ccb62a5 into bottlerocket-os:develop Aug 17, 2020
@bcressey bcressey deleted the fix-rust-build-cache branch August 17, 2020 18:17
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