Skip to content
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

ObjectPoolAllocator #903

Open
wants to merge 17 commits into
base: v3
Choose a base branch
from
Open

ObjectPoolAllocator #903

wants to merge 17 commits into from

Conversation

jmillan
Copy link
Member

@jmillan jmillan commented Sep 7, 2022

This is an extract from a bigger "Memory Optimizations" PR #675

It contains only the ObjectPoolAllocator part with a few exceptions:

  • RtpPacket::Parse() does return a RtpPacket instance. In Memory optimizations #675 it returned a shared pointer but since shared pointers are just needed for cloned packets (for retransmission), the former method does not need to create one.
  • RtcpCompoundPacket is left as it was. This is, a new one is created when needed (this will be enhanced in a separate PR).

As per my tests I'm not seeing much difference with this and v3. There is maybe some noticeable CPU enhancement.

Please @nazar-pc , @Hartigan give it a try and instrument this if possible to see how it enhances comparing to v3. I'll do some more testing just to make sure this addition is worth it.

Performed performance unit tests:

Parsed RtpPackets ObjectPoolAllocator (sec) new/delete (sec)
10K 0.0028 0.0039
100K 0.027 0.038
1M 0.26 0.33
Cloned RtpPackets ObjectPoolAllocator (sec) new/delete (sec)
10K 0.0034 0.0049
100K 0.033 0.049
1M 0.33 0.48

ObjectPoolAllocator is definitely more performant as it reuses memory instead of freeing & re-allocating it.

@jmillan jmillan requested review from ibc and nazar-pc September 7, 2022 15:50
Copy link
Member

@ibc ibc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few things reviewed yet

worker/include/RTC/RtpPacket.hpp Show resolved Hide resolved
worker/include/Utils.hpp Outdated Show resolved Hide resolved
@jmillan
Copy link
Member Author

jmillan commented Sep 9, 2022

NOTE: Currently measuring the CPU time differences with pools VS new/delete.

@jmillan jmillan marked this pull request as draft September 9, 2022 08:58
@jmillan
Copy link
Member Author

jmillan commented Sep 9, 2022

Converted to draft while re-testing re-profiling. Feel fee to try it out and review.

jmillan referenced this pull request Sep 9, 2022
* Make ObjectPoolAllocator from ObjectPool
@nazar-pc
Copy link
Collaborator

@Hartigan please send multiple comments as a review together rather than individually, it will reduce number of GitHub notifications everyone receives.

@jmillan jmillan marked this pull request as ready for review October 4, 2022 10:36
@jmillan jmillan requested review from ibc and Hartigan October 4, 2022 10:36
Copy link
Member

@ibc ibc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some cosmetic changes requested and a question. Other than that it looks very good however I'm not in a good shape to properly review these huge changes, but I trust you guys.

worker/src/RTC/RtpPacket.cpp Show resolved Hide resolved
worker/src/RTC/RtpPacket.cpp Show resolved Hide resolved
worker/src/RTC/Transport.cpp Show resolved Hide resolved
worker/test/src/RTC/TestRtpPacket.cpp Show resolved Hide resolved
@ibc
Copy link
Member

ibc commented Jan 26, 2023

Which is the status of this PR?

@jmillan
Copy link
Member Author

jmillan commented Jan 26, 2023

It's ready to merge. It's working properly. Even though we may want to enrich he pool allocator in the future is a good starting point.

@ibc
Copy link
Member

ibc commented Jan 26, 2023

Ok?

@ibc
Copy link
Member

ibc commented Mar 29, 2023

Reminder: this PR needs love.

@jmillan
Copy link
Member Author

jmillan commented Mar 29, 2023

Yes, it's on my TODO

@jmillan
Copy link
Member Author

jmillan commented Dec 15, 2023

I'll revive this PR for the new year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants