#Investigate local dagger engine cache allocation
1 messages · Page 1 of 1 (latest)
I am trying to optimize the buildkit toml to adjust how much cache we keep of different types
@final terrace @sullen cedar I think this is a question for you.
We could also add a page to our https://docs.dagger.io/manuals/administrator, I think it's a good piece of information
Issue DOCS-313 created.
See https://discord.com/channels/707636530424053791/1263412879466696705 for full context
Triage
We recently added raw API support, still working on the frontends for it. But you can access this from the CLI:
- Show all the cache entry metadata:
echo '{daggerEngine{localCache{entrySet{entries{description diskSpaceBytes}}}}}' | dagger query - Show just high level summaries of usage:
echo '{daggerEngine{localCache{entrySet{entryCount diskSpaceBytes}}}}' | dagger query
It's just very initial work so far, much more coming in https://github.com/dagger/dagger/pull/7646 and follow-ups, so let me know what other information would be useful to have
Hi @final terrace , thanks for the tip on the API support, we are now able to segregate out the different types of cache used! We effectively have a scheduled task that will query the cache and break it down by type that we parsed from the different returned patterns of: '{daggerEngine{localCache{entrySet{entries{description diskSpaceBytes}}}}}'.
I would say some difficulties we saw were:
- What are the different patterns/types? Identifying what is a mounted cache vs. layer cache vs. base image cache vs. built image cache
- How can we now use this information and translate it to buildkit configuration to optmize our
keepDurationgcpolicies. - How can we modify what the dagger engine thinks is the total engine size? I noticed in the query responses that there is a activelyUsed field which maybe only kicks off when the cache size is above the total size? We would like to control this value so that we can trigger the dagger pruning earlier
Here is our current engine.toml:
# https://docs.docker.com/build/cache/garbage-collection/#default-policies
[worker.oci]
enabled = true
gc = true
[[worker.oci.gcpolicy]]
all = false
keepDuration = "12h"
keepBytes = "1GB"
filters = ["name==vuv_cache"]
[[worker.oci.gcpolicy]]
all = false
keepDuration = "12h"
filters = ["name==uv_cache"]
[[worker.oci.gcpolicy]]
all = false
keepDuration = "48h"
filters = ["name==pip_cache"]
[[worker.oci.gcpolicy]]
all = false
keepDuration = "24h"
keepBytes = "20GB"
filters = ["type==source.local", "type==source.git.checkout"]
[[worker.oci.gcpolicy]]
all = false
keepDuration = "120h" # 5 days
[[worker.oci.gcpolicy]]
all = false
keepBytes = "150GB"
[[worker.oci.gcpolicy]]
all = true
keepBytes = "150GB"
This was very helpful though thank you!
How did you get that graph 😄
And most importantly how did you get the names of the caches, the above dagger queries do not include the cache names
Does dagger use the builder defined docker builder ls? or does it spin up another builder internally?
I'm trying to figure out where I can pull more info about cache. And if its using the default docker builder then the GC policies must go to the daemon.json instead of the builtkit toml
For example, with this buildkit file, even after VM reboot, dagger reports 65GB for keep-bytes
jenkins@jenkins1:~$ sudo cat /etc/buildkit/buildkitd.toml
[worker.oci]
enabled = true
gc = true
gckeepstorage = "80%"
[[worker.oci.gcpolicy]]
keepBytes = "30%"
jenkins@jenkins1:~$ dagger core dagger-engine local-cache keep-bytes
✔ connect 0.2s
✔ initialize 0.3s
✔ prepare 0.0s
✔ daggerEngine: DaggerEngine! 0.0s
✔ DaggerEngine.localCache: DaggerEngineCache! 0.0s
✔ DaggerEngineCache.keepBytes: Int! 0.0s
Setup tracing at https://dagger.cloud/traces/setup. To hide: export NOTHANKS=1
6.4e+10