Closed jmillan closed 11 months ago
Is list traversal that expensive, what kind of difference are we talking about here?
Data added in the PR description. As the number of streams per context increase, the difference is bigger. Here an extreme case where the list traversal takes more than encrypting:
It uses a list hash rather than a single list to store stream contexts.
By distributing the stream contexts in multiple lists (32) we enhance the list traversal time for the stream we are looking, by 32 times in the best case.
I made a PR in the project but it didn't succeed https://github.com/cisco/libsrtp/pull/659
They'll work on a different solution. In the meantime we can use this approach. It saves 2% CPU for a Router with 1 AV Producer and 40 A/V Consumers. The gains are bigger as the number of Consumers increase.