Skip to content

Conversation

@shadaj
Copy link
Contributor

@shadaj shadaj commented Oct 23, 2025

Makes two changes that improve the cache hit rate if switching between compilation with -Cprefer-dynamic and not. First, because sccache only caches rlib / staticlib crates, -Cprefer-dynamic has no effect and can be ignored (it is often set via global RUSTFLAGS).

Similarly, the Cargo-generated fingerprint is easily invalidated by custom RUSTFLAGS, but since sccache has fine-grained knowledge of the rustc invocation it should ignore this fingerprint. We do this by ignoring this flag in the cache key, and also stripping the -Cextra-filename (which Cargo uses to append the fingerprint to outputs) from the keys of the output files.

Most of this behavior is (to my understanding) covered by the existing tests, but I adjusted a hashing test to ensure these two flags are correctly ignored.

@shadaj shadaj force-pushed the cache-prefer-dynamic-extra-filename branch from 25f448a to eb97b02 Compare October 23, 2025 21:57
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.24%. Comparing base (de9895c) to head (cca478e).

Files with missing lines Patch % Lines
src/compiler/rust.rs 94.11% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2469      +/-   ##
==========================================
+ Coverage   71.23%   71.24%   +0.01%     
==========================================
  Files          64       64              
  Lines       35221    35245      +24     
==========================================
+ Hits        25088    25110      +22     
- Misses      10133    10135       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shadaj shadaj force-pushed the cache-prefer-dynamic-extra-filename branch from eb97b02 to adce4ad Compare October 23, 2025 22:03
@shadaj shadaj force-pushed the cache-prefer-dynamic-extra-filename branch from adce4ad to cca478e Compare October 23, 2025 22:03
Comment on lines +1472 to +1476
|| (arg == "-C" && value == &Some(OsString::from("prefer-dynamic")))
|| (arg == "-C"
&& value
.as_ref()
.is_some_and(|v| v.starts_with("extra-filename"))))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

(arg == "C" && (value == &Some(..) || value.as_ref().is_some_and(..))

is more readable?

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.

3 participants