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

[lib/rust] RUSTFLAGS might introduce cache-misses in the target mount cache #30

Open
idelvall opened this issue Nov 29, 2023 · 0 comments

Comments

@idelvall
Copy link
Member

idelvall commented 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 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.

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 same RUSTFLAGS

@idelvall 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant