versatica / mediasoup

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

About v3.13.15, io_uring, and liburing #1317

Closed j1elo closed 8 months ago

j1elo commented 8 months ago

Just an idea

Hi @ibc , just passing by the release notes I saw the entry for 3.13.15 and have read the whole trail of issues/PRs about Linux 6 and io_uring, all the way down to https://github.com/versatica/mediasoup/issues/1282.

The whole plot across those items seems to be that build scripts in mediasoup are checking for Linux kernel version >= 6 before attempting to even enable io_uring.

My comment raises specifically from this one:

  • meson.build only compiles liburing subproject if current host has kernel >6. Why? Because liburing depends on io-uring which is only available in Linux kernel >= 6.

Here's where I got curious. io_uring has supposedly been available in the Linux kernel since at least version 5.1, with following iterations adding more features and improvements. I'd say 5.6 was the version that started to be more "complete".

Source: articles like this on LWN, or random comments of people who were seemingly using it on Linux 5.4

On the other hand, the liburing readme states that

liburing itself is not tied to any specific kernel release, and hence it's possible to use the newest liburing release even on older kernels (and vice versa). Newer features may only be available on more recent kernels, obviously.

and the Meson wrap for liburing does indeed contain compilation checks to conditionally enable or disable a couple features depending on the capabilities of the build machine (see liburing/meson.build)

So I'd just wanted to point out that maybe mediasoup can simplify a bit and just do without different builds for kernel 5 vs. 6, always enabling io_uring with whatever features get compiled by the build machine (which as you noted for Ubuntu 20.04 has up to Kernel 5.15.0).

I noted that io_uring got some very nice performance improvements with kernel 6, but then it seems to me that the mediasoup worker as of today could be always built with io_uring support on all supported Linux platforms (aka. kernel > 5.6 for sure), and on runtime on modern systems it would just have a bit better performance due to newer host kernel 6.

nazar-pc commented 8 months ago

This is a lot of additional burden to identify features and bugs. Checking kernel version is a simple and straightforward way to get what we need on modern kernels. If you need it on older kernels and don't want to install modern HWE kernel, you'll have to fork mediasoup and put in the effort of figuring out what works and what doesn't.

j1elo commented 8 months ago

I'm fine with the current state of things, I was just commenting on the fact that "io-uring which is only available in Linux kernel >= 6" wasn't technically true.

But my comment was (maybe naively) assuming that all io_uring features used by the worker's source code would keep compiling fine as-is when building on kernel 5.15. If that would not be the case, then disregard it all.

nazar-pc commented 8 months ago

wasn't technically true

You're right, but that is where mediasoup decided to support it

jmillan commented 8 months ago

I was experiencing some issues with kernel 5.10 using sendto(), which is basic to us, and worked out simply fine when upgrading to 6.0.

IMO going forward just with versions >=6.0 is a safe guard against other possible incompatibilities, but changing the check to >=5.15 would be seamless.

@j1elo, if you test it with 5.15 and confirm everything works we can decrease the supported kernel version.

nazar-pc commented 8 months ago

We only ship precompiled binaries for major kernel versions, so 5.15 would still be downloaded without ui_uring support unless we make logic there more complicated

jmillan commented 8 months ago

Forget about my comment, as the provided linked indicated, the issue was also present in kernel version 5.15.49.

j1elo commented 8 months ago

Forget about my comment, as the provided linked indicated, the issue was also present in kernel version 5.15.49.

Oh well then, I'm sorry to have missed that one. Seems that even in 5.15, the implementation in the kernel wasn't yet we'll finished, even though the documented release version was much earlier!

It then does very much seem like kernel 6.x was indeed where the io_uring feature started to work reliably.