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

支持合并发送 #84

Closed
1 of 8 tasks
q191201771 opened this issue May 15, 2021 · 1 comment
Closed
1 of 8 tasks

支持合并发送 #84

q191201771 opened this issue May 15, 2021 · 1 comment

Comments

@q191201771
Copy link
Owner

q191201771 commented May 15, 2021

背景:
流媒体转发服务,除了线程模型的架构外,内存拷贝次数和系统调用次数对性能影响比较大。
合并发送是指,多个小包数据合并为一块数据块调用系统调用write进行发送。
显然,合并发送可以减少系统调用write的调用次数。但是会增加内存拷贝。
并且由于主动降低了数据发送的及时性,可能会造成卡顿。

现状:
目前lal中的流会话session都使用naza库中connection作为连接对象的封装。
connection在创建时支持是否增加一层发送缓存实现合并发送(基于Go标准库的bufio.Writer)。
但是以connection为粒度做合并发送有一个问题,就是1对n转发时,可能会发生n次拷贝。
所以,我们需要一个基于group(也即刚才所说的n)的合并发送缓存。
另外,bufio.Writer在内存管理,缓存策略方面,也不一定完美贴合我们的需求,可能需要再实现一个类似的buffer writer。

行动项:

  • lalserver中的rtmp sub session已支持合并发送
  • 写一篇关于bufio.Writer的文章
  • 更新配置文件中相关配置的说明文档
  • 需要增加一种控制策略,根据数据时间戳差值。(当前合并发送的策略是使用需要发送的字节数作为阈值)
  • 增加定时Flush
  • 其他协议的合并发送
  • 性能对比测试
  • 该主题可能还涉及到发送数据发不动时,上层主动丢弃数据的逻辑,这个需要后面另开主题讨论
@q191201771
Copy link
Owner Author

lalserver中的rtmp sub session已支持合并发送。

q191201771 added a commit that referenced this issue May 22, 2021
1. #86 [fix] gop缓存设置为0时,可能花屏
2. #84 [fix] rtmp merge write开启时,可能给新加入的sub session发送错误的数据
@q191201771 q191201771 mentioned this issue Apr 23, 2022
33 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant