Skip to content

Commit

Permalink
Only activate direct mode by default for local
Browse files Browse the repository at this point in the history
4538675 reverted my initial change.

This re-enables direct mode by default, making sure only the disk
cache is affected. There may still be an issue with Windows, but
details are sparse and no reproduction has been found yet.
  • Loading branch information
Alphare authored and sylvestre committed Nov 23, 2023
1 parent 240c38f commit aa20391
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Local.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Preprocessor cache mode will be disabled if any of the following holds:

Configuration options and their default values:

- `use_preprocessor_cache_mode`: `false`. Whether to use preprocessor cache mode entirely.
- `use_preprocessor_cache_mode`: `true`. Whether to use preprocessor cache mode entirely.
- `file_stat_matches`: `false`. If false, only compare header files by hashing their contents. If true, will use size + ctime + mtime to check whether a file has changed. See other flags below for more control over this behavior.
- `use_ctime_for_stat`: `true`. If true, uses the ctime (file status change on UNIX, creation time on Windows) to check that a file has/hasn't changed. Can be useful to disable when backdating modification times in a controlled manner.

Expand Down
12 changes: 11 additions & 1 deletion src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ pub trait Storage: Send + Sync {

/// Return the config for preprocessor cache mode if applicable
fn preprocessor_cache_mode_config(&self) -> PreprocessorCacheModeConfig {
// Disabled by default, only enabled in local mode
// Enable by default, only in local mode
PreprocessorCacheModeConfig::default()
}
/// Return the preprocessor cache entry for a given preprocessor key,
Expand Down Expand Up @@ -431,6 +431,16 @@ impl Default for PreprocessorCacheModeConfig {
}
}

impl PreprocessorCacheModeConfig {
/// Return a default [`Self`], but with the cache active.
pub fn activated() -> Self {
Self {
use_preprocessor_cache_mode: true,
..Default::default()
}
}
}

/// Implement storage for operator.
#[cfg(any(feature = "s3", feature = "azure", feature = "gcs", feature = "redis"))]
#[async_trait]
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Default for DiskCacheConfig {
DiskCacheConfig {
dir: default_disk_cache_dir(),
size: default_disk_cache_size(),
preprocessor_cache_mode: Default::default(),
preprocessor_cache_mode: PreprocessorCacheModeConfig::activated(),
}
}
}
Expand Down Expand Up @@ -1296,7 +1296,7 @@ token = "webdavtoken"
disk: Some(DiskCacheConfig {
dir: PathBuf::from("/tmp/.cache/sccache"),
size: 7 * 1024 * 1024 * 1024,
preprocessor_cache_mode: Default::default(),
preprocessor_cache_mode: PreprocessorCacheModeConfig::activated(),
}),
gcs: Some(GCSCacheConfig {
bucket: "bucket".to_owned(),
Expand Down

0 comments on commit aa20391

Please sign in to comment.