Skip to content

bugfix: add temporary watchdog service for high-CPU processes#1335

Merged
brianmcgillion merged 1 commit intotiiuae:mainfrom
kajusnau:fix-cpu-usage
Aug 26, 2025
Merged

bugfix: add temporary watchdog service for high-CPU processes#1335
brianmcgillion merged 1 commit intotiiuae:mainfrom
kajusnau:fix-cpu-usage

Conversation

@kajusnau
Copy link
Copy Markdown
Collaborator

Description of Changes

  1. Add temporary watchdog service to monitor known problematic high-cpu usage processes:

Type of Change

  • New Feature
  • Bug Fix
  • Improvement / Refactor

Related Issues / Tickets

Checklist

  • Clear summary in PR description
  • Detailed and meaningful commit message(s)
  • Commits are logically organized and squashed if appropriate
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • Author has run make-checks and it passes
  • All automatic GitHub Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing Instructions

Applicable Targets

  • Orin AGX aarch64
  • Orin NX aarch64
  • Lenovo X1 x86_64
  • Dell Latitude x86_64
  • System 76 x86_64

Installation Method

  • Requires full re-installation
  • Can be updated with nixos-rebuild ... switch
  • Other:

Test Steps To Verify:

NOTE: Perform the following test at least 3 times to confirm the behavior is consistent

  1. Install Ghaf from scratch (this bug appears mostly on fresh installs)
  2. Boot and log into the system
  3. Observe htop and journalctl --user-unit=cosmic-cpu-watchdog.service
    • cosmic-applet-audio and cosmic-osd should appear in htop consuming more than 80% of CPU resources
    • The offending processes should be killed by cosmic-cpu-watchdog within ~2 minutes, the watchdog should then exit

Signed-off-by: Kajus Naujokaitis <kajus.naujokaitis@unikie.com>
@kajusnau kajusnau requested a review from vunnyso August 22, 2025 13:11
@kajusnau kajusnau self-assigned this Aug 22, 2025
@kajusnau kajusnau added the Needs Testing CI Team to pre-verify label Aug 22, 2025
Comment thread modules/desktop/graphics/cosmic/default.nix
@milva-unikie
Copy link
Copy Markdown

Tested on Lenovo-X1 (new image)

  • All good, watchdog works as it should

Notes

  • Killing the services causes the taskbar to disappear for a couple of seconds. This might confuse some users (and by some users I mean myself, I was confused)

@milva-unikie milva-unikie added Tested on Lenovo X1 Carbon This PR has been tested on Lenovo X1 Carbon and removed Needs Testing CI Team to pre-verify labels Aug 26, 2025
@brianmcgillion brianmcgillion merged commit d056528 into tiiuae:main Aug 26, 2025
28 checks passed
@kajusnau kajusnau deleted the fix-cpu-usage branch October 7, 2025 06:51
@fulalas
Copy link
Copy Markdown

fulalas commented Oct 10, 2025

Is this supposed to run automatically? I still get full CPU load for both cosmic-osd and cosmic-settings-daemon.

Also, if this watchdog detects offending processes and kill them, will them auto-restart?

@kajusnau
Copy link
Copy Markdown
Collaborator Author

kajusnau commented Oct 10, 2025

Is this supposed to run automatically? I still get full CPU load for both cosmic-osd and cosmic-settings-daemon.

Also, if this watchdog detects offending processes and kill them, will them auto-restart?

Yes they restart automatically, this is handled by cosmic session.
This workaround applies only for our use case here, since pulse/pipewire sometimes takes a bit longer to start. In these cases, killing and restarting the offending processes is enough.

Let’s keep broader issue discussion limited to cosmic upstream 😀

@fulalas
Copy link
Copy Markdown

fulalas commented Oct 10, 2025

Yes they restart automatically, this is handled by cosmic session.

Not on my machine. Both cosmic-osd and cosmic-settings-daemon keep using 100% of the CPU indefinitely.

How this watchdog is initialized? Does it rely on systemd?

@kajusnau
Copy link
Copy Markdown
Collaborator Author

Yes they restart automatically, this is handled by cosmic session.

Not on my machine. Both cosmic-osd and cosmic-settings-daemon keep using 100% of the CPU indefinitely.

How this watchdog is initialized? Does it rely on systemd?

Yes the watchdog is a systemd service.
If I had to guess, on your system, the necessary pipewire/pulse dependencies (services) are not started at any point or are otherwise misconfigured, which causes the cosmic tools to never establish a proper connection to the pipewire/pulse daemon.

Here, the configuration is correct, but there’s a timing issue - cosmic tools start too early, and don’t re-establish a connection to the sound related daemons, so we simply restart the cosmic tools.

@fulalas
Copy link
Copy Markdown

fulalas commented Oct 10, 2025

Yes the watchdog is a systemd service.

I see. Well, that's a bummer. Nothing should rely on systemd.

If I had to guess, on your system, the necessary pipewire/pulse dependencies (services) are not started at any point or are otherwise misconfigured

Pipewire works just fine on PorteuX. I can even use COSMIC audio settings with no issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tested on Lenovo X1 Carbon This PR has been tested on Lenovo X1 Carbon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants