Skip to content

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

@rfjakob

Description

@rfjakob

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions