Go version

go 1.25.0 linux/amd64

Output of go env in your module/workspace:

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

What did you do?

benchmark chacha20

What did you see happen?

BenchmarkAES256GCM-2              301892              4369 ns/op        1875.05 MB/s
BenchmarkAES256CTR-2              794265              1505 ns/op        5443.42 MB/s
BenchmarkChaCha20Poly1305-2       230552              5786 ns/op        1415.79 MB/s
BenchmarkChaCha20-2                84082             14384 ns/op         569.52 MB/s        ←here, slower than AEAD

What did you expect to see?

A stream cipher should be at least faster than AEAD with it It's ok on AES256CTR/AES256GCM but chacha20 is slower than chacha20-poly1305, that's very strange I write a benchmark https://github.com/Fangliding/go-encrypt-test/blob/main/main_test.go and here is the result https://github.com/Fangliding/go-encrypt-test/actions/runs/17172546494/job/48724094779

chacha20 is very slow, it seems that some optimization is missing

Comment From: gabyhelp

Related Issues

Related Code Changes

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: cherrymui

cc @FiloSottile @rolandshoemaker @cpu @golang/security