Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/crypto/chacha20poly1305: 15% performance regression on certain cpus #67240

Open
rfjakob opened this issue May 7, 2024 · 3 comments
Open

x/crypto/chacha20poly1305: 15% performance regression on certain cpus #67240

rfjakob opened this issue May 7, 2024 · 3 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@rfjakob
Copy link

rfjakob commented May 7, 2024

Go version

go1.22.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jakob/.cache/go-build'
GOENV='/home/jakob/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jakob/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jakob/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/jakob/go/src/github.com/rfjakob/gocryptfs/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2175247311=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Hi, I have a user reporting a 15% performance regression in gocryptfs ( rfjakob/gocryptfs#828 ) due to change #63871 .

The CPU is Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz so I guess too old for AVX but it does have PSHUFB.

Can PSHUFB be detected at runtime instead?

Reproducer is the built-in gocryptfs speed test:

./gocryptfs -speed

What did you see happen?

With go 1.22: Slow XChaCha20-Poly1305

gocryptfs v2.4.0-15-g9958b63; go-fuse [vendored]; 2024-03-03 go1.22.0 linux/amd64
cpu: Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz; no AES acceleration
[...]
XChaCha20-Poly1305-Go            616.01 MB/s    (selected in auto mode)

What did you expect to see?

With go 1.21: Fast XChaCha20-Poly1305

gocryptfs v2.4.0; go-fuse [vendored]; 2023-10-12 go1.21.3 linux/amd64
cpu: Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz; no AES acceleration
[...]
XChaCha20-Poly1305-Go            728.97 MB/s    (selected in auto mode)
@randall77
Copy link
Contributor

That processor is 13 years old now.
We could make the check dynamic if not building with GOAMD64=v2 or better. The challenge is how do we test that code? I suspect we don't have any processors without PSHUFB support in our trybot fleet.
GODEBUG=cpu.X=off for the right value of X might be enough, not sure.

@cherrymui cherrymui added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label May 7, 2024
@cherrymui cherrymui added this to the Unreleased milestone May 7, 2024
@mauri870
Copy link
Member

mauri870 commented May 8, 2024

There is more discussion going on at #63872 to discuss how to test GOAMD64=v1 features in the builder fleet.

@rfjakob
Copy link
Author

rfjakob commented May 8, 2024

I suspect we don't have any processors without PSHUFB support in our trybot fleet.

The CPU in question does have PSHUFB. Looking at https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels, this makes it a x86-64-v2 CPU.

So the question is more about testing on x86-64-v2. I guess the trybot fleet is x86-64-v3 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants