ccache -s: Read Cache Statistics
ccache -s prints the cache statistics: hits, misses, hit rate, and current size.
The only reliable way to know your CI cache is actually working is to read the stats. ccache -s after a build tells you whether the restored cache produced hits or whether something is busting it.
What it does
ccache -s prints counters for cacheable calls, direct and preprocessed hits, misses, and the cache size against its limit. ccache -v -s (or -vv) adds a more detailed breakdown including the reasons compiles were not cached. The counters accumulate until reset.
Common usage
ccache -s # summary stats
ccache -v -s # verbose breakdown
ccache -s | grep -i hit
ccache --show-stats # same as -s on newer ccacheOptions
| Flag | What it does |
|---|---|
| -s / --show-stats | Print summary statistics |
| -v / -vv | Add verbose detail to the stats output |
| cache hit (direct) | Served from the fast direct-mode cache |
| cache hit (preprocessed) | Served after preprocessing the source |
| cache miss | Compiled and stored (no usable cache entry) |
In CI
Print ccache -s at the end of the build step so every run records its hit rate in the log. A first run after a cache restore should show many hits; near-zero hits on a warm cache is the signal to investigate hashing inputs (compiler path, __FILE__, build dir). Consider zeroing stats at the start to measure per-run behavior.
Common errors in CI
A persistently low hit rate is not an error message but the most common ccache problem; check CCACHE_BASEDIR, the compiler_check setting, and whether the build dir path changes between runs. "called for link" or "unsupported source language" lines in verbose stats are normal non-compile invocations, not failures.