From 53539b5669139cc1b964247a18bca8bc318c1ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Gom=C3=A8s?= Date: Mon, 20 Nov 2023 15:42:49 +0100 Subject: [PATCH] Only activate direct mode by default for local 45386750a48b6ed7daf9019db88a22dc7a7361c5 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. --- docs/Local.md | 2 +- src/cache/cache.rs | 12 +++++++++++- src/config.rs | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/Local.md b/docs/Local.md index 5ccecf9f3..89525fbf0 100644 --- a/docs/Local.md +++ b/docs/Local.md @@ -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. diff --git a/src/cache/cache.rs b/src/cache/cache.rs index 717cde09a..c31761223 100644 --- a/src/cache/cache.rs +++ b/src/cache/cache.rs @@ -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, @@ -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] diff --git a/src/config.rs b/src/config.rs index 07dee8b3f..a0dac525b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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(), } } } @@ -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(),