Kodi Community Forum

Full Version: High CPU (38%-48%) while idling, new Kodi and Raspberry Pi install. Is this normal?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a new Kodi installation on a new Raspberry Pi. I just noticed that when idling the Kodi process is taking up between 38% and 48% CPU! It is definitely heating up the Pi but Kodi is not doing anything. Is this normal for Kodi? When I exit, my Pi idles as less than 1%.

Raspberry Pi 4 8gb
Version: Kodi 18.7
Skin: default Kodi skin
Be aware that %CPU is a function of CPU speed.  So if you are using ondemand or scheduit governors, idle can appear higher if stepped down to a lower frequency compared to using performance which is always running at max speed.  Your values seems excessive to me even accounting for what I said based on my numbers.  Perhaps you have some plugins running?

What governor are you using?
Code:
% cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor          
ondemand

Example on my Arch ARM RPi4:
performance avgs ~8% idle
ondemand avgs ~15% idle
schedutil avgs ~16%
conservative avgs ~20%
 
Some neat plots thanks to psrecord:
Code:
% psrecord $(pidof kodi-gbm) --log /tmp/kodi-gbm.log --interval 2 --duration 60 --plot k-$(date "+%Y%m%d_%H%M%S").png

ondemand
Image

performance
Image

schedutil
Image

conservative
Image
(2020-10-02, 06:36)ioo+kod Wrote: [ -> ]Skin: default Kodi skin

That's usually not the only factor. Whatever add-ons you have installed and which are running in the background can also up the CPU percentage.

And yes, the RPi4 is a bit of a hot-head, so a cooling fan or a metallic casing for better temperature spreading is recommended. Using heat spreaders only inside a plastic casing will not do.
(2020-10-02, 11:13)Klojum Wrote: [ -> ]
(2020-10-02, 06:36)ioo+kod Wrote: [ -> ]Skin: default Kodi skin

That's usually not the only factor. Whatever add-ons you have installed and which are running in the background can also up the CPU percentage.

And yes, the RPi4 is a bit of a hot-head, so a cooling fan or a metallic casing for better temperature spreading is recommended. Using heat spreaders only inside a plastic casing will not do.
Hi, I do have a great metalic case that acts as a giant heatsink. It effectively reduces the temperature by 10%, I saw this effect right away.

I will wipe look at uninstalling all add-ons and taking another measurement but right now idling on the home screen of the default skin I am monitoring top and the kodi.bin_v8 process it taking 32%-38%.
(2020-10-02, 08:24)graysky Wrote: [ -> ]Be aware that %CPU is a function of CPU speed.  So if you are using ondemand or scheduit governors, idle can appear higher if stepped down to a lower frequency compared to using performance which is always running at max speed.  Your values seems excessive to me even accounting for what I said based on my numbers.  Perhaps you have some plugins running?

What governor are you using?
Code:
% cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor          
ondemand

Example on my Arch ARM RPi4:
performance avgs ~8% idle
ondemand avgs ~15% idle
schedutil avgs ~16%
conservative avgs ~20%
 
Some neat plots thanks to psrecord:
Code:
% psrecord $(pidof kodi-gbm) --log /tmp/kodi-gbm.log --interval 2 --duration 60 --plot k-$(date "+%Y%m%d_%H%M%S").png

ondemand
Image

performance
Image

schedutil
Image

conservative
Image
pi@raspberrypi:~ $ cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
ondemand


It looks like I am using ondemand which is is the default. Is this the correct governor or should I look at changing it?

When I exit Kodi my pi goes back to idling at less than 1%
(2020-10-02, 17:05)ioo+kod Wrote: [ -> ]It looks like I am using ondemand which is is the default. Is this the correct governor or should I look at changing it?

Yes, it's the correct governor but it lowers the arm's clock when relatively idle, which makes the cpu usage look higher.
e.g. kodi is using 15% of 1500MHz cpu. ondemand governor says it can reduce power by switching to 600MHz. But now cpu looks like it is at 37.5% (of 600MHz)

Switch to performance to get a more useful measure of how busy the cpu is. Run (as root):
Code:
echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
But, yes, kodi is a cpu hog even when it looks relatively idle. 10%-15% (of full speed) is quite common.
(2020-10-02, 17:05)ioo+kod Wrote: [ -> ]When I exit Kodi my pi goes back to idling at less than 1%

