I wrote a quick-n-dirty script that tells me which files had to be rebuild and what the cache miss ratio was:
Sample output (truncated):
ccache hit: lib/expression/unary_minus_expression.cpp
ccache miss: lib/expression/in_expression.cpp
ccache miss: lib/expression/arithmetic_expression.cpp
=== 249 files, 248 cache misses (0.995984 %)===
Script:
#!/usr/bin/env python3
from pathlib import Path
import re
import os
files = {}
for filename in Path('src').rglob('*.ccache-log'):
with open(filename, 'r') as file:
for line in file:
source_file_match = re.findall(r'Source file: (.*)', line)
if source_file_match:
source_file = source_file_match[0]
result_match = re.findall(r'Result: cache (.*)', line)
if result_match:
result = result_match[0]
files[source_file] = result
break
if len(files) == 0:
print("No *.ccache-log files found. Did you compile with ccache and the environment variable CCACHE_DEBUG=1?")
sys.exit(1)
common_path_prefix = os.path.commonprefix(list(files.keys()))
files_shortened = {}
misses = 0
for file in files:
shortened = file.replace(common_path_prefix, '')
if files[file] == 'miss':
misses += 1
print("ccache miss: %s" % (shortened))
print("\n=== %i files, %i cache misses (%f %%)===\n" % (len(files), misses, float(misses) / len(files) * 100))
Note that this takes all ccache-log files into account, not only those of the last build. If you want the latter, simply remove the log files first.