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

ST: Low performance when got large amount of coroutines. #1553

Open
NodeBoy2 opened this issue Jan 3, 2020 · 5 comments
Open

ST: Low performance when got large amount of coroutines. #1553

NodeBoy2 opened this issue Jan 3, 2020 · 5 comments
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@NodeBoy2
Copy link

NodeBoy2 commented Jan 3, 2020

Description'

Please ensure that the markdown structure is maintained.

Long running, severe memory growth, and increased close_wait on the server. Using perf to investigate, it was found that heap_delete and heap_insert are causing significant delays.

  1. SRS version: 2.0.258
  2. SRS logs:
    • Normal

Replay

How to replay bug?

Steps to reproduce the bug

1. Long-time operation/live streaming (using random values for streaming URLs, all different)

Expected behavior (Expect)

Is it because std::map<std::string, SrsSource*> SrsSource::pool is not released that causes the issue? Is there any solution available?

TRANS_BY_GPT3

@NodeBoy2 NodeBoy2 changed the title srs长时间运行导致服务器close srs长时间运行,内存增长,并且导致服务器close_wait大量增加 Jan 3, 2020
@NodeBoy2
Copy link
Author

NodeBoy2 commented Jan 3, 2020

Using gdb to debug a long-running program (while streaming), in the _st_thread_create() function of the st library, the _st_active_count variable has reached 1695. At the same time, in the fetch_or_create() function of srs_app_source.cpp, the value of the pool is outputted, and it is found that the previous streaming records still exist.
(gdb) p _st_active_count $1 = 1695
(gdb) p pool $1 = std::map with 845 elements = { ["/mttest/fengyifan_test"] = 0x1a1e1c0, ["/test/test_200"] = 0x29d5b20, ["origin.test.com/test/003d94d6.10c9a7116ac01061"] = 0x3621f80, ... }

TRANS_BY_GPT3

@NodeBoy2
Copy link
Author

NodeBoy2 commented Jan 3, 2020

Refer to #713. In SrsSource::fetch(), add source->die_at = -1; At the same time, add the active_at variable to SrsSource to record the last active time (update it in on_metadata, on_video, on_audio). When cleaning up SrsSource objects, first check if die_at has timed out, then check if the last active time has timed out. Can this solve the problem?

TRANS_BY_GPT3

@winlinvip winlinvip added the Bug It might be a bug. label Dec 1, 2020
@winlinvip winlinvip added this to the SRS 4.0 release milestone Dec 1, 2020
@winlinvip
Copy link
Member

winlinvip commented Dec 1, 2020

The waiting performance of ST needs to be optimized.

TRANS_BY_GPT3

@watchpoints
Copy link

watchpoints commented Dec 21, 2020

me too, CPU 20%'.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title srs长时间运行,内存增长,并且导致服务器close_wait大量增加 ST大量协程时,等待和查找协程性能低 Mar 4, 2021
@winlinvip winlinvip self-assigned this Aug 23, 2021
@winlinvip winlinvip assigned chen-guanghua and unassigned winlinvip Aug 26, 2021
@winlinvip winlinvip changed the title ST大量协程时,等待和查找协程性能低 ST: Low performance when got large amount of coroutines. 大量协程时,等待和查找协程性能低 Jan 2, 2023
@winlinvip winlinvip modified the milestones: 5.0, 6.0 Jan 2, 2023
@winlinvip winlinvip changed the title ST: Low performance when got large amount of coroutines. 大量协程时,等待和查找协程性能低 ST: Low performance when got large amount of coroutines. When there are a large number of coroutines, the performance of waiting and searching for coroutines is low. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
@winlinvip winlinvip changed the title ST: Low performance when got large amount of coroutines. When there are a large number of coroutines, the performance of waiting and searching for coroutines is low. ST: Low performance when got large amount of coroutines. Apr 22, 2024
@winlinvip winlinvip assigned winlinvip and unassigned chen-guanghua Apr 22, 2024
@winlinvip
Copy link
Member

There is a PR ossrs/state-threads#5 related to this issue, improving the performance for iterating all coroutines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

4 participants