ossrs / ossrs/state-threads

a performance issue for epoll idle

Open
#4 35 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
759
Forks
277
PR merge metrics
No merged PRs in 30d

Description

I came across a performance issue in epoll mode, when there were thousands concurrent connections. Profiling shows that _st_epoll_dispatch() consumed a lot of CPU.

After reviewing the function, I think I've found the reason: there's a loop that enumerates ALL threads in the I/O queue.

for (q = _ST_IOQ.next; q != &_ST_IOQ; q = q->next) {

As I'm using one thread per connection model, I believe this loop make epoll mode degraded effectively to select mode.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at _st_epoll_dispatch() and inspect the _ST_IOQ traversal shown in the report. Reproduce the epoll workload with thousands of concurrent connections, profile its CPU use, and compare the result after addressing the reported traversal; done means the idle epoll path no longer shows the described degradation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
networking, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.