diff --git a/cmd/object-api-utils.go b/cmd/object-api-utils.go index a71cea3bf..961be2f7b 100644 --- a/cmd/object-api-utils.go +++ b/cmd/object-api-utils.go @@ -884,6 +884,16 @@ func CleanMinioInternalMetadataKeys(metadata map[string]string) map[string]strin return newMeta } +// compressOpts are the options for writing compressed data. +var compressOpts []s2.WriterOption + +func init() { + if runtime.GOARCH == "amd64" { + // On amd64 we have assembly and can use stronger compression. + compressOpts = append(compressOpts, s2.WriterBetterCompression()) + } +} + // newS2CompressReader will read data from r, compress it and return the compressed data as a Reader. // Use Close to ensure resources are released on incomplete streams. // @@ -894,7 +904,7 @@ func newS2CompressReader(r io.Reader, on int64) io.ReadCloser { pr, pw := io.Pipe() // Copy input to compressor go func() { - comp := s2.NewWriter(pw) + comp := s2.NewWriter(pw, compressOpts...) cn, err := io.Copy(comp, r) if err != nil { comp.Close() diff --git a/go.mod b/go.mod index dd8ccf46a..666f80fdf 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/jcmturner/gokrb5/v8 v8.4.2 github.com/json-iterator/go v1.1.11 - github.com/klauspost/compress v1.13.3 + github.com/klauspost/compress v1.13.4 github.com/klauspost/cpuid/v2 v2.0.4 github.com/klauspost/pgzip v1.2.5 github.com/klauspost/readahead v1.3.1 diff --git a/go.sum b/go.sum index cb7df0d64..ddc076e24 100644 --- a/go.sum +++ b/go.sum @@ -881,8 +881,8 @@ github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.12/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.3 h1:BtAvtV1+h0YwSVwWoYXMREPpYu9VzTJ9QDI1TEg/iQQ= -github.com/klauspost/compress v1.13.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s= +github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=