From d0a43af61688353de3dbda70d038aaf266cd4a61 Mon Sep 17 00:00:00 2001 From: Andreas Auernhammer Date: Wed, 17 Jan 2018 19:54:31 +0100 Subject: [PATCH] replace all "crypto/sha256" with "github.com/minio/sha256-simd" (#5391) This change replaces all imports of "crypto/sha256" with "github.com/minio/sha256-simd". The sha256-simd package is faster on ARM64 (NEON instructions) and can take advantage of AVX-512 in certain scenarios. Fixes #5374 --- cmd/gateway/azure/gateway-azure.go | 2 +- cmd/retry-storage_test.go | 3 ++- cmd/update-main.go | 2 +- cmd/xl-v1-metadata.go | 2 +- pkg/hash/reader.go | 3 ++- pkg/madmin/utils.go | 3 ++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/gateway/azure/gateway-azure.go b/cmd/gateway/azure/gateway-azure.go index c135a5b46..4365bf1b1 100644 --- a/cmd/gateway/azure/gateway-azure.go +++ b/cmd/gateway/azure/gateway-azure.go @@ -19,7 +19,6 @@ package azure import ( "bytes" "crypto/rand" - "crypto/sha256" "encoding/base64" "encoding/hex" "encoding/json" @@ -38,6 +37,7 @@ import ( "github.com/minio/minio/pkg/auth" "github.com/minio/minio/pkg/errors" "github.com/minio/minio/pkg/hash" + sha256 "github.com/minio/sha256-simd" minio "github.com/minio/minio/cmd" ) diff --git a/cmd/retry-storage_test.go b/cmd/retry-storage_test.go index 28d9af5c0..5fa1ead11 100644 --- a/cmd/retry-storage_test.go +++ b/cmd/retry-storage_test.go @@ -18,12 +18,13 @@ package cmd import ( "bytes" - "crypto/sha256" "errors" "os" "reflect" "testing" "time" + + sha256 "github.com/minio/sha256-simd" ) // Tests retry storage. diff --git a/cmd/update-main.go b/cmd/update-main.go index 5adb2bba4..b40f3fea0 100644 --- a/cmd/update-main.go +++ b/cmd/update-main.go @@ -19,7 +19,6 @@ package cmd import ( "bufio" "crypto" - _ "crypto/sha256" // Needed for sha256 hash verifier. "encoding/hex" "fmt" "io/ioutil" @@ -33,6 +32,7 @@ import ( "github.com/fatih/color" "github.com/inconshreveable/go-update" "github.com/minio/cli" + _ "github.com/minio/sha256-simd" // Needed for sha256 hash verifier. "github.com/segmentio/go-prompt" ) diff --git a/cmd/xl-v1-metadata.go b/cmd/xl-v1-metadata.go index 7a65cc737..c7d24da55 100644 --- a/cmd/xl-v1-metadata.go +++ b/cmd/xl-v1-metadata.go @@ -18,7 +18,6 @@ package cmd import ( "crypto" - "crypto/sha256" "encoding/hex" "encoding/json" "fmt" @@ -30,6 +29,7 @@ import ( "time" "github.com/minio/minio/pkg/errors" + sha256 "github.com/minio/sha256-simd" "golang.org/x/crypto/blake2b" ) diff --git a/pkg/hash/reader.go b/pkg/hash/reader.go index 832ef64cb..31981135b 100644 --- a/pkg/hash/reader.go +++ b/pkg/hash/reader.go @@ -19,12 +19,13 @@ package hash import ( "bytes" "crypto/md5" - "crypto/sha256" "encoding/base64" "encoding/hex" "errors" "hash" "io" + + sha256 "github.com/minio/sha256-simd" ) var errNestedReader = errors.New("Nesting of Reader detected, not allowed") diff --git a/pkg/madmin/utils.go b/pkg/madmin/utils.go index 34aa80618..5e1163295 100644 --- a/pkg/madmin/utils.go +++ b/pkg/madmin/utils.go @@ -18,7 +18,6 @@ package madmin import ( "crypto/md5" - "crypto/sha256" "encoding/xml" "io" "io/ioutil" @@ -27,6 +26,8 @@ import ( "net/url" "strings" + sha256 "github.com/minio/sha256-simd" + "github.com/minio/minio-go/pkg/s3utils" )