OpenMetrics for ccache

The ccache software maintains a cache to store compilation artefacts, so the next time you compile the same source file, you can get the compiled code from the cache. That speeds up a lot recompilation.

At Nasqueron, ccache is useful to speed up Poudriere builds to test FreeBSD ports. To be able to follow if the cache is useful, we devised a Grafana dashboard to expose metrics from ccache.

If you run ccache -s, it prints statistics. For example with ccache 3:

Converted into OpenMetrics format, that gives:

Those metrics can then be published to a timeseries database like Prometheus.

The Python code to perform this conversion is available in our operations repository. It doesn’t have any dependency.

Important note about ccache versions. As we target FreeBSD and Poudriere, the code handles ccache 3. The parsing code need to be updated for ccache 4, as their statistics output format changed. Run ccache -svv to get the same kind of output under ccache 4, but we need to ignore section headers.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.