Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Refine SRS timer and cond for performance issue. #1711

Closed
winlinvip opened this issue Apr 19, 2020 · 1 comment
Closed

Refine SRS timer and cond for performance issue. #1711

winlinvip opened this issue Apr 19, 2020 · 1 comment
Assignees
Labels
EnglishNative This issue is conveyed exclusively in English. Feature It's a new feature.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented Apr 19, 2020

Reference: ossrs/state-threads#13 (comment)

image

This is the current SRS UDP scheduling structure diagram. It is basically very efficient, so st does not appear in the bottleneck. The points that can be improved include:

  1. The system only has one sleep, in the main coroutine, which is converted into a cond to notify other coroutines.
  2. HTTP Stream uses sleep, so it will trigger ST switching performance. The performance of HTTP-FLV is lower than that of RTMP. It should use cond like RTMP.
  3. MR (Merged Write) uses sleep, so the read optimization efficiency is not high. It should use readmsg or readmmsg, combined with cond processing. However, read optimization is different from write optimization. Write can determine how many messages to write after, while read is more troublesome, especially for TCP. It depends on how to implement port reuse, so that there can be many messages to read (such as RTMP back to the source using a private protocol).
  4. Each Consumer has a cond, causing the Source to call the cond signal for each Consumer. In fact, the cond can be placed on the source, allowing each consumer to wait for the source's event, implementing broadcast, and batch awakening these coroutines.
@winlinvip
Copy link
Member Author

winlinvip commented Dec 1, 2020

I discovered that the ST (State Threads) underlying layer will also continuously call getsystime. Additionally, ST's epoll_wait(timeout=0) will have performance issues when there are many sleep calls. These issues can be optimized together.

@winlinvip winlinvip self-assigned this Aug 23, 2021
@winlinvip winlinvip added this to the SRS 5.0 release milestone Aug 26, 2021
@winlinvip winlinvip assigned chen-guanghua and unassigned winlinvip Aug 26, 2021
@winlinvip winlinvip added the Feature It's a new feature. label Jan 17, 2022
@ossrs ossrs locked and limited conversation to collaborators Jul 18, 2023
@winlinvip winlinvip converted this issue into discussion #3653 Jul 18, 2023
@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Jul 29, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
EnglishNative This issue is conveyed exclusively in English. Feature It's a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants