Remove decompression benchmark, use sync.Once for initialization

Benchmark gist: https://git.io/fASMy

Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
This commit is contained in:
Maksym Pavlenko
2018-09-18 17:09:12 -07:00
parent 003b27eff4
commit e8fac24e7b
2 changed files with 14 additions and 94 deletions

View File

@@ -45,13 +45,10 @@ const (
const disablePigzEnv = "CONTAINERD_DISABLE_PIGZ"
var unpigzPath string
func init() {
if unpigzPath = detectPigz(); unpigzPath != "" {
log.L.Debug("using pigz for decompression")
}
}
var (
initPigz sync.Once
unpigzPath string
)
var (
bufioReader32KPool = &sync.Pool{
@@ -176,6 +173,12 @@ func (compression *Compression) Extension() string {
}
func gzipDecompress(ctx context.Context, buf io.Reader) (io.ReadCloser, error) {
initPigz.Do(func() {
if unpigzPath = detectPigz(); unpigzPath != "" {
log.L.Debug("using pigz for decompression")
}
})
if unpigzPath == "" {
return gzip.NewReader(buf)
}