You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sharing target mount cache across builds with different RUSTFLAGS overwrites cache entries and results in cache misses. The reason is $CARGO_TARGET_DIR cache entries, despite depending on RUSTFLAGS are not keyed by them.
Context
Current version of the lib/rust library uses several mount caches per tuple of {runner, project, os_release}:
One cache mount for $CARGO_HOME, shared across all builds and supporting parallel access
A family of blocking-access cache mounts for $CARGO_TARGET_DIR. One per calling Earthly target. Notice that an Earthly build can trigger multiple (Earthly) targets in parallel, each one of them using their own mount cache
The problem comes when RUSTFLAGS are changed, some cache entries might be overwritten, or when the user Earthfile has successive +CARGO builds in the same Earthly target using different RUSTFLAGS. These scenarios would result in the loss of the original cache entries.
We could additionally key $CARGO_TARGET_DIR mount caches by the whole cargo command + hashOf(rustflags) to make sure these caches are only reused across builds of the same command, with the same RUSTFLAGS
The text was updated successfully, but these errors were encountered:
idelvall
changed the title
[rust] Target cache might get thrashed due to RUSTFLAGS
[lib/rust] Target cache might get thrashed due to RUSTFLAGS
Nov 29, 2023
idelvall
changed the title
[lib/rust] Target cache might get thrashed due to RUSTFLAGS
[lib/rust] RUSTFLAGS might introduce cache-misses in the target mount cache
Nov 29, 2023
Sharing target mount cache across builds with different RUSTFLAGS overwrites cache entries and results in cache misses. The reason is
$CARGO_TARGET_DIR
cache entries, despite depending onRUSTFLAGS
are not keyed by them.Context
Current version of the lib/rust library uses several mount caches per tuple of {runner, project, os_release}:
$CARGO_HOME
, shared across all builds and supporting parallel access$CARGO_TARGET_DIR
. One per calling Earthly target. Notice that an Earthly build can trigger multiple (Earthly) targets in parallel, each one of them using their own mount cacheThe problem comes when
RUSTFLAGS
are changed, some cache entries might be overwritten, or when the user Earthfile has successive+CARGO
builds in the same Earthly target using differentRUSTFLAGS
. These scenarios would result in the loss of the original cache entries.References
Proposal
We could additionally key
$CARGO_TARGET_DIR
mount caches by the whole cargo command + hashOf(rustflags) to make sure these caches are only reused across builds of the same command, with the sameRUSTFLAGS
The text was updated successfully, but these errors were encountered: