ossrs / ossrs/state-threads

Support MSG_ZEROCOPY for streaming server.

Open
#13 9 comments 1 reaction 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

参考:https://github.com/ossrs/srs/issues/307#issuecomment-615884074

目前内核最热的函数是copy_user_enhanced_fast_string,它主要是将用户空间的数据,拷贝到内核,可以想到是因为要将发送的UDP的payload拷贝到内核发送。

同样的,TCP也是这个是瓶颈,实际上Linux内核支持了很多种零拷贝方式,比如sendfile、splice、tee还有MSG_ZEROCOPY

它提到是有代价的,如果要发送大量的数据,那么比较值得:

Copy avoidance is not a free lunch. As implemented, with page pinning, it replaces 
per byte copy cost with page accounting and completion notification overhead. As a 
result, MSG_ZEROCOPY is generally only effective at writes over around 10 KB.

若使用sendmmsg,600Kbps码率的流,1个连接观看时一次发送50KB数据,1000个连接观看一次发送8.5MB的数据,2000个连接观看一次发送14.4MB数据,3000个连接观看一次发送20MB数据。

这可能需要修改ST做支持,参考:https://github.com/ossrs/state-threads/issues/13

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

No file, test, or entry point is named. Start by reading the Linux MSG_ZEROCOPY documentation and the referenced state-threads issue, then trace the streaming server's send path to determine the required integration points. Done means the library supports MSG_ZEROCOPY for suitable large writes without regressing existing networking behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, linux
Domain
networking, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.