Limit CPU load

  • Platform information:
    • Hardware: Raspberry Pi 4
    • OS: osmc based on debian
    • Java Runtime Environment:
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Debian-1deb11u1)
OpenJDK Server VM (build 11.0.16+8-post-Debian-1deb11u1, mixed mode)
  • openHAB version: openHAB 3.4.0

  • Issue of the topic:
    Openhab runs well. But when I use Kodi to play music sometimes the sound stutters when the openhab.service is running.
    In normal conditions the CPU load of openhab seems to be below 6%. Sorry, I’m not familiar with top and didn’t found a way to log the maximum loads of named processes (is there a way?).
    When music stutters it seems that there are high CPU load of some php-fbm processes.
    Is there a way to limit the CPU usage of all openhab related processes to a maximum CPU load of 20% ?

Where does the php-fbm process come from …? Native openhab is not based on php.
To limit the CPU process of OH you would have to take care of the java process. But this will not help as php-fbm is something different.
This process is being used to speedup we page see e.g. PHP-FPM Cuts Web App Loading Times by 300% . By limit its CPU usage I think its speed will be limited as well.

May be this blog article give an idea about what you could do Restricting process CPU usage using nice, cpulimit, and cgroups | Scout APM Blog in case you still want to try to limit the process CPU usage.

Thanks for your quick answer.
To be honest I’m not sure if the stutter is related to the php-fpm or not. This was my suggestion, when I had a look to top and I see the php-fpm processes with high loads sometimes. If you say php-fbm is not related to OH, the issue must be something different, because it only stutters when OH is running.

You can try following:

  • login to the linux shell console on your OH host
  • enter but do not press return key:
    top -bn 1 2>&1 > /tmp/top.txt; pstree -p > /tmp/pstree.txt
  • wait until the problem occurs
  • press return key

The command will create two files. One ( /tmp/top.txt ) containing the output of the top command stored in that file. The other one ( pstree ) containing a list of all processes and their tree.
Copy these files to your computer and upload them here.

The best advice anyone can give to you is to NOT run multiple applications on the same hardware when they’re time-sensitive like Kodi and (to some lesser extent) OH are.

Trying to make them co-exists is a rabbit hole you, once you start, will be pouring a lot of time and nerves into.

So stop creeping down the hole now, get another Raspi and don’t run Kodi and OH on the same machine.