cisco/libsrtp

Unexpectedly high CPU usage

zhngs opened this issue · 2 comments

zhngs commented

image

I found that the CPU consumption of SRTP library in the flame diagram of a well-working streaming media server is unexpectedly high. I think that encryption and decryption should not consume so much CPU. Is this a normal phenomenon?

There are a few areas where this can be expensive:

  1. Encryption (AES -- and I see that here)
  2. Authentication (SHA-1 is clearly consuming time here)
  3. Looking up SSRCs if you have a really large list of SSRCs

Perhaps (3) has already been addressed; I cannot remember, but it used to be a problem. Regardless, it's good to always remove unused SSRC and not let those pile up. (That is, delete unused / old streams.)

(1) is just the cost of encryption, but if you linked with OpenSSL, it will offload that work onto the CPU (assuming it has AES support).

(2) is also just the cost of authentication, and even OpenSSL cannot offload that to the CPU. However, if you use GCM for authentication, rather than SHA-1, you will see that it requires less CPU processing.

zhngs commented

Thanks for the answer, it is very helpful!