diff options
author | Meng Zhuo <mengzhuo1203@gmail.com> | 2018-04-04 13:15:22 +0800 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-04-04 16:25:39 +0000 |
commit | 73e0c302b2bcf26c009f682c2c11ef3567854d46 (patch) | |
tree | 8769fd8e6fa921267ea7befd324ed8c676b25311 /src/runtime/alg.go | |
parent | 28c1ad9d35f27b3b57afff4ee78faac746a8ed0a (diff) | |
download | go-73e0c302b2bcf26c009f682c2c11ef3567854d46.tar.gz go-73e0c302b2bcf26c009f682c2c11ef3567854d46.zip |
runtime: implement aeshash for arm64 platform
Fix #10109
name old time/op new time/op delta
Hash5 72.3ns ± 0% 51.5ns ± 0% -28.71% (p=0.000 n=4+5)
Hash16 78.8ns ± 0% 48.7ns ± 0% ~ (p=0.079 n=4+5)
Hash64 196ns ±25% 73ns ±16% -62.68% (p=0.008 n=5+5)
Hash1024 1.57µs ± 0% 0.27µs ± 1% -82.90% (p=0.000 n=5+4)
Hash65536 96.5µs ± 0% 14.3µs ± 0% -85.14% (p=0.016 n=5+4)
HashStringSpeed 156ns ± 6% 129ns ± 3% -17.56% (p=0.008 n=5+5)
HashBytesSpeed 227ns ± 1% 200ns ± 1% -11.98% (p=0.008 n=5+5)
HashInt32Speed 116ns ± 2% 102ns ± 0% -11.92% (p=0.016 n=5+4)
HashInt64Speed 120ns ± 3% 101ns ± 2% -15.55% (p=0.008 n=5+5)
HashStringArraySpeed 342ns ± 0% 306ns ± 2% -10.58% (p=0.008 n=5+5)
FastrandHashiter 217ns ± 1% 217ns ± 1% ~ (p=1.000 n=5+5)
name old speed new speed delta
Hash5 69.1MB/s ± 0% 97.0MB/s ± 0% +40.32% (p=0.008 n=5+5)
Hash16 203MB/s ± 0% 329MB/s ± 0% +61.76% (p=0.016 n=4+5)
Hash64 332MB/s ±21% 881MB/s ±14% +165.66% (p=0.008 n=5+5)
Hash1024 651MB/s ± 0% 3652MB/s ±17% +460.73% (p=0.008 n=5+5)
Hash65536 679MB/s ± 0% 4570MB/s ± 0% +572.85% (p=0.016 n=5+4)
Change-Id: I573028979f84cf2e0e087951271d5de8865dbf04
Reviewed-on: https://go-review.googlesource.com/89755
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/alg.go')
-rw-r--r-- | src/runtime/alg.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/runtime/alg.go b/src/runtime/alg.go index 89125f48ba..cc723e49e2 100644 --- a/src/runtime/alg.go +++ b/src/runtime/alg.go @@ -272,25 +272,24 @@ func ifaceHash(i interface { const hashRandomBytes = sys.PtrSize / 4 * 64 -// used in asm_{386,amd64}.s to seed the hash function +// used in asm_{386,amd64,arm64}.s to seed the hash function var aeskeysched [hashRandomBytes]byte // used in hash{32,64}.go to seed the hash function var hashkey [4]uintptr func alginit() { - // Install aes hash algorithm if we have the instructions we need + // Install AES hash algorithms if the instructions needed are present. if (GOARCH == "386" || GOARCH == "amd64") && GOOS != "nacl" && support_aes && // AESENC support_ssse3 && // PSHUFB support_sse41 { // PINSR{D,Q} - useAeshash = true - algarray[alg_MEM32].hash = aeshash32 - algarray[alg_MEM64].hash = aeshash64 - algarray[alg_STRING].hash = aeshashstr - // Initialize with random data so hash collisions will be hard to engineer. - getRandomData(aeskeysched[:]) + initAlgAES() + return + } + if GOARCH == "arm64" && arm64_support_aes { + initAlgAES() return } getRandomData((*[len(hashkey) * sys.PtrSize]byte)(unsafe.Pointer(&hashkey))[:]) @@ -299,3 +298,12 @@ func alginit() { hashkey[2] |= 1 hashkey[3] |= 1 } + +func initAlgAES() { + useAeshash = true + algarray[alg_MEM32].hash = aeshash32 + algarray[alg_MEM64].hash = aeshash64 + algarray[alg_STRING].hash = aeshashstr + // Initialize with random data so hash collisions will be hard to engineer. + getRandomData(aeskeysched[:]) +} |