One other request: please try to avoid quoting large posts. It's not really useful and only results in extra page scrolling as well as additional useless storage on our forum server.

FYI, on our forum you can select the most prominent text of a post with your mouse (or finger), a "Reply" option will then appear in the bottom left corner of that post. Press that option bar and the selected text is copied in the reply text box for your convenience.
txt:

root@kmxbilr2 ~ # top
top - 18:40:07 up 6 min,  1 user,  load average: 0,45, 0,87, 0,53
Tasks: 170 total,   2 running, 168 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0,9 us,  1,2 sy,  0,1 ni, 97,8 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
MiB Mem :   3523,2 total,   2749,6 free,    269,8 used,    503,8 buff/cache
MiB Swap:    309,0 total,    309,0 free,      0,0 used.   2905,0 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                 
 4821 xbian     20   0  802008 210200  92496 R   6,3   5,8   0:55.93 kodi.bin                                                                                                
   33 root      20   0       0      0      0 I   1,3   0,0   0:01.10 kworker/2:1-events                                                                                      
   73 root       1 -19       0      0      0 S   0,3   0,0   0:00.97 vchiq-slot/0                                                                                            
   80 root     -51   0       0      0      0 S   0,3   0,0   0:00.64 irq/40-mmc0                                                                                             
 5059 ntp       20   0    7240   3028   2604 S   0,3   0,1   0:00.22 ntpd                                                                                                    
 5198 root      20   0 1025756  48884  13424 S   0,3   1,4   0:05.75 java                                                                                                    
 5680 root      20   0    9792   2832   2252 R   0,3   0,1   0:01.55 top                                                                                                     
    1 root      20   0    5320   3128   2060 S   0,0   0,1   0:22.09 init                                                                                                    
    2 root      20   0       0      0      0 S   0,0   0,0   0:00.01 kthreadd                                                                                                
    3 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_gp                                                                                                  
    4 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_par_gp                                                                                              
    6 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 kworker/0:0H-kblockd                                                                                    
    7 root      20   0       0      0      0 I   0,0   0,0   0:00.94 kworker/u8:0-events_unbound                                                                             
    .....
                                                                                      
root@kmxbilr2 ~ # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
ondemand
root@kmxbilr2 ~ #

That's I have of Kodi is idle
Sorry you should have echo'd "performance" to switch to performance governor. I've edited my post to correct this.
That doesn't look like "normal" values. My RPi 4 with Raspberry Pi OS, Kodi idles at 25% or less. That is without overclock and ondemand. Just a few addons installed, default skin.
A kodi debug log may help to find the cause: https://kodi.wiki/view/Log_file
(2020-10-02, 18:47)Nachteule Wrote: [ -> ]4821 xbian     20   0  802008 210200  92496 R   6,3   5,8   0:55.93 kodi.bin

This is a completely different result than I am seeing. Since I posted this, I completely wiped my Kodi installation and started again. While I idle on the default screen- add files from the file manager. I am seeing around 24%-28% idle. I have no media, no configuration, no add-ons. I have Kodi 18.7 with Raspberry Pi 4B 8gb with the ondemand governor. I have a Flirc aluminum case which acts as a giant heat sink and is doing an excellent job at dissipating the hear. So this would be out of the box performance.

What configuration did you do to get such drastically different results than me?
(2020-10-02, 19:01)popcornmix Wrote: [ -> ]Sorry you should have echo'd "performance" to switch to performance governor. I've edited my post to correct this.

So which governor setting would you recommend? The performance may show lower CPU values but would it be using or wasting more power?
Using a crude instrument to measure power consumption (Kill-A-Watt), I could not detect a difference between 600 MHz and 1500 MHz on my RPi4.  The thing only reports power consumption in "watts" without decimal places so it rounds to the nearest watt.  I would think that something that could measure fractions of a watt accurately might show differences.  The point not much if any much difference.

To you use case, why do you care if it's higher?
(2020-10-02, 23:30)ioo+kod Wrote: [ -> ]So which governor setting would you recommend? The performance may show lower CPU values but would it be using or wasting more power?

ondemand is the default and is recommended.
I'm just saying that measuring cpu usage using the ondemand governor is meaningless as clock speed is lowered when we are idle (which has the side effect of making the percentage look higher).
Use performance governor if you want to look at the real cpu percentage.