matus-chochlik / ctcache

Cache for clang-tidy static analysis results
Boost Software License 1.0
84 stars 30 forks source link

Question: Are there tuneable parameters to control cache size? #2

Closed devjgm closed 3 years ago

devjgm commented 3 years ago

I'm looking into using this clang-tidy cache for my project (https://github.com/googleapis/google-cloud-cpp/issues/6170), and so far it looks pretty promising.

I'm wondering about cache growth. Are there tunable parameters prune cache files that haven't been used in N days? I see that the cache files themselves are empty, so I'm not concerned about size, but the number of files may grow without bound otherwise.

Thanks in advance.

matus-chochlik commented 3 years ago

If you use the cache in local mode (storing the hash files in a local directory) you have to clean them manually. I either just used the temp directory that gets cleared on reboot or had a cron job doing someting like find ... -type f -mtime +N -delete for that. In the recent months I've been using the server running on a RPi on the local network and the server takes care of cleaning up the older or unused hashes. Currently the server's uptime is >3 months and the gzipped cache file is less than 40kB.

There is the --cleanup-interval N option for the server that says how often the cleanup should be performed, but currently the algorithm is hardcoded. I could add some options for fine tuning if the default behavior causes problems for you.

devjgm commented 3 years ago

Thanks for the quick reply.

Yes, I am planning to use this in local mode. We use Google Cloud Build for our CI system, and we have a build step that saves/restores certain named cached directories. I plan to save this cache in ~/.cache/ctcache, and it will be saved/restored for our builds. However, over time, this directory will grow.

Does clang-tidy-cache update atime or mtime on cache hits? If so, I could look for cache files that are older than X and delete them myself.

matus-chochlik commented 3 years ago

It uses os.utime(path, None), in cache hit so the modification time is updated.

devjgm commented 3 years ago

Great. Thanks. That should let me do what I need to keep the number of files in check.

And thanks for this tool! It looks really nice in my first uses of it!

matus-chochlik commented 3 years ago

Thanks for using ctcache, and good luck with your project!