-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RtpStreamSend: Memory optimizations #840
Conversation
#675 is extremely big and difficult to review. This is the Nth split I make out of that PR. Let's never do such big PR again with many different kind of changes, it's too time consuming and it takes too much time to get them merged. AFAIK, after this only the object pool stuff would be missing. Please, do dedicate some time reviewing. I've tested it and the memory savings big. I have made some extra enhancements such as not cloning the RTP packet not even for sending DTX. |
Also @nazar-pc , removed the |
Note: I'll write more tests. |
Essentially extracted from #675 * RtpStreamSend does not clone each RTP packet coming from Producer. - A std::shared_ptr holding the original packet is used by all RtpStreamSend instances. * RtpStreamSend does not clone each RTP packet when sending DTX. - The original RTP packet is DTX encoded/decoded when needed. * RtpStreamSend does not store up to 65536 RTP packets in a std::map. - Only a limited range of RTP packets are stored in a std::deque.
f17d5f9
to
c5495a6
Compare
Do not return boolean. False was never being returned.
Remove unrelated asserts.
@nazar-pc, could you please look at the Rust CI error? |
I'm checking |
OMG YES. static members initialization must be done in cpp files. |
Not required for numeric variables as per the spec. Indeed |
Prove that we initialize any static class numeric variable the way it was done in this PR before. |
I didn't say otherwise. |
Great problem I've found with the approach in this PR. A This means that such payload pointer will get invalidated once the next packet arrives. This is the reason why the original PR did a |
Indeed. Just wondering, didn't this bug produce terrible issues already? It shouldn't be hard to reproduce AFAIU.
Why cloning it in Router before passing it to Consumers? It should be cloned when generated in the Producer, right? or even in RtcStreamRecv. |
If there is no |
So the RtpPacket has its own buffer for future retransmissions.
We use RtpObservers as well. Please clone before. |
And do they need to access the RtpPacket once after this libuv iteration? They process the current packet and don't need to access the packet in the future. |
We can clone the packet before, it's just not needed if there are no Consumers. |
This is true for now. Will it be forever? |
I've set an explicit comment in
If you have a preference to always clone a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than pending comment this is great
🎉 |
This reverts commit b42d907.
Essentially extracted from #675
RtpStreamSend does not clone each RTP packet coming from Producer.
std::shared_ptr
holding the original packet is used by all RtpStreamSendinstances.
RtpStreamSend does not clone each RTP packet when sending DTX.
RtpStreamSend does not store up to 65536 RTP packets in a
std::map
.std::deque
(up to 2000 ms of media).Memory usage differences using mediasoup-demo with 6 attendees in a room: