libsrtp icon indicating copy to clipboard operation
libsrtp copied to clipboard

srtp_get_stream is O(n)

Open JonathanLennox opened this issue 6 years ago • 2 comments

LibSRTP stores every ssrc's srtp_stream_ctx_t in a linked list. This means that finding the appropriate context for an ssrc is an O(n) operation. In a large conference, this can be a noticeable performance cost.

A hash table would probably be the best option here.

JonathanLennox avatar Jul 11 '18 19:07 JonathanLennox

Fully agree. The SSRC lookup can be painfully slow if there are lot of them. Since these are (in theory) supposed to be random values, a tree might prove to be fairly well balanced most of the time without much effort.

paulej avatar Jul 11 '18 19:07 paulej

We have extracted the current stream list implementation and create an internal api + default linked list implementation in the following PR https://github.com/cisco/libsrtp/pull/612

While this does not allow to plug-in a custom implementation dynamically, it allows compiling libsrtp without the default list implementation and replace it with a custom one instead.

murillo128 avatar Sep 07 '22 08:09 murillo128