Skip to content

Support MSG_ZEROCOPY for streaming server. #13

@winlinvip

Description

@winlinvip

参考:ossrs/srs#307 (comment)

目前内核最热的函数是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做支持,参考:#13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions