From ae8836fa448edee9924ea87b2283dbe206fd1131 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 10 Jun 2024 22:42:12 +0200 Subject: [PATCH] archive: use zstd if available the performance improvement is not as clear as with pigz, but it is still measurable difference. Signed-off-by: Giuseppe Scrivano --- pkg/archive/archive.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index 45d581c053..a2525c9675 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -220,6 +220,12 @@ func DecompressStream(archive io.Reader) (_ io.ReadCloser, Err error) { readBufWrapper := p.NewReadCloserWrapper(buf, xzReader) return readBufWrapper, nil case Zstd: + cleanup := func() { + p.Put(buf) + } + if rc, canUse := tryProcFilter([]string{"zstd", "-d"}, buf, cleanup); canUse { + return rc, nil + } return zstdReader(buf) default: return nil, fmt.Errorf("unsupported compression format %s", (&compression).Extension())