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

Optimize RTP header extension handling #786

Merged
merged 5 commits into from
Mar 5, 2022

Conversation

jmillan
Copy link
Member

@jmillan jmillan commented Mar 4, 2022

Yet another extract from memory-optimizations branch.

Use std::array instead of a map for one byte extensions.

@jmillan jmillan requested review from ibc and nazar-pc March 4, 2022 09:24
worker/src/RTC/RtpPacket.cpp Outdated Show resolved Hide resolved
worker/src/RTC/RtpPacket.cpp Outdated Show resolved Hide resolved
worker/src/RTC/RtpPacket.cpp Outdated Show resolved Hide resolved
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.

I don really know how that lib works but since tests pass I assume it's ok

Copy link
Collaborator

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

The first observation here is that for 1-byte extensions there is a limit of 14, so it is way cheaper to just allocate contiguous space for 14 bytes as a static array rather than using red-black tree-based map from standard library. This provides huge savings on trivial temporary heap allocations.

For two-byte header extensions just more efficient data structure is used.

@jmillan jmillan merged commit 169b05b into v3 Mar 5, 2022
@jmillan jmillan deleted the optimize-rtp-header-extension-handling branch March 5, 2022 08:14
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.

3 participants