-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
crypto: understand performance differences compared to BoringSSL #21525
Comments
Cc'ing @agl |
The other points may require a closer look - very nice to bring this up 👍 |
This issue should have a "Performance" label. |
/cc-ing @FiloSottile too |
@rsc it any update for this? Where can I see the latest go-BoringSSL benchmark? |
@rsc - Looks like you created some kind of automated benchmarking speed. Any chance to share the scripts so we can repeat the test?
Thanks! |
So I accidentally discovered that I can easily run benchmark on builtin packages by running I've created a script" # this is for go 1.19 + that supports using boringcrypto by simply setting env variable
go version
go install golang.org/x/perf/cmd/benchstat@latest
echo "=========================="
echo "BENCHMARK WITHOUT BORINGSSL"
echo "=========================="
go test -bench=. crypto/... -count 5 | tee old.txt
echo "=========================="
echo "BENCHMARK WITH BORINGSSL"
echo "=========================="
GOEXPERIMENT=boringcrypto go test -bench=. crypto/... -count 5 | tee new.txt
benchstat old.txt new.txt | tee benchmark_comparison.txt If you'll confirm this script is actually what I need to run - I'm more than happy to share the results. |
I ran all the crypto benchmarks with standard Go crypto and with BoringCrypto. Results below.
In general there is about a 200ns overhead to calling into BoringCrypto via cgo for a particular call. So for example aes.BenchmarkEncrypt (testing encryption of a single 16-byte block) went from 13ns to 209ns, or +1500%. That we can't do much about except hope that bulk operations call into cgo once instead of once per 16 bytes.
But there are also some mysteries or things to consider fixing. I've put this in milestone Go 1.10 because some of them may be bugs in the Go distribution that we should at least understand. Once we know that the problems are all on the dev.boringcrypto side, we can switch the milestone to Unreleased.
crypto/aes
crypto/ecdsa
crypto/hmac
crypto/rsa
Benchmark results (also at https://perf.golang.org/search?q=upload:20170818.4):
The text was updated successfully, but these errors were encountered: