Skip to content
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

Support zstd (non-chunked) conversion #2530

Merged
merged 1 commit into from
Sep 28, 2023
Merged

Conversation

henry118
Copy link
Member

This PR adds non-chunked zstd image conversion to nerdctl.

nerdctl today already supports converting images to zstdchunked format for lazy-loading. Traditional non-chunked zstd format is usually smaller than the chunked equivalent, and faster to convert. This is desirable for the non lazy-loading scenarios.

The following is the image size comparison between gzip, zstd and ztdchunked formats. Both zstd and zstdchunked used the default level 3 compression level.

// Gzip
REPOSITORY    TAG       IMAGE ID        CREATED          PLATFORM       SIZE        BLOB SIZE
ubuntu        latest    aabed3296a3d    2 seconds ago    linux/amd64    83.4 MiB    28.2 MiB

// zstd
REPOSITORY     TAG       IMAGE ID        CREATED          PLATFORM       SIZE        BLOB SIZE
ubuntu:zstd    latest    fdda97ba5d76    5 minutes ago    linux/amd64    83.4 MiB    24.5 MiB

// Zstdchunked
REPOSITORY    TAG       IMAGE ID        CREATED          PLATFORM       SIZE        BLOB SIZE
ubuntu        zstdchunked      3fc7ec4a3a95    3 seconds ago         linux/amd64    0.0 B       31.3 MiB

@AkihiroSuda AkihiroSuda added this to the v1.7.0 (tentative) milestone Sep 24, 2023
}

pr, pw := io.Pipe()
enc, err := zstd.NewWriter(pw, zstd.WithEncoderLevel(zstd.EncoderLevel(options.ZstdCompressionLevel)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +63 to +66
// #region zstd flags
imageConvertCommand.Flags().Bool("zstd", false, "Convert legacy tar(.gz) layers to zstd. Should be used in conjunction with '--oci'")
imageConvertCommand.Flags().Int("zstd-compression-level", 3, "zstd compression level")
// #endregion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add docs to /docs/command-reference.md?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. will do

@@ -878,6 +878,8 @@ Flags:
- `--estargz-min-chunk-size=<SIZE>` : The minimal number of bytes of data must be written in one gzip stream (requires stargz-snapshotter >= v0.13.0). Useful for creating a smaller eStargz image (refer to [`./stargz.md`](./stargz.md) for details).
- `--estargz-external-toc` : Separate TOC JSON into another image (called \"TOC image\"). The name of TOC image is the original + \"-esgztoc\" suffix. Both eStargz and the TOC image should be pushed to the same registry. (requires stargz-snapshotter >= v0.13.0) Useful for creating a smaller eStargz image (refer to [`./stargz.md`](./stargz.md) for details). :warning: This flag is experimental and subject to change.
- `--estargz-keep-diff-id`: Convert to esgz without changing diffID (cannot be used in conjunction with '--estargz-record-in'. must be specified with '--estargz-external-toc')
- `--zstd` : Use zstd compression instead of gzip (a.k.a zstd). Should be used in conjunction with '--oci'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(a.k.a zstd) is unneeded maybe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. updated

Signed-off-by: Henry Wang <henwang@amazon.com>
@AkihiroSuda AkihiroSuda merged commit 21ac3a5 into containerd:main Sep 28, 2023
21 checks passed
@henry118 henry118 deleted the zstd branch September 29, 2023 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants