From: Joel Rosdahl Date: Sun, 8 Aug 2021 16:49:01 +0000 (+0200) Subject: feat: Add statistics for forced recaches X-Git-Tag: v4.4~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fcec2b22b451a0d193d868afb4756d29f697ecd;p=thirdparty%2Fccache.git feat: Add statistics for forced recaches --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 1d629b3c6..309a7f91c 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -2199,7 +2199,7 @@ do_cache_compilation(Context& ctx, const char* const* argv) } MTR_END("cache", "to_cache"); - return Statistic::cache_miss; + return ctx.config.recache() ? Statistic::recache : Statistic::cache_miss; } int diff --git a/src/core/Statistic.hpp b/src/core/Statistic.hpp index 8b67e96a8..dddfca927 100644 --- a/src/core/Statistic.hpp +++ b/src/core/Statistic.hpp @@ -63,6 +63,7 @@ enum class Statistic { secondary_storage_miss = 38, secondary_storage_error = 39, secondary_storage_timeout = 40, + recache = 41, END }; diff --git a/src/core/Statistics.cpp b/src/core/Statistics.cpp index 9351f186e..04f67897d 100644 --- a/src/core/Statistics.cpp +++ b/src/core/Statistics.cpp @@ -87,6 +87,7 @@ const StatisticsField k_statistics_fields[] = { STATISTICS_FIELD(secondary_storage_miss, "secondary storage miss"), STATISTICS_FIELD(secondary_storage_error, "secondary storage error"), STATISTICS_FIELD(secondary_storage_timeout, "secondary storage timeout"), + STATISTICS_FIELD(recache, "forced recache"), STATISTICS_FIELD(called_for_link, "called for link"), STATISTICS_FIELD(called_for_preprocessing, "called for preprocessing"), STATISTICS_FIELD(multiple_source_files, "multiple source files"), diff --git a/test/suites/base.bash b/test/suites/base.bash index 3996deaf5..61a854b58 100644 --- a/test/suites/base.bash +++ b/test/suites/base.bash @@ -447,10 +447,12 @@ fi $CCACHE_COMPILE -c test1.c expect_stat preprocessed_cache_hit 0 expect_stat cache_miss 1 + expect_stat recache 0 CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c expect_stat preprocessed_cache_hit 0 - expect_stat cache_miss 2 + expect_stat cache_miss 1 + expect_stat recache 1 $REAL_COMPILER -c -o reference_test1.o test1.c expect_equal_object_files reference_test1.o test1.o diff --git a/test/suites/direct.bash b/test/suites/direct.bash index 4f26a63eb..4e22c93b8 100644 --- a/test/suites/direct.bash +++ b/test/suites/direct.bash @@ -1141,6 +1141,7 @@ EOF $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 0 expect_stat cache_miss 1 + expect_stat recache 0 expect_stat files_in_cache 2 # result + manifest manifest_file=$(find $CCACHE_DIR -name '*M') @@ -1148,7 +1149,8 @@ EOF CCACHE_RECACHE=1 $CCACHE_COMPILE -c test.c expect_stat direct_cache_hit 0 - expect_stat cache_miss 2 + expect_stat cache_miss 1 + expect_stat recache 1 expect_stat files_in_cache 2 expect_equal_content $manifest_file saved.manifest