machine: design doc for uncompressed image cache#28857
Conversation
Fixes: https://redhat.atlassian.net/browse/RUN-4473 Signed-off-by: Nicola Sella <nsella@redhat.com>
|
|
||
| `podman machine init` is slow because reasons, one of which is that the VM disk image is decompressed on every invocation, even when the compressed image is already cached locally. When a user does `podman machine rm` + `podman machine init`, the decompressed disk is destroyed and recreated from scratch. | ||
|
|
||
| This proposal eliminates redundant decompression by caching the decompressed base image alongside the compressed blob, drastically reducing warm init times. Also introduces future improvements like a `podman machine pull` command that could further improve the init times, or at least move the logic to a phase of initialization where the user might expect longer times, so during pull. |
There was a problem hiding this comment.
why bother keeping a compressed version?
There was a problem hiding this comment.
for whatever reason I didn't want to break any behavior by removing a file. I am totally up to remove the compressed blob
There was a problem hiding this comment.
i think it is logical to just work uncompressed bc then you don't have to fiddle with the UI. That said, you will need to think about the migration of someone who has compressed cache files today as you think this over. i'd be also curious what other folks think.
There was a problem hiding this comment.
we could just migrate to uncompressed only - I believe the penalty for this is just an extra cache miss the first time the user init's after this change.
There was a problem hiding this comment.
then I think it's set. no breaking change if the compressed file is needed it will just be redownloaded
There was a problem hiding this comment.
we could just migrate to uncompressed only - I believe the penalty for this is just an extra cache miss the first time the user init's after this change.
There is not penalty at all in theory, updating to a new podman version is required to use this new feature and that always implies a cache miss. With each new podman version you will need to download the new image for that podman version of course.
| ### High-level approach | ||
|
|
||
| - Decompress the image at pull time and save it next to the compressed blob in the cache directory. | ||
| - Add a new `podman machine rm --cache` flag to allow explicit cache pair removal. |
There was a problem hiding this comment.
if you dont keep a compressed version, then this is not needed?
|
Will using reflink affect |
Excellent points. I dont recall the exact answer (because at one time I fiddled with this), but iirc it also depended on the platform (windows, darwin, linux). |
yup, makes a lot of sense. start is when it needs to be fast. furthermore, the init time could be additionally cut down if we split the pull + extract step. I think this change would be beneficial especially for Podman Desktop folks, which I believe could do the setup steps way before the user starts the machine. |
I would not argue based on assumptions, this should be measured if we want to decide on this. That changes podman machine start will do the the image contents are minimal so how much extra writes would that produce, a lot less then a full copy each time on init. At least looking at our CI tests (and our histological flakiness) I think a reflink copy would help a ton there for example to speed up the copies and thus the overall tests. |
| Are you sure you want to continue? [y/N] y | ||
| ``` | ||
|
|
||
| When the machine does not exist but `--cache` is specified, cache files are still listed and removed: |
There was a problem hiding this comment.
I think UI wise this seems rather confusing, should there not be a different command to clean a cache?
The entire podman machine command line is already confusing enough as no argument means default machine. So someone who just want to clean the cache cannot do that.
I think a dedicated command would solve this much cleaner and makes the docs much more straightforward, i.e. podman machine cache by default that just shows the cachefile localtion and size, and then when adding --remove it removes the cache?
|
|
||
| - Decompress the image at pull time and save it next to the compressed blob in the cache directory. | ||
| - Add a new `podman machine rm --cache` flag to allow explicit cache pair removal. | ||
| - Add an `ImageDigest` field to `MachineConfig` to track provenance and enable refcounting. |
There was a problem hiding this comment.
The refcounting references totally confuse me, what are you trying to count.
If we do real reflink copies of files there is nothing to count, the file is a copy and the fs is handling the deduplication internally so the userspace does not need to know anything about it?
|
I updated the design doc with a second commit.
edit: for clarification, we could add reflink copies in this design doc or later |
- introduce `podman machine cache` - use uncompressed cache only - copy image on init Signed-off-by: Nicola Sella <nsella@redhat.com>
6a4ad2a to
1abe5e7
Compare
| | Command | Effect | | ||
| | --- | --- | | ||
| | `podman machine cache` | List cached base images (digest, format, size) | | ||
| | `podman machine cache --remove` | Delete all cached base images after confirmation | |
There was a problem hiding this comment.
I am not sure about --remove flag since podman machine cache lists. Maybe create podman machine cache prune?
There was a problem hiding this comment.
I am not sure about --remove flag since podman machine cache lists. Maybe create podman machine cache prune?
depending on the complexity of the subcommand, prune might be worth it, i.e. thinking of a future scenario when we might have prune --all, prune --outdated
There was a problem hiding this comment.
That sounds good. We can start with just pruning.
|
Since the cache is only managing the default podman machine image, I think it's overkill to have a A separate |
Fixes: https://redhat.atlassian.net/browse/RUN-4473
Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?