Repository navigation
Description
(this was manually written, reviewed between humans, and using a spellcheck! :-))
Gzip compression is dated. A lot of work has gone into supporting modern methods (e.g., zstd), but gzip remains deeply entrenched in the OCI ecosystem: 15 of 15 surveyed popular images ship only gzip layers. Because of this ubiquity, gzip decompression now frequently dominates end-to-end container image pull durations (especially in cloud and datacenter environments).
To illustrate this bottleneck, consider a real-world scenario for docker.io/tensorflow/tensorflow:2.21.0-gpu's largest OCI layer (2.7 GiB, 2nd-largest is much smaller):
- Fetch: ~15 s (Docker Hub -> EC2 VM, single TCP connection).1
- Inflate gzip: ~30 s with Go stdlib (35 s on Xeon 8488C, 33 s on NVIDIA Grace, 70 s on my laptop).
- Decode tar: << 2 s (any modern system).
- Persist: << 10 s (reasonable 'local' storage).
Fetching, decompressing, and writing to storage happen in a streaming-like fashion. The slowest link in this pipeline dictates the total duration. Here, the total time to "pull" is not I/O-bound but CPU-bound instead, dictated by single-core gzip decompression speed.
The abundance and impact of this bottleneck have become larger over time for two reasons:
- People run more machine learning workloads. Images in that landscape often have one dominant layer, and they are typically shipped as gzip-only2.
- I/O seems to be getting faster on both the output and input sides of gzip decompression.
Let's put gzip and I/O in perspective:
- Decoding a gzip stream is serial work (the dominant layer governs total decompression time in a multi-core environment).
- Most gzip decompression implementations (incl. Golang's) have an output rate upper bound of approximately 200-400 MiB/s on beefy CPUs. For typical compression ratios of roughly 2, that means that decompression ingests only around 100 MiB/s. Higher compression ratios reduce the ingest rate.
- A typical, in-region container registry often feeds data faster than 100 MiB/s.3
- Writing the decompressed data to local storage is typically again much faster.
Solutions?
Making gzip decompression faster
We should look into speeding up containerd's default gzip decompression method (without compromising security or maintainability). Currently, that is Golang's standard library implementation. An easy win would be to adopt klauspost's mature drop-in replacement. It typically decompresses 1.2 to 1.6 times faster while making fewer memory allocations.4 For example, when experimenting with a TensorFlow image, extraction time dropped from 33 to 22 seconds. An incremental improvement like this can have noticeable user-facing impact (such as reducing a container's cold-start time from 15 seconds to 10) and ultimately translates to significant cumulative CPU time savings globally.
We plan to submit a PR to introduce klauspost/compress/gzip with supporting data and discussion. (update: #13560)
Notably, containerd can optionally use Intel's ISA-L binaries to accelerate gzip decompression to around 1 GiB per second per CPU core. However, this is likely rarely enabled in production (due to concerns around licensing, security, platform support, and potentially a lack of awareness). Potentially, the ISA-L route can be explored further, but it is less of a no-brainer.
Multi-format images and everything else
Solution space has much more to offer, and one of the most important directions is for the community to migrate away from publishing gzip-only images.
It's worth finding and evangelizing an OCI-compliant and fully backwards-compatible approach to publishing multi-format images. Owners can then be nudged to publish modern distribution formats in addition to publishing gzip. Old clients would still consume gzip-compressed layers. Modern clients can (if necessary) be tuned to prefer the most efficient available format.
Context/disclaimer
Container image distribution and end-to-end propagation (of full images as well as of updates) often involve significant resource waste (storage, network bandwidth, CPU time, human time). We (@klueska and I) are currently exploring how we can help with some of that. It's still early days. We're looking at a wide space of solutions, and optimizing gzip decompression is something that popped out early on as a low-effort/high-impact lever.
Appendix: Surveyed images and related threads
Table 1: Largest layer of popular images, and measured decompression time (all surveyed images are published gzip-only at the time of writing; the table below just shows five of the 15 inspected ones). Decode time is the measured wall time to gzip-decompress the largest layer on a single core (Go 1.26.3 stdlib, ARM64 NVIDIA Grace).
| Image | Largest layer | gzip decode (Go stdlib) |
|---|---|---|
| nvcr.io/nvidia/pytorch:24.10-py3 | 4,185 MiB | ~49 s |
| docker.io/pytorch/pytorch:latest | 3,455 MiB | ~41 s |
| docker.io/tensorflow/tensorflow:latest-gpu | 2,803 MiB | ~33 s |
| nvcr.io/nvidia/cuda:13.1.2-devel-ubi9 | 2,028 MiB | ~17 s |
| docker.io/library/python:3.12 | 225 MiB | ~2.7 s |
Related threads
- containerd#2640:
igzip/unpigzsupport. - containerd#8881: parallel layer decompression.
- golang/go#75532: Golang 1.27 flate speedup (not inflate).
- kubernetes#104071: perf discussion for kube-apiserver (encode side).
Footnotes
-
EC2 instance, single HTTP GET request against
https://registry-1.docker.io(anonymous); n=6 repetitions yielded (234 ± 18) MiB/s ingest bandwidth. ↩ -
In the ML space, the dominant layer of popular images is often several gigabytes in size, and 15 of 15 surveyed popular images ship only gzip layers (at the time of writing). ↩
-
A typical CPU core inflates gzip-compressed OCI layers of popular ML images at, say, ~80-200 MiB/s (on the input side). A single TCP connection to an in-region registry delivers ~300-900 MiB/s (ballpark, of course every environment is different, and actual NIC bandwidth is even higher in modern cloud/DC environments). The general point is: large gzip-compressed byte sequences can be fed to a machine at very high bandwidth, only to then be squeezed slowly through a single CPU core for decompression. ↩
-
According to our brief experimentation; we will share data in a PR description. ↩
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
ningmingxiao commentedon Jun 9, 2026
can you show the time when use new library @jgehrcke
jgehrcke commentedon Jun 9, 2026
@ningmingxiao thanks for looking!
What would you like to see, specifically?
A quote from above:
In addition, there's some more data in #13560.
We did more exhaustive measurements, also some for x86. I can share more data points if you point me into a specific direction. In general, I think we should have most of the klauspost-specific discussion on #13560 now.
pkg/archive/compression: use klauspost/compress/gzip for decode
pkg/archive/compression: use klauspost/compress/gzip for decode
pkg/archive/compression: use klauspost/compress/gzip for decode
slonopotamus commentedon Jul 10, 2026
Background: I am working with 50+ GB images. I strongly suspect that most images are still gzip nowadays and not zstd because 1. it is very nontrivial to make
docker build(which I believe to be the most popular way to build images) produce a zstd image and 2. all image building tools default to gzip. Don't try to fix gzip, it is futile. Make it easier to produce zstd images instead.