Crypto:pkey_sign_nif/5 performance issue

So I’m debugging a performance issue and from my analysis with eprof 86% of the request time was spent in [eprof]( (which was only called 4 times during the tracing).

The code in question is just doing :public_key.sign(string, :sha, private_key). Is there a way to improve the performance of that call? Or do I need to avoid it in hot paths?

That sounds like a call that is inherently expensive so I’m not sure if you can improve the performance of it.

I would except that there is a reason is for encrypting the data, so I’m not sure if you can just remove the call?

It’s possible that there are some other encryption options that are faster but I have no idea about it and if they’re equally secure

Which signature algorithm are you using? Some are more performant than others, here is a nice benchmark comparing raw performance of RSA, EC and EdDSA for the same level of security. All are supported by OTP (although support of EdDSA is very recent, I think).

1 Like

Okay, that makes sense. Thanks for the replies @tcoopman and @tangui. I’ll just change things so that this isn’t in the hot-path anymore.