Use Intel ISA-L's igzip if available

Intel ISA-L is Intel's open source (BSD) library that outperforms both
gzip and pigz. This commit checks and uses igzip if available.

Signed-off-by: Kazuyoshi Kato <kaz@fly.io>
This commit is contained in:
Kazuyoshi Kato
2023-10-05 22:11:14 -07:00
parent 66aab638da
commit 34378ec9b4
3 changed files with 46 additions and 28 deletions

View File

@@ -20,6 +20,7 @@ import (
"fmt"
"io"
"net/http"
"os/exec"
"testing"
"github.com/stretchr/testify/require"
@@ -49,19 +50,30 @@ func BenchmarkDecompression(b *testing.B) {
zstd := testCompress(b, data, Zstd)
b.Run(fmt.Sprintf("size=%dMiB", sizeInMiB), func(b *testing.B) {
b.Run("gzip", func(b *testing.B) {
testDecompress(b, gz)
})
original := gzipPath
defer func() {
gzipPath = original
}()
b.Run("zstd", func(b *testing.B) {
testDecompress(b, zstd)
})
if unpigzPath != "" {
original := unpigzPath
unpigzPath = ""
b.Run("gzipPureGo", func(b *testing.B) {
gzipPath = ""
b.Run("gzipPureGo", func(b *testing.B) {
testDecompress(b, gz)
})
gzipPath, err = exec.LookPath("igzip")
if err == nil {
b.Run("igzip", func(b *testing.B) {
testDecompress(b, gz)
})
}
gzipPath, err = exec.LookPath("unpigz")
if err == nil {
b.Run("unpigz", func(b *testing.B) {
testDecompress(b, gz)
})
unpigzPath = original
}
})
}