-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
ci: persist Rust caches for Pip package build #4480
Conversation
Summary: The `build-data-server-pip` job runs on two platforms on every push, and each run takes about 5 minutes. The vast majority of this time (85%) is spent building all dependencies from scratch. Since [macOS minutes are priced at 10× the rate of Linux minutes][pricing] and this is our only macOS job, we may as well spend a modicum of effort to improve this. [pricing]: https://docs.github.com/en/free-pro-team@latest/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions#about-billing-for-github-actions The docs at <https://github.com/actions/cache> say that a repository can have up to 5 GB of caches. The cache for our other Rust job is ~200 MB, and we don’t have any other caches, so adding two more of those caches seems okay. The caches are also invalidated infrequently: only when we update Rust dependencies or update the workflow file itself. Adding a cache should speed up these builds. We already do this for the Rust lint job, and it works well. This is a separate cache because the job builds in release mode rather than debug mode. Rust builds generally have good hermeticity properties, so this should be fairly safe. If we want to be extra safe, we could turn this off for builds that will be published in an actual stable release. Test Plan: Check that the second run of the checks for this PR spends a negligible amount of time in the “Build” and “Test” phases. wchargin-branch: ci-cache-rust-pip wchargin-source: 631d316bed4c17387901b166c6d8d28a6f8c8b7f
(Unassigning just because I haven’t finished the test plan yet.) |
wchargin-branch: ci-cache-rust-pip wchargin-source: 631d316bed4c17387901b166c6d8d28a6f8c8b7f
.github/workflows/ci.yml
Outdated
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
# Needed for installing binaries with cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand this comment. Could you elaborate slightly?
Update: read the other version of this comment which mentions cargo-raze
so I assume this has something to do with raze
generating these artifacts? Slightly more elaboration would still be useful IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elaborated. This is needed only if you cargo install
a binary, like
cargo-raze
or hyperfine
or something. Upstream documentation issue:
rust-lang/cargo#8841
We don’t actually need it for this job. I kept it to reduce headache in
case we later update it to cargo install
. Clarified in comment.
.github/workflows/ci.yml
Outdated
@@ -116,6 +116,20 @@ jobs: | |||
with: | |||
python-version: '3.8' | |||
architecture: 'x64' | |||
- name: 'Cache Cargo home directory' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also includes tensorboard/data/server/target/
which isn't the Cargo home directory (as I understand it) - maybe broaden description slightly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, yes. Renamed in both cases. (I think “Cargo artifacts” is probably
fine, since it’s Cargo (not rustc) that sets up this structure. But
happy to entertain other suggestions.)
wchargin-branch: ci-cache-rust-pip wchargin-source: 588f30bc9fd70403a911ec482def0c0004f06aa3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
.github/workflows/ci.yml
Outdated
@@ -116,6 +116,20 @@ jobs: | |||
with: | |||
python-version: '3.8' | |||
architecture: 'x64' | |||
- name: 'Cache Cargo home directory' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, yes. Renamed in both cases. (I think “Cargo artifacts” is probably
fine, since it’s Cargo (not rustc) that sets up this structure. But
happy to entertain other suggestions.)
.github/workflows/ci.yml
Outdated
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
# Needed for installing binaries with cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elaborated. This is needed only if you cargo install
a binary, like
cargo-raze
or hyperfine
or something. Upstream documentation issue:
rust-lang/cargo#8841
We don’t actually need it for this job. I kept it to reduce headache in
case we later update it to cargo install
. Clarified in comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, thanks for explaining.
I’ve just realized that this caching behavior is a little weird, albeit I think that this is fine. Any change to the Rust code recompiles the I’m inclined to take no action; just noting for posterity. |
Summary:
The
build-data-server-pip
job runs on two platforms on every push, andeach run takes about 5 minutes. The vast majority of this time (85%) is
spent building all dependencies from scratch. Since macOS minutes are
priced at 10× the rate of Linux minutes and this is our only
macOS job, we may as well spend a modicum of effort to improve this.
The docs at https://github.com/actions/cache say that a repository can
have up to 5 GB of caches. The cache for our other Rust job is ~200 MB,
and we don’t have any other caches, so adding two more of those caches
seems okay. The caches are also invalidated infrequently: only when we
update Rust dependencies or update the workflow file itself.
Adding a cache should speed up these builds. We already do this for the
Rust lint job, and it works well. This is a separate cache because the
job builds in release mode rather than debug mode.
Rust builds generally have good hermeticity properties, so this should
be fairly safe. If we want to be extra safe, we could turn this off for
builds that will be published in an actual stable release.
Test Plan:
Note that the second run of the checks for this PR spends less time in
the “Build” and “Test” phases. It appears to still spend about a minute
total building, even though it hits cache. I’m not sure why—this is not
the case for normal, local, incremental builds—but this is still an
improvement of about 65%, so I’m okay with it for now.
wchargin-branch: ci-cache-rust-pip