Laurence Gonsalves
04/24/2024, 9:09 PMremoveUnusedEntriesAfterDays
, but what I'd really like is a way to remove any cache or intermediate files that would not be used to in the execution of any currently existing tasks.
We're using Gradle in a GitLab CI pipeline, and have found that over time the cache eventually gets big enough that having it is more expensive than not having it. GitLab CI caches work by zipping up the cached directories, uploading the zip remotely, and then later downloading it and unzipping it. So when the cache contains unused files, time and space are wasted transferring and (un)zipping.
I'm thinking to have our jobs wipe the entire cache once daily, but I'm wondering if Gradle can do something smarter than a complete wipe.ephemient
04/24/2024, 9:41 PMephemient
04/24/2024, 9:43 PMfind cache \( -type f ! -anewer . -o -type d -empty \) -delete
might also work (replace cache
with what you want to clean and .
with some file that was only touched at the start of your build)Laurence Gonsalves
04/24/2024, 10:30 PMmaybe you want to use a "remote" (but nearby, so it's fast) build cache and maven proxyI was investigating exactly that a couple of days ago. This is what GitLab's "Dependency Proxy for packages" is supposed to be. Unfortunately, in my testing it was actually slower than using maven central directly, even when the cache was pre-populated. 🤦
untested but in principle something like ... might also workWow! This is actually what I've been using the last few days, but have discovered some reliability issues with it. For example:
FAILURE: Build failed with an exception.
What went wrong:
The cache entry for settings file '/builds/myorg/myproject/settings.gradle' appears to be corrupted.
I think non-determinism (eg: incorporating the clock in build logic) and/or looking at directory listings can throw this approach off. That is, sometimes a file can get deleted because it's not used in one build, but later another build decides it does need that file, and it doesn't handle individual files missing from the cache very gracefully, it seems.