On Mon, Jun 21, 2021 at 7:18 AM Tim Evans tkevans@tkevans.com wrote:
$ uname -a Linux harrier 5.12.11-300.fc34.x86_64 #1 SMP Wed Jun 16 15:47:58 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
As I sit here, my Lenovo T530 laptop is reporting packagekitd is taking anywhere from 20 to 40 percent of CPU, per 'top.' There is continuous disk activity. Nothing going on with the system other than Thunderbird e-mail and Chrome browser.
This seems to go on, with CPU percentage growing over time, and it rebooting cures this, but it comes back after the system has slept overnight (lid closed).
PackageKit and dnf keep separate metadata in /var/cache and they update periodically. PackageKit seems to do this on login, but I've also noticed it trigger an update when I switch networks. And dnf is on a timer. Either of them can use a lot of cpu, it just depends on how much updating they need.
Recently I've been experimenting with cgroups to restrict the amount of cpu packagekit gets via the packagekit.service unit. i.e. this is a service unit specific restriction, not on all instances of packagekit. Thus it doesn't affect offline updates, where it can still use 100% cpu if need be. But, it's possible GNOME Software could be a bit slower since it uses packagekit, though I haven't noticed any ill effect so far.
$ sudo systemctl edit packagekit.service
Read the file that appears and insert these two lines where it says to:
[Service] CPUQuota=25%
Save it out, and when the unit restarts (logout and login or do the daemon-reload followed by service restart dance) you'll see packagekit uses this value as a maximum.