Repository navigation
docs: Add page for caching configuration - #8695
Conversation
|
|
||
| The layer cache size configuration is managed by [Buildkit's garbage collector](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md?plain=1#L83-L94). | ||
|
|
||
| To free up disk space used by the cache, use the following command: |
There was a problem hiding this comment.
Which cache does this command impact?
There was a problem hiding this comment.
I would also love a small table mapping the type of the filters to dagger's functions/apis/etc.
a0a0170 to
ebffe32
Compare
6e2ad5c to
1a3b680
Compare
TomChv
left a comment
There was a problem hiding this comment.
Small comments, otherwise look great
|
|
||
| Dagger caches two types of data: | ||
|
|
||
| 1. Layers: This refers to build instructions and the results of some API calls. This cache is implemented by Buildkit. |
There was a problem hiding this comment.
Do we want to explain a bit more how it works?
Basically a layer is the "receipe" of the instruction (for example COPY) with its arguments (for example a & b) as well as the result.
Then when Dagger executes a Buildkit operation, buildkit will first check if it already has the receipe and if the argument matches, if it does, it will fetch the result directly, skip the execution and send it to the next operation.
In contrary, if the cache miss, all next operations will also have its cache invalidated.
| - It may sometimes be necessary to explicitly force execution of specific pipeline operations, bypassing the Dagger layer cache. The typical approach for this is to [invalidate the Dagger layer cache](../cookbook/cookbook.mdx#invalidate-cache) by introducing a volatile time variable at a specific point in the Dagger pipeline | ||
|
|
||
| - For the volume cache: | ||
| - Cache the tool's own cache directory instead of caching the installed dependencies directory. For example, with `node` and `npm`, use a cache volume for the `~/.npm` cache directory and not for the project's `node_modules` directory. |
There was a problem hiding this comment.
AFAIK this change is to optimize how deps are cached and retrieved. @kpenfound can you add more context?
|
|
||
| For these tools to cache properly, they need their own cache data (usually a directory) to be persisted between sessions. By using a cache volume for this data, Dagger can reuse the cached contents across pipeline runs and reduce execution time. | ||
|
|
||
| ## Caching best practices |
There was a problem hiding this comment.
Why do we remove it? Maybe you can add a link to the other page here too, if someone is looking at the caching page, he might assume best practises are also here and not in configuration.
There was a problem hiding this comment.
Moved to features page as I had similar feedback earlier, so perhaps that's the more natural place for this information.
fbf1a0f to
7a01ca6
Compare
|
|
||
| For these tools to cache properly, they need their own cache data (usually a directory) to be persisted between sessions. By using a cache volume for this data, Dagger can reuse the cached contents across pipeline runs and reduce execution time. | ||
|
|
||
| ## Caching best practices |
|
I let other people give a 2nd look just to confirm then we should merge it :D |
| Dagger caches two types of data: | ||
|
|
||
| 1. Layers: This refers to build instructions and the results of some API calls. This cache is implemented by Buildkit. | ||
| 2. Volumes: This refers to the contents of a Dagger filesystem volume and is persisted across Dagger Engine sessions. It is implemented by Dagger (distinct from Buildkit). |
There was a problem hiding this comment.
It is implemented by Dagger (distinct from Buildkit).
Cache volumes are still implemented by buildkit.
There was a problem hiding this comment.
Both caches are managed by BuildKit. In this case, I propose to remove the BuildKit reference altogether, as I'm not sure naming the underlying tech is useful to an end-user.
| ### Layer caching | ||
|
|
||
| - Layers are cached in sequence, and a change in any one layer invalidates that and all subsequent layers. Pay attention to the order of your build operations, and sequence non-volatile operations before volatile ones to avoid invalidating the cache early. | ||
| - It may sometimes be necessary to explicitly force execution of specific pipeline operations, bypassing the Dagger layer cache. The typical approach for this is to [invalidate the Dagger layer cache](../cookbook/cookbook.mdx#invalidate-cache) by introducing a volatile time variable at a specific point in the Dagger pipeline |
There was a problem hiding this comment.
Maybe we should have an example? This is the same as before though, so not blocking.
|
|
||
| Dagger caches two types of data: | ||
|
|
||
| 1. Layers: This refers to build instructions and the results of some API calls. This cache is implemented by Buildkit. |
There was a problem hiding this comment.
See above for related discussion
| Dagger caches two types of data: | ||
|
|
||
| 1. Layers: This refers to build instructions and the results of some API calls. This cache is implemented by Buildkit. | ||
| 2. Volumes: This refers to the contents of a Dagger filesystem volume and is persisted across Dagger Engine sessions. It is implemented by Dagger (distinct from Buildkit). |
| - Show all the cache entry metadata: | ||
|
|
||
| ```shell | ||
| echo '{daggerEngine{localCache{entrySet{entries{description diskSpaceBytes}}}}}' | dagger query |
There was a problem hiding this comment.
This reads more human-friendly to me:
dagger query <<EOF
{
daggerEngine {
localCache {
entrySet {
entries {
description
diskSpaceBytes
}
}
}
}
}
EOF| - Show high level summaries of cache usage: | ||
|
|
||
| ```shell | ||
| echo '{daggerEngine{localCache{entrySet{entryCount diskSpaceBytes}}}}' | dagger query |
There was a problem hiding this comment.
A more human-friendly version:
dagger query <<EOF
{
daggerEngine {
localCache {
entrySet {
entryCount
diskSpaceBytes
}
}
}
}
EOF|
|
||
| ## Cache pruning | ||
|
|
||
| The layer cache size configuration is managed by [Buildkit's garbage collector](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md?plain=1#L83-L94). |
| To free up disk space used by the cache, use the following command: | ||
|
|
||
| ```shell | ||
| dagger core dagger-engine local-cache prune |
There was a problem hiding this comment.
While I really like that this is supported via dagger core, for consistency reasons, I would stick with:
dagger query <<EOF
{
daggerEngine {
localCache {
prune
}
}
}
EOFSigned-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
7a01ca6 to
aa40257
Compare
|
Just took another look, LGTM 👍 |

No description provided.