-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RTC: Support object cache pool. 4.0.75
- Loading branch information
Showing
2 changed files
with
2 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14bfc98
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.
RTC有非常多的RTP包,由于对于实时性要求很高,所以每个Player每个时刻能处理的包却并不能太多(也就是服务器不能做延迟批量处理包)。
而直播很不一样,直播服务器可以主动缓存几百毫秒甚至秒级别的数据,批量处理和发送,以获得更高的性能。
因此,RTC对于对象的缓存就很重要,不断的new和delete对象,会导致性能低下。
首先,我们要将RTP Packet的缓存区分配,改成对象自己管理:
然后,我们使用对象池分配内存和对象:
关于对象池的性能优化:
其他重要说明:
14bfc98
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.
Object Cache Pool,压测发现作用有限,已经从4.0的代码删除:f7b3225
代码保留在:feature/object_cache_pool
数据请看如下两个图对比:
开启Cache
关闭Cache