-
Notifications
You must be signed in to change notification settings - Fork 379
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
compression: add support for the zstd algorithm #639
Conversation
PR for c/storage: containers/storage#363 |
@mtrmac fixed now, it is using the 0.8 format. How could we start generating zstd tarballs? Should |
ACK. Tests fail on Windows, though.
Yes, an option in |
Skopeo WIP PR here: containers/skopeo#671 |
pkg/compression/compression.go
Outdated
"gzip": GzipCompressor, | ||
"bzip2": Bzip2Compressor, | ||
"xz": XzCompressor, | ||
"zstd": ZstdCompressor, |
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.
If the callers need to deal with the strings, please turn them into a typed Go enum.
… and then DecompressorFunc
and CompressorFunc
can be removed, and become methods on that typed enum. (Well, DecompressorFunc
needs to continue to exist so that we don’t break the API.)
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.
are you fine with the last version where I changed the function to look like:
func GetCompressor(dest io.Writer, name string, level int) (io.WriteCloser, error)
so now we don't expose CompressorFunc
at all. Do you still want to have a Go enum for the compression algorithms?
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.
Yes, please
- let’s not have an untyped
when it could use a
desiredCompressionFormat = "gzip"
compression.Gzip
constant - A named Go type would prevent accidentally/unnecessarily mixing raw strings and format values.
- Depending on what the type exactly ends up being, making
GetCompressor
a method on the format type might eliminate thefailure path. (If not, no harm done.)c, found := compressors[name] if !found {
- OTOH, that might force us to add a
compression.GetFormatFromString()
, to settypes.SystemContext.CompressionFormat
with the typed value — but that would be a good thing, because invalid values would have to be recognized early at the CLI level, instead of deep inside thecompressGoroutine
.
00db5ed
to
38a18ac
Compare
rebased ⬆️ |
@vrothberg @rhatdan PTAL |
@giuseppe needs another rebase (will review now) |
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.
Overall LGTM, just a few nits. @giuseppe, could we add some tests to make sure we don't regress? pkg/compress
has some tests in place that could be extended.
bfe8784
to
16b9f39
Compare
If we add support for zstd? Would an image created with this algorythm, still be able to be used on Docker? Older versions of CRI-O, Buildah, Podman? |
@giuseppe, could you add tests? Besides that, LGTM. |
no, unfortunately it won't be compatible with other versions of the tools that have no support for zstd.
I've added some new tests to |
What error will docker report if it tries to use an image created with this compression? |
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.
LGTM
@giuseppe, please also open a PR for Skopeo to avoid the CI being red for too long.
I've opened it here: containers/skopeo#671 I'll revendor containers/image and drop the WIP once this is merged |
@mtrmac Can we merge this? Once this is merged, should we open a PR for Moby to support the new compression algorithm, so we can maintain compatibility. Does this increase speed of builds? Pulls? Pushes? |
so these are some numbers I've collected: #!/bin/sh
sudo rm -rf /tmp/nginx
mkdir /tmp/nginx
for i in gzip zstd; do
./skopeo copy --dest-compress --dest-compress-format $i --dest-compress-level=20 docker://docker.io/nginx dir:/tmp/nginx/$i
done > /dev/null
du --si -s /tmp/nginx/*
for i in gzip zstd; do
./skopeo copy --dest-compress-format $i dir:/tmp/nginx/$i docker://quay.io/giuseppe/nginx:$i
done > /dev/null
printf "\npull...\n"
for i in gzip zstd; do
printf "\n%s\n" $i
time sudo unshare -m ./skopeo copy docker://quay.io/giuseppe/nginx:$i "containers-storage:[overlay@/tmp/nginx/storage/$i+/tmp/nginx/storage/run]localhost/nginx:$i" > /dev/null
done I've got:
|
Not bad at all. |
@giuseppe Should tests be passing now? |
The Skopeo failures are expected as the dependency is not there yet |
@giuseppe, can you open a PR at Skopeo using this branch of c/image? This way, we can make sure to not introduce a regression. Once the PR here in c/image is merged, you can update the PR at Skopeo. |
The PR for Skopeo is here: containers/skopeo#671 |
I can't see if containers/skopeo#671 passes as Travis builds don't seem to be triggered due to the merge conflicts. |
I've rebased it now |
zstd is a compression algorithm that has a very fast decoder, while providing also good compression ratios. The fast decoder makes it suitable for container images, as decompressing the tarballs is a very expensive operation. This is a first step at supporting zstd as we We don't yet generate zstd layers. In my testing, copying the Fedora image from a local dir: repository, the wall clock time passed from ~8s with gzip compression to ~4.5s with zstd. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
add the possibility to choose what compression format must be used and the compression level to use. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
the default size is too small and it has a negative impact on the compression results. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@rhatdan tests for the Skopeo PR are passing. If everything is fine, please let's move this forward |
LGTM |
zstd is a compression algorithm that has a very fast decoder, while
providing also good compression ratios. The fast decoder makes it
suitable for container images, as decompressing the tarballs is a very
expensive operation. This is a first step at supporting zstd as we We
don't yet generate zstd layers.
In my testing, copying the Fedora image from a local dir: repository,
the wall clock time passed from ~8s with gzip compression to ~4.5s
with zstd.
Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com