-
Notifications
You must be signed in to change notification settings - Fork 47
Support Layer Deltas #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Support Layer Deltas #494
Conversation
|
✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6535 |
mtrmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/containers/container-libs/blob/main/CONTRIBUTING.md#sign-your-prs please, we can’t even look at PRs with unclear copyright status.
… so I’m expressing no opinion on the goal or desirability of the PR at this point. |
|
@mtrmac done |
Signed-off-by: Kyounghoon Jang <[email protected]>
|
@mtrmac ah sorry I misread. Thought that meant cryptographic signing. Commits are actually signed off now |
|
Packit jobs failed. @containers/packit-build please check. |
Generated-By: Claude Code Signed-off-by: Vance <[email protected]>
|
So I imagine y'all will want a test build of Podman with this patch to validate we're seeing the benefits we expect from deltas? |
mtrmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair warning, without reading this ~at all:
- If this should be included, it would require a lot of restructuring, starting with the external API concerns mentioned in the original PR (those are now possible to solve but tedious)
- Given the existence of zstd:chunked nowadays, and unlocked staging of layers on pull, the benefits would have to be very compelling for us to add and maintain yet another pull path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???!
@alexlarsson was gracious enough to also create a patch of Skopeo with a new I've made a quick demo of a synthetic example (1-byte edit to large file) here: https://github.com/vraiti/oci-deltas. The result was a 400 KiB patch to update a 1.2 GiB layer. |
how much do you get with zstd:chunked on the same test? |
|
Do we have real-world numbers on AI model updates? |
How so? Do we expect any benefit with AI models with deltas? |
|
I read that to mean “a 1-byte edit is not representative of anything”. |
|
@giuseppe Just tested, zstd:chunked reports 2 MiB for a 1-byte patch. Also large, but orders of magnitude smaller than I had thought it would be. From documentation and discussion I was under the impression that zstd:chunked did not patch files, only reusing exactly matching files. Does it use something like rolling checksum chunking? That would certainly make it much better for edge computing applications than I had thought. I will run some additional experiments on more representative workloads (namely, the Openshift upgrades that caused us to lose a Tesco business opportunity) to see whether zstd:chunked is effective there as well. |
yes, zstd:chunked uses a rolling checksum to split a file into multiple chunks. |
Introduction
This PR is mainly a rebase of a very old PR from the containers/image repository by @alexlarsson: containers/image#902. It also adds a small amount of extra debug logging to make the optimizations of this PR easily observable.
Rebased PR Info
The matter of network-efficient container updates has been gaining attention from developers in edge computing as container-based technologies to manage edge device applications have gained traction (e.g. Microshift, flightctl):
So, I was investigating how we might support this need for efficient updates, when I came across Alex's PR to containers/image. While it's far from a perfect solution (garbage collection and race conditions were two big concerns that came up in the discussion), the "best" solution would likely be an extension of the OCI spec, which would also likely require much stronger proven demand to justify. After some discussion with engineers from these BU mentioned above as well as @mheon, we decided that rebasing Alex's PR may be a suitable first step.
As all of the logic needed for this PR was already implemented, just in a different codebase, this seemed like an appropriate task for an LLM. In accordance with Red Hat's AI policy, I've annotated the commits as AI generated. While I've done my best to review the generated code, the low-level details of this repository are unfamiliar to me, so I can't conclusively say on my own whether or not this PR is doing all the right things. However, according to my testing everything seems to be working as expected. A demo of the layer delta patch using Skopeo can be found in this repository: https://github.com/vraiti/oci-deltas.
Original PR Info
NOTE: This was mostly copied from containers/image#902. Only change was to the sample manifest media type and layer annotation names.
Deltas are a way to avoid downloading a full copy if a layer tar file
if you have a previous version of the layer available locally. In
testing these deltas have been shown to be around 10x to 100x smaller
than the .tar.gz files for typical Linux base images.
In the typical client-side case we have some previous version of the
image stored in container-storage somewhere, which means that we have
an uncompressed files available, but not the actual tarball
(compressed or not).
This means we can use github.com/alexlarsson/tar-diff which takes
two tar files and produces a delta file which when applied on the
untar:ed content of the first tarfile produces the (bitwise identical)
content of the uncompressed second tarfile. It just happens that the
uncompressed tarfile is exactly what we need to reproduce, because that
is how the layers are refered to in the image config (the DiffIDs).
How this works is that we use OCI artifacts to store, for each regular
image a manifest with information about the available deltas for the
image. This image looks like a regular manifest, except each layer
contains a tar-diff (as a blob) an uses the existing annotations key
to record which DiffIDs the layer applies to.
For example, a manifest would look like this:
The config blob is just an json file containing "{}". Ideally it
should not be of type application/vnd.oci.image.config.v1+json,
because that is reserved for docker-style images. However, as
explained in oras-project/oras#129, docker hub
doesn't currently support any other type. For registries that support
OCI artifacts we should instead use some other type so that tooling
can know that this is not a regular image.
The way we attach the delta manifest to the image is that we store it
in the same repo and a tag name based on the manifest digest like
"delta-${shortid}".
The delta layers record which DiffID they apply to, which is what we
want to use to look up the pre-existing layers to use as delta source
material, and it is what the delta apply will generate. This means
however that using the deltas only works if we're allowed to
substitute blobs, but this doesn't seem to be an issue in the typical
case.