versatica / mediasoup

Cutting Edge WebRTC Video Conferencing
https://mediasoup.org
ISC License
6.27k stars 1.13k forks source link

liburing #1218

Closed jmillan closed 11 months ago

jmillan commented 1 year ago

Enable liburing usage for linux (kernel versions >= 6).

Use liburing to relay incoming RTP to Consumers. This greately reduces the number of system calls as just a single system call is needed to relay the incoming RTP packet to "every" Consumer, opposite to libuv which requires a system call to relay the RTP packet to "each" Consumer.

For efficiency, memory buffers are preallocated holding the data payload being sent.

NOTE: The numbers are really positive. Not only the CPU usage is reduced but it's also more stable.

nazar-pc commented 1 year ago

Okay, I'm glad you've tested it with positive outcome! From my experience it is not always faster.

ibc commented 1 year ago

but it's also more stable

What does this mean exactly?

jmillan commented 1 year ago

Okay, I'm glad you've tested it with positive outcome! From my experience it is not always faster.

In my tests you'll see the difference when larg-ish Routers, but not with small/normal ones. Testing with >200 consumers you'll see a noticeable difference.

nazar-pc commented 1 year ago

In my tests you'll see the difference when larg-ish Routers, but not with small/normal ones. Testing with >200 consumers you'll see a noticeable difference.

That makes a lot of sense and is to be expected. Squeezing more performance out of the same CPU core is always nice.

jmillan commented 1 year ago

The numbers are really positive. Not only the CPU usage is reduced but it's also more stable.

What does this mean exactly?

The CPU usage is more stable, it shows less spikes.

ibc commented 12 months ago

Sorry for so many comments, I thought I was creating a batch but it was not true.

jmillan commented 12 months ago

Love it now. Is it ready? Are you gonna add those entries we discussed into the dump data? Or in another PR?

Thanks, I'll do few changes in this PR and add those dump data too. I'll notify you once done.

jmillan commented 12 months ago

@ibc, the initial version of liburing is ready to merge. Can you please take a look at today's 4 commits?

ashinrot commented 11 months ago

This greately reduces the number of system calls as just a single system call is needed to relay the incoming RTP packet to "every" Consumer

Hello, I'm working on udp syscall tunning on my local server, and trying lots of linux feature. IOUring seems to be a good solution, but how about sendmmsg syscall, it seems to be able to reduce the syscall with less code?

jmillan commented 11 months ago

but how about sendmmsg syscall, it seems to be able to reduce the syscall with less code?

You don't send multiple RTP packets in a raw to the same socket in mediasoup, but the "same" RTP packet from a Producer, to multiple sockets.

sendmmsg is for sending multiple packets to the same socket.

This PR is about using liburing when it's more convenient than libuv.