-
Notifications
You must be signed in to change notification settings - Fork 12
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
global caches & cargo-sweep #20
Conversation
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.
LGTM.
Ok, by using global caches (caches with id) I encounter this exact problem https://users.rust-lang.org/t/does-dockers-mount-type-cache-cause-problems/97073. |
I've checked and flock properly works on shared cache mounts, so still investigating why I am facing this rust-lang/cargo#11376 |
This looks promising: rust-lang/cargo#11376 (comment) |
This last commit sets The reason is that, installed crates are not fetched on demand if not found (they need to be installed), so if BK GC removes them from the cache then the build will fail, while if they are stored in the target layers and BK GCed them, the build will rerun those commands and install them back. This setting makes cargo install to store the crates in the target filesystem to avoid such scenario |
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.
Looks good, just a few minor comments.
Summary
This PR:
RUN_WITH_CACHE
UDC$CARGO_HOME
is a non-locking global cache (shared across all Earthfiles). This significantly reduces cache sizeOn global cache
In order to make the new global cache work with
sharing=shared
mode (that allows parallel builds to access its contents), I had to make sure that$CARGO_HOME/.package-cache
was also being stored in the cache, since this the file used by Cargo as a lock to synchronize the access to$CARGO_HOME
from parallel builds.The simplest way I found to achieve this was by temporarily changing the whole
$CARGO_HOME
location to a folder within the cache, while running the same bin/cargo program.