Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RSA/ECDSA throughput can't be significantly improved because the bottleneck is in the OpenSSL cgo call that performs the crypto heavy lifting, namely EVP_PKEY_encrypt, EVP_PKEY_decrypt, EVP_PKEY_sign, or EVP_PKEY_verify. These accounts for ~93% of the processing time.
Batching cgo calls nor reducing GC pressure help increase the throughput because we are at the order of 10.000 ns/op, much higher than the ~60ns cgo overhead and whatever the GC latency has.
On the other hand, we can reduce the allocations by defining
EVP_PKEY
andEVP_PKEY_CTX
pointer types in C instead of Go. This trick avoids filling Go heap with unnecessary pointers unless strictly necessary.This PR only adds a benchmark for EncryptRSAPKCS1. All rsa/ecdsa functions are implemented reusing almost the same code so benchmarking one is representative enough.
The result is that we have not improved throughput, but we have reduced allocated memory and objects.