Repository navigation
Conversation
In this patch, the crate::cache::Storage trait is split into the Storage and PreprocessorCacheStorage traits, with the implementations stored in storage.rs and preprocessor_cache.rs, respectively. The configuration for the preprocessor cache is moved from DiskCacheConfig to a more general location, CacheConfigs. The config for the preprocessor cache is moved from [cache.disk.preprocessor_cache_mode] to [cache.preprocessor] and all original keys are available. In addition, 3 keys are introduced max_size is the maximum size for the preprocessor cache. rw_mode defines the preprocessor cache as ReadWrite or ReadOnly. dir specifies the location of the preprocessor cache. If not specified, the path to the disk cache will be used. This allows other storage, e.g., S3, which does not support random read/write, to also benefit from the preprocessor cache. In the build environment, one can store the generated object file in a shared object storage system and put the preprocessor hash locally. This should help accelerate the whole build process.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2607 +/- ##
==========================================
+ Coverage 72.74% 73.49% +0.75%
==========================================
Files 68 71 +3
Lines 36985 37513 +528
==========================================
+ Hits 26903 27571 +668
+ Misses 10082 9942 -140 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…_bug_2173 This test is not covered locally even with `cargo test --features=all`
|
Hello, is there any reviewer updates on this? |
|
FYI: I have deployed my version of the code to our internal build cluster, and it seems local preprocessor cache + S3 object file storage works properly. |
|
|
||
| # See the local docs on more explanations about this mode | ||
| [cache.disk.preprocessor_cache_mode] | ||
| [cache.preprocessor_cache_mode] |
There was a problem hiding this comment.
the field in CacheConfigs is preprocessor, so [cache.preprocessor_cache_mode] will be rejected by deny_unknown_fields.
also, existing [cache.disk.preprocessor_cache_mode] configs will now fail to parse. could we keep accepting it, or at least mention the breaking change?
| key: &str, | ||
| preprocessor_cache_entry: PreprocessorCacheEntry, | ||
| ) -> Result<()> { | ||
| if self.config.rw_mode == CacheModeConfig::ReadOnly { |
There was a problem hiding this comment.
before, a read-only disk cache (SCCACHE_LOCAL_RW_MODE=READ_ONLY, or ReadOnlyStorage) also blocked preprocessor writes.
now only config.rw_mode is checked. is this intended?
please add a test
| Some(ref cache) => { | ||
| assert!(self.config.use_preprocessor_cache_mode); | ||
| let key = normalize_key(key); | ||
| info!("PreprocessorCache: put_preprocessor_cache_entry({})", key); |
There was a problem hiding this comment.
info! on every put is too noisy, please use debug/trace.
also, the two assert! above could panic the server. do we need them?
| CacheMode::ReadWrite, | ||
| vec![], | ||
| ); | ||
| let preprocessor_cache_storage = if preprocessor_cache_mode { |
There was a problem hiding this comment.
both branches are the same except for the bool, and this block is copied 5 times.
could be use_preprocessor_cache_mode: preprocessor_cache_mode in a small helper, no?
| Self { | ||
| use_preprocessor_cache_mode: false, | ||
| file_stat_matches: false, | ||
| file_stat_matches: true, |
There was a problem hiding this comment.
this is unrelated to the split, and the docs still say false.
please move it to a separate PR
|
|
||
| (cache_type, fallback) | ||
| if preprocessor_config.dir.is_none() { | ||
| preprocessor_config.dir = Some(fallback.dir.join("preprocessor")); |
There was a problem hiding this comment.
PreprocessorCache::new also appends preprocessor to the dir, so the cache ends up in <dir>/preprocessor/preprocessor.
existing preprocessor caches are lost on upgrade, no?
| .or_else(|| cos.map(CacheType::COS)); | ||
|
|
||
| let fallback = disk.unwrap_or_default(); | ||
| let mut preprocessor_config = preprocessor.unwrap_or_default(); |
There was a problem hiding this comment.
unwrap_or_default() gives use_preprocessor_cache_mode: false.
before, the disk default used PreprocessorCacheModeConfig::activated(), so this silently disables preprocessor cache mode for everyone who doesn't set it.
the docs still say true by default.
|
|
||
| // ======= Preprocessor cache ======= | ||
| let preprocessor_mode_config = | ||
| bool_from_env_var("SCCACHE_DIRECT")?.map(|value| PreprocessorCacheModeConfig { |
There was a problem hiding this comment.
setting SCCACHE_DIRECT now replaces the whole [cache.preprocessor] section from the file (dir, max_size, rw_mode...) with defaults, no?
|
The refactor direction looks fine, and CI is green. But the PR changes behaviour without saying so. Preprocessor cache mode becomes off by default (it used to be |
|
this one has been stuck for a while without an update, closing it for now. feel free to reopen if you get back to it, thanks |
This is a series of PRs that
This is the Part 4. The previous part is #2604.
See #2571 and #2481 for more details.