go-digest icon indicating copy to clipboard operation
go-digest copied to clipboard

consider using sha256-simd

Open rchincha opened this issue 4 years ago • 5 comments

Considering the impressive perf gains, thoughts about pulling this in?

https://github.com/minio/sha256-simd

rchincha avatar Dec 04 '21 04:12 rchincha

SGTM

AkihiroSuda avatar Dec 05 '21 17:12 AkihiroSuda

@rchincha Do you plan to submit a PR?

AkihiroSuda avatar Feb 08 '22 05:02 AkihiroSuda

@AkihiroSuda perhaps best to wait for this discussion to resolve. https://github.com/golang/go/issues/50543

rchincha avatar Feb 08 '22 17:02 rchincha

The concerns on the Go issues are mostly around licensing. I think https://github.com/minio/sha256-simd/ is a different implementation that is apache2 licensed?

I pulled in the same library into go-containerregistry, which we use to build our images, and it was over 2x speedup in pushing images, so a huge improvement

howardjohn avatar Mar 31 '22 15:03 howardjohn

Yes, and as I see it, couple of decisions to make here: 1) this perf improvement applicable only if CPU has sha_ni extensions available, and 2) do you want to wait for this to land in golang proper instead (for better support perhaps).

rchincha avatar Mar 31 '22 16:03 rchincha

This might suffice to enable the simdized hasher:

package example

import (
  "crypto"
  sha256simd "github.com/minio/sha256-simd"
)

func init() {
  crypto.RegisterHash(crypto.SHA256, sha256simd.New)
}

e.g.,

  • https://github.com/containerd/containerd/pull/7732

AkihiroSuda avatar Nov 29 '22 04:11 AkihiroSuda