psensor CPU usage jumps when graph window loses focus

Bug #1582930 reported by Steven Stansbery
56
This bug affects 9 people
Affects Status Importance Assigned to Milestone
psensor (Ubuntu)
Fix Released
Low
Unassigned
Xenial
Confirmed
Low
Unassigned

Bug Description

Spike in CPU usage occurs anytime the psensor graph window does not have the focus. You can verify this by having just one other small window on the desktop, Terminal for instance, and Alt-Tab between them. You'll see the CPU usage jump and fall as you do.

This occurs with psensor 1.1.3-2ubuntu3 in ubuntu 16.04.

The jump in CPU usage does not occur in an identically configured psensor 1.1.3-2ubuntu2 in ubuntu 15.10.

I'm running a custom built PC with an AMD A8-3870 APU and no discrete graphics card or motherboard graphics. I am not using proprietary graphics drivers just the default graphics with ubuntu 15.10 and 16.04.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: psensor 1.1.3-2ubuntu3
ProcVersionSignature: Ubuntu 4.4.0-22.40-generic 4.4.8
Uname: Linux 4.4.0-22-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
CurrentDesktop: Unity
Date: Tue May 17 15:46:13 2016
InstallationDate: Installed on 2016-04-28 (19 days ago)
InstallationMedia: Ubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160420.1)
ProcEnviron:
 LANGUAGE=en_US
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: psensor
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Steven Stansbery (steve-stansbery) wrote :
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in psensor (Ubuntu):
status: New → Confirmed
Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Thanks for the report, I am also reproducing it.

It is due to the fact that the signal 'draw' is called too often, so psensor is refreshing
too often the curves leading to overusing the cpu.

Unfortunely, the signal 'draw' is not emitted by psensor itself so currently, I don't have any fix.

Changed in psensor (Ubuntu):
importance: Undecided → Low
Revision history for this message
Hans-Gregor Gehrke (b-u6untu-r) wrote :

I can confirm this behaviour as well. (Ubuntu 16.04 AMD64 with stock unity and repository) As soon as Graph window loses focus the CPU power increases (depending on graph window size and amount of plotted data). As soon as focus is regained, processing goes under 1%.
I tested installing version 1.1.3-Ubuntu5, 1.1.3-Ubuntu2 and 0.8.0.3ubuntu3. All leading to the same behaviour.
I could observe this on my desktop with NVIDIA graphics (proprietary driver) as well as on my notebook with Intel graphics N3700.
I am not an expert in programming but it seems to be a problem caused by one of the dependencies used (incorrectly?).
If there is is something to help finding this problem I would be glad to assist.
I really like psensor!

Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1582930

tags: added: iso-testing
Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Hans-Gregor, thanks for the report.
Currently I know that it is due to the gtk signal 'draw' which is sent by the Gtk layer to psensor.
What I don't know is why the signal is sent. I wonder if it is not Unity. Did you try another window manager?

Revision history for this message
Hans-Gregor Gehrke (b-u6untu-r) wrote :

Hi Jean-Philippe,

I've tested psensor under Xfce (xUbuntu) and indeed psensor behaves has expected. The CPU power stays at virtually 0 in back- and foreground. I tested it installing the xubunut-desktop alongside. After switching back to Unity, psensor still behaved well*. However, as soon as I reactivated the Ambiance-Theme the CPU power used went up again.

*The theme (colors) of unity were (partially) overwritten by the xubuntu-desktop installation. It seems the problem of psensors CPU usage is related to something set by applying the default Unity theme. Something seems to cause the repeated call of the draw function.

Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

You are right it is related to the theme.

The call of the GTK functions: gtk_widget_get_style_context, gtk_style_context_get_background_color, tk_style_context_get_color are emitting a draw signals to psensor when the widget does not have the focus.

BTW, by caching the retrieval of fg/bg colors when drawing the psensor curves, I can easily fix the CPU overuse in the Psensor code. I verified than it works, there is no more CPU overuse when the focus is lost.

I will try to commit a fix in a PPA asap.

Revision history for this message
Jean-Philippe Orsini (jfi) wrote :
Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

The release 1.1.5 of psensor is containing the fix.

Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Hans-Gregor, you could use the PPA of psensor to get the fix:

sudo apt-add-repository ppa:jfi/ppa
sudo apt-get update
sudo apt-get install psensor

then restart psensor

Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Attached the debdiff for Ubuntu Xenial which is fixing the issue

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "lp1582930.debdiff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Revision history for this message
Hans-Gregor Gehrke (b-u6untu-r) wrote :

Hi,
Jean-Philippe, thank you for the fixed new version! It works well with Unity (Ubuntu 16.04 and default theme) without wasting CPU time. htop reports an average of about 0.6% cpu cycle time running in the background.
Therefore, I can confirm, the binaries provided by ppa:jfi/ppa (Version 1.1.5) fix the bug.

regards Gregor

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Thanks for the debdiff Jean-Philippe. Unfortunately it fails to build in Ubuntu 16.04 LTS. I believe you also need to add a second patch:

http://wpitchoune.net/gitweb/?p=psensor.git;a=commit;h=50550d7ed65b9f86b7c231abc993dd858db01c09

Please also tag the patches using DEP-3: (http://dep.debian.net/deps/dep3/)

For example:

Description: Fixed CPU overuse when focus is lost.
Author: Jean-Philippe Orsini <email address hidden>
Origin: upstream, http://wpitchoune.net/gitweb/?p=psensor.git;a=commit;h=9a85d16663d7837698a3b00574a0652db1f849af
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/psensor/+bug/1582930

Thanks!

Changed in psensor (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Sebastien Bacher (seb128) wrote :

(unsubscribing sponsors to get it out of the queue until it's good again for review, please subscribe ubuntu-sponsors back once you fixed the issue described in the previous comment)

Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Second version of the patch (debdiff) adding a fix of a build failure when a recent version of MHD is used.

Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Marc, thanks for the review and the comment. I am quite lost how to use thse DEP-3 tags in practice, I will try to do it as soon as I understand how to do it:(

Changed in psensor (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Jean-Philippe Orsini (jfi) wrote :

Added DEP-3 headers as recommend by Marc

Revision history for this message
Mattia Rizzolo (mapreri) wrote :

From me it looks like you put the two commits from upstream in the same patch file, while linking only one in the Orig field. Would you please use two different patches? It's even easier, as you'd just be copying the upstream commit.

Given that that fix is in upstream 1.1.5 I marked the bug as fixed already, and kept open only a task for xenial.

Changed in psensor (Ubuntu):
status: Confirmed → Fix Released
Changed in psensor (Ubuntu Xenial):
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Mattia Rizzolo (mapreri) wrote :

unsubscribing sponsors; please re-subscribe it once ready.

Revision history for this message
Larry Wilson (larry2311) wrote :

It has been well over 12 months now and still the fix version 1.1.5 is *not* in the main repositories for 16.04.

So, simple questions:
Why not?, and
Why is to so?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.