Skip to content

crypto/aes: linux/arm64 Go 1.9 performance is +20X slower than OpenSSL #22808

Closed
@williamweixiao

Description

@williamweixiao

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 linux/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="arm64"
GOBIN=""
GOEXE=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_arm64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

What did you do?

go test crypto/cipher -bench GCM

What did you expect to see?

Performance can be on par with OpenSSL (https://blog.cloudflare.com/content/images/2017/11/sym_key_1_core.png)

What did you see instead?

+20X slower than OpenSSL( https://blog.cloudflare.com/content/images/2017/11/go_sym_key_1_core.png)

Activity

as

as commented on Nov 20, 2017

@as
Contributor
C:\Users\as>go test crypto/cipher -bench GCM
goos: windows
goarch: amd64
pkg: crypto/cipher
BenchmarkAESGCMSeal1K-4          5000000               314 ns/op        3260.87 MB/s
BenchmarkAESGCMOpen1K-4          5000000               276 ns/op        3705.65 MB/s
BenchmarkAESGCMSeal8K-4          1000000              1732 ns/op        4728.25 MB/s
BenchmarkAESGCMOpen8K-4          1000000              1721 ns/op        4758.42 MB/s
PASS
ok      crypto/cipher   7.189s

12.5MBps is exactly 100Mbps. This number seems too round to ignore, any thoughts on why it won't exceed the speed of a "fast ethernet" network interface? It would help to see the benchmark's output from your system as well.

added this to the Unplanned milestone on Nov 20, 2017
williamweixiao

williamweixiao commented on Nov 20, 2017

@williamweixiao
MemberAuthor

Following is the result I got from some typical arm64 platform:

go test crypto/cipher -bench GCM
goos: linux
goarch: arm64
pkg: crypto/cipher
BenchmarkAESGCMSeal1K-32 50000 35735 ns/op 28.65 MB/s
BenchmarkAESGCMOpen1K-32 50000 35858 ns/op 28.56 MB/s
BenchmarkAESGCMSeal8K-32 5000 285102 ns/op 28.73 MB/s
BenchmarkAESGCMOpen8K-32 5000 278226 ns/op 29.44 MB/s
PASS
ok crypto/cipher 7.199s

as

as commented on Nov 20, 2017

@as
Contributor

Taking a second look at the results and seeing arm64 instead of amd64, I realize the reason has already been stated in prior discussions: no assembly implementations for the platform. It's probably safe to disregard my previous inquisition.

matt2909

matt2909 commented on Nov 21, 2017

@matt2909
Contributor

This looks to be a duplicate of #18498

titanous

titanous commented on Nov 21, 2017

@titanous
Member

Duplicate of #18498. Closing.

gopherbot

gopherbot commented on Nov 22, 2017

@gopherbot
Contributor

Change https://golang.org/cl/64490 mentions this issue: crypto/aes: optimize arm64 AES implementation

vielmetti

vielmetti commented on Jun 26, 2018

@vielmetti

On arm64, Packet Type 2A / c1.large.arm Cavium ThunderX:

ed@ed-2a-bcc-llvm:~$ go test crypto/cipher -bench GCM

goos: linux
goarch: arm64
pkg: crypto/cipher
BenchmarkAESGCMSeal1K-96           20000             68788 ns/op          14.89 MB/s
BenchmarkAESGCMOpen1K-96           20000             68697 ns/op          14.91 MB/s
BenchmarkAESGCMSign8K-96           10000            182114 ns/op          44.98 MB/s
BenchmarkAESGCMSeal8K-96            3000            536359 ns/op          15.27 MB/s
BenchmarkAESGCMOpen8K-96            3000            537432 ns/op          15.24 MB/s
PASS
ok      crypto/cipher   9.404s
ed@ed-2a-bcc-llvm:~$ 
ed@ed-2a-bcc-llvm:~$ go version
go version go1.10.2 linux/arm64
ed@ed-2a-bcc-llvm:~$ ~/go/bin/go1.11beta1 test crypto/cipher -bench GCM
goos: linux
goarch: arm64
pkg: crypto/cipher
BenchmarkAESGCMSeal1K-96           50000             37520 ns/op          27.29 MB/s
BenchmarkAESGCMOpen1K-96           50000             37550 ns/op          27.27 MB/s
BenchmarkAESGCMSign8K-96           10000            172278 ns/op          47.55 MB/s
BenchmarkAESGCMSeal8K-96            5000            289794 ns/op          28.27 MB/s
BenchmarkAESGCMOpen8K-96            5000            288511 ns/op          28.39 MB/s
PASS
ok      crypto/cipher   9.274s

1.11beta1 is substantially faster than 1.10.2.

locked and limited conversation to collaborators on Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bradfitz@titanous@vielmetti@matt2909@as

        Issue actions

          crypto/aes: linux/arm64 Go 1.9 performance is +20X slower than OpenSSL · Issue #22808 · golang/go