Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use FIFO scheduler in bbb-webrtc-sfu #15602

Merged

Conversation

prlanzarin
Copy link
Member

What does this PR do?

  • build: use FIFO scheduler in bbb-webrtc-sfu
    • This commit puts bbb-webrtc-sfu in the FIFO scheduling policy (same as
      bbb-html5). Also bumps bbb-html5 nice level up to 18 and sets SFU to
      nice 19 (so bbb-html5 has some advantage when push comes to shove).

Closes Issue(s)

Closes #

Motivation

bbb-webrtc-sfu (and mediasoup) are running in the CFS scheduler which
means it has to compete with (much) lower priority tasks like
presentation conversion, recording processing, [...]
Since it encompasses an RTC application which also handles audio, it
should be at least on the same scheduling policy as FS/bbb-html5 - and
that should be safer now with mediasoup which has a lower footprint
(and generates lower CPU noise overall).

This can be improved further by using per-process priorities in SFU.
Ideally we'd want mediasoup audio workers and mcs-core to be the same
priority as FS (so higher than bbb-html5), but the rest of them
(video/screen workers) to be the same or lower than bbb-html5.
For future reference:

bbb-webrtc-sfu (and mediasoup) are running in the CFS scheduler which
means it has to compete with (much) lower priority tasks like
presentation conversion, recording processing, [...]
Since it encompasses an RTC application which also handles audio, it
should be _at least_ on the same scheduling policy as FS/bbb-html5 - and
that should be safer now  with mediasoup which has a lower footprint
(and generates lower CPU noise overall).

This commit puts bbb-webrtc-sfu in the FIFO scheduling policy (same as
bbb-html5). Also bumps bbb-html5 nice level up to 18 and sets SFU to
nice 19 (so bbb-html5 has some advantage when push comes to shove).

This can be improved further by using per-process priorities in SFU.
Ideally we'd want mediasoup audio workers and mcs-core to be the same
priority as FS (so higher than bbb-html5), but the rest of them
(video/screen workers) to be the same or lower than bbb-html5. For
future reference:
  - bigbluebutton/bbb-webrtc-sfu@3e24512
  - bigbluebutton/bbb-webrtc-sfu@66d443d
@antobinary antobinary added this to the Release 2.6 milestone Aug 26, 2022
@sonarcloud
Copy link

sonarcloud bot commented Aug 26, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@prlanzarin prlanzarin marked this pull request as ready for review August 26, 2022 14:58
@schrd
Copy link
Collaborator

schrd commented Aug 26, 2022

Just an idea: Processes belonging to a service can be grouped by using systemd slices. That way a group of processes could be prioritized/limited not matter how many processes exist in a group. That way you can limit for example the cpu consumption of all html5 processes no matter how many are configured. And you can weight groups of processes, like all bbb-html5 processes to all bbb-webrtc-sfu and to all freeswitch ones.

A slice hierarchy might look like this:

  • bigbluebutton.slice
    • bigbluebutton-media.slice
      • audio.slice
        • freeswitch.service
        • bbb-webrtc-sfu-audio.service
      • video.slice
        • bbb-webrtc-sfu-video.service
    • bigbluebutton-nomedia.slice
      • bbb-apps-akka.service
      • bbb-fsesl-akka.service
      • bbb-web.service

See https://www.man7.org/linux/man-pages/man5/systemd.slice.5.html and https://www.man7.org/linux/man-pages/man5/systemd.resource-control.5.html

@prlanzarin
Copy link
Member Author

Just an idea: Processes belonging to a service can be grouped by using systemd slices. That way a group of processes could be prioritized/limited not matter how many processes exist in a group. That way you can limit for example the cpu consumption of all html5 processes no matter how many are configured. And you can weight groups of processes, like all bbb-html5 processes to all bbb-webrtc-sfu and to all freeswitch ones.

A slice hierarchy might look like this:

* `bigbluebutton.slice`
  
  * `bigbluebutton-media.slice`
    
    * `audio.slice`
      
      * `freeswitch.service`
      * `bbb-webrtc-sfu-audio.service`
    * `video.slice`
      
      * `bbb-webrtc-sfu-video.service`
  * `bigbluebutton-nomedia.slice`
    
    * `bbb-apps-akka.service`
    * `bbb-fsesl-akka.service`
    * `bbb-web.service`

See https://www.man7.org/linux/man-pages/man5/systemd.slice.5.html and https://www.man7.org/linux/man-pages/man5/systemd.resource-control.5.html

Neat. From the top of your head do you know if slices have a neat way of handling prioritization of child processes? Or does that only apply easily to parent processes?

@schrd
Copy link
Collaborator

schrd commented Aug 26, 2022

Neat. From the top of your head do you know if slices have a neat way of handling prioritization of child processes? Or does that only apply easily to parent processes?

I don't know if I understood https://systemd.io/CGROUP_DELEGATION/ correctly. But I think it is possible to move processes into a systemd scope that belongs to a different slice than the managing process which forks off the processes. I found this one but did not try if it works: https://unix.stackexchange.com/questions/525740/how-do-i-create-a-systemd-scope-for-an-already-existing-process-from-the-command

You can inspect the cgroup tree in your system by running systemd-cgls.

@antobinary antobinary merged commit a7ae997 into bigbluebutton:v2.6.x-release Jan 26, 2023
@prlanzarin
Copy link
Member Author

I'll open a follow up issue for the improvements discussed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants