moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
8.1k stars 1.14k forks source link

Customize LRU strategy #4137

Open silvin-lubecki opened 1 year ago

silvin-lubecki commented 1 year ago

The GC policies allow a lot of customization to make sure we can prioritize different types of content. But when it comes the time to collect content, buildkit sorts all the contents depending the frequency the content has been used and the last date used. There is no way to prefer frequency over age, or the other way. See https://github.com/moby/buildkit/blob/master/cache/manager.go#L1652-L1657

It would be great to be able to configure the relative importance between age and frequency, for fine grain tuning. I guess it would be a global config, and not a policy level one.

tonistiigi commented 1 year ago

Let's just add 2 config properties lastUsedPriority and usageCountPriority with 0-1 relative weight value.