Bug 500835 - powerdevil high CPU usage with ddcutil 2.2.0
Summary: powerdevil high CPU usage with ddcutil 2.2.0
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Power management & brightness (other bugs)
Version First Reported In: 6.3.2
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-27 20:16 UTC by Avraham Hollander
Modified: 2025-08-21 21:37 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: Plasma 6.4.4 with ddcutil 2.2.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Avraham Hollander 2025-02-27 20:16:29 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
Powerdevil's CPU usage spikes every second or so with ddcutil 2.2.0. Downgrading to ddcutil 2.1.4 and restarting the service solved the problem.

STEPS TO REPRODUCE
1. Upgrade to ddcutil 2.2.0
2. Restart powerdevil

OBSERVED RESULT
Powerdevil has relatively high CPU usage

EXPECTED RESULT
Powerdevil works as expected

SOFTWARE/OS VERSIONS
Operating System: Gentoo Linux 2.17
KDE Plasma Version: 6.3.2
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Kernel Version: 6.13.5-tkg-sched-ext-latency (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 5600G with Radeon Graphics
Memory: 15.4 GiB of RAM
Graphics Processor: AMD Radeon RX 6600


ADDITIONAL INFORMATION
Log with ddcutil 2.1.4:
Feb 26 19:25:22 buildbox systemd[752]: Starting Powerdevil...
Feb 26 19:25:22 buildbox org_kde_powerdevil[1046]: Initializing libddcutil.  ddcutil version: 2.1.4, shared library: /usr/lib64/libddcutil.so.5.1.2
Feb 26 19:25:22 buildbox org_kde_powerdevil[1046]: Options passed from client:
Feb 26 19:25:22 buildbox org_kde_powerdevil[1046]: Applying combined options:
Feb 26 19:25:22 buildbox org_kde_powerdevil[1046]: Library initialization complete.

Log with ddcutil 2.2.0:
Feb 27 15:01:47 buildbox systemd[750]: Starting Powerdevil...
Feb 27 15:01:47 buildbox org_kde_powerdevil[1043]: Starting libddcutil. library built Feb 27 2025 at 10:54:40. stdout_stderr_redirected=true
Feb 27 15:01:47 buildbox org_kde_powerdevil[1043]: Initializing libddcutil.  ddcutil version: 2.2.0, shared library: /usr/lib64/libddcutil.so.5.2.0
Feb 27 15:01:47 buildbox org_kde_powerdevil[1043]: [  1043] Options passed from client:
Feb 27 15:01:47 buildbox org_kde_powerdevil[1043]: [  1043] Applying combined libddcutil options:
Feb 27 15:01:48 buildbox org_kde_powerdevil[1043]: Library initialization complete.
Feb 27 15:01:48 buildbox org_kde_powerdevil[1043]: [  1043] Watching for display connection changes, resolved watch mode = Watch_Mode_Poll, poll loop interval = 2000 millisec
Feb 27 15:01:48 buildbox org_kde_powerdevil[1043]: [  1043]                                          extra_stabilization_millisec: 0,  stabilization_poll_millisec: 100
Feb 27 15:01:48 buildbox org_kde_powerdevil[1043]: [  1043] libddcutil recheck thread (nil) started
Feb 27 15:01:48 buildbox org_kde_powerdevil[1043]: [  1043] libddcutil watch thread 0x5e7452737fe0 started
Feb 27 15:01:48 buildbox org_kde_powerdevil[1043]: [  1173] (dw_recheck_displays_func) Recheck interval: Slept for 200 millisec
Comment 1 TraceyC 2025-03-07 20:58:39 UTC
I'm not seeing this on Plasma 6.3.2 or git-master (both systems have ddcutils 2.2.0)

For instance, on 6.3.2:
$ ps -p 533706 -o %cpu,%mem,cmd
%CPU %MEM CMD
 0.0  0.1 /usr/lib64/kf6/org_kde_powerdevil

Can you get the pid of powerdevil, use it in the following command:

ps -p PID -o %cpu,%mem,cmd

and paste the output in this report? Thanks!
Comment 2 Jakob Petsovits 2025-03-07 22:38:16 UTC
ddcutil 2.2.0 has two different "watch modes", as per release notes: http://www.ddcutil.com/c_api_220/

The logs from Comment #0 indicate that this user's system is using the POLL watch mode, see this snippet:

> watch mode = Watch_Mode_Poll, poll loop interval = 2000 millisec

On my system, I get Watch_Mode_Xevent which according to ddcutil is easier on the CPU. So, if ddcutil with POLL watch mode is too CPU-intensive on a Ryzen 5600G (which isn't even all that old) then that's not so great.

As mentioned in Bug 500951 comment #2, possible attempt on the powerdevil side of things could be to abandon ddcutil's display change notifications altogether, and instead trigger manual ddcutil redetection after libkscreen tells us about new or removed displays.
Comment 3 Avraham Hollander 2025-08-13 12:41:32 UTC
I'm not sure when exactly this was fixed, but  I've actually been using ddcutil 2.2.0 for a while now and it's been fine. So I'm closing this as fixed.
Comment 4 TraceyC 2025-08-13 16:38:34 UTC
Thanks for letting us know :)