This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 390711 - Wakes up frequently
Wakes up frequently
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: mail-notification (Show other bugs)
8
All Linux
low Severity low
: ---
: ---
Assigned To: Thorsten Leemhuis
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks: wakeup
  Show dependency treegraph
 
Reported: 2007-11-19 12:22 EST by Tim Waugh
Modified: 2008-05-04 07:16 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-12-20 12:24:58 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Tim Waugh 2007-11-19 12:22:00 EST
Description of problem:
The mail-notification program seems to wake up more frequently than is
necessary.  strace reveals that it never sleeps for more than about 500
milliseconds, and looking through the source it seems to be to do with the
mn-tooltips module.

Version-Release number of selected component (if applicable):
mail-notification-4.1-4.1

How reproducible:
100%

Steps to Reproduce:
1.ps xf
2.strace -p <pid>
-or-
1.powertop
Comment 1 Thorsten Leemhuis 2007-11-20 14:57:12 EST
Seen this as well; but this is not Fedora specific, thus I think that's best
tracked and fixed directly upstream. I forwarded the problem to upstream's
bugtracker:

https://savannah.nongnu.org/bugs/index.php?21618
Comment 2 Thorsten Leemhuis 2007-11-25 08:04:27 EST
Upstream seems to belive that is okay:
https://savannah.nongnu.org/bugs/?20214

I agree that the situation could be improved, but I don't have the skills for
that and I think it should be done upstream in any case, as that is nothing
Fedora specific. Thus closing this here.
Comment 3 Bastien Nocera 2007-11-25 10:34:55 EST
And how is that normal?
Comment 4 Tim Waugh 2007-11-26 04:54:46 EST
nm-tooltips is based on an old gtktooltips.  The current gtktooltips does seem
to have the same '#define DEFAULT_DELAY 500' but I can't see that it's used
anywhere for setting a timeout (just for setting member data that is not
referenced elsewhere).

So I think it's just that nm-tooltips.c needs porting to the newer GTK+
gtktooltips.c.
Comment 5 Dmitry Butskoy 2007-11-26 07:44:31 EST
> Upstream seems to belive that is okay

I maintain another two packages from the same upstream. It is a good upstream,
there are good packages from it, but... the promotion of patches for this
upstream is... a little bit harder rather than could be expected.

If you believe me, than it is our task to fix this.

Reopen.

> So I think it's just that nm-tooltips.c needs porting to the newer GTK+
> gtktooltips.c.

Thorsten, (again :) ) show us the latest build logs. please.


Comment 6 Thorsten Leemhuis 2007-11-26 12:52:03 EST
(In reply to comment #3)
> And how is that normal?

The upstream author said that (you found it in the upstream bug) and he's not
CCed to this bug, so he can not answer your question.

(In reply to comment #4)
> nm-tooltips is based on an old gtktooltips.  The current gtktooltips does seem
> to have the same '#define DEFAULT_DELAY 500' but I can't see that it's used
> anywhere for setting a timeout (just for setting member data that is not
> referenced elsewhere).
> 
> So I think it's just that nm-tooltips.c needs porting to the newer GTK+
> gtktooltips.c.

Sounds good, but I don't have the skills for that, as I'm one of the fedora
package monkeys as dwmw2 calls them. And I actually think this isn't something
Fedora specific, that's why I think it should best dealt with upstream directly,
as that leads to improvements for everyone and avoids that work is done in
wasted because it's done in multiple places. 

I'm again willing to forward recent comments from this bug to the upstream bug
tracker, maybe the upstream author will then understand the issue better and
consider fixing it (maybe he did it already, there is no public devel repo).

I even would be a bit unwilling to ship a patch (if one would exists) for
anything else then testing purposes if there is no indication from upstream to
apply it sooner or later (similar how our kernel guys are unwilling to ship
patchs that are not heading upstream), thus I disagree with this:

(In reply to comment #5)
> If you believe me, than it is our task to fix this.

See also http://fedoraproject.org/wiki/PackageMaintainers/WhyUpstream 

If there is anything to improve that is not fedora-specific let's to it in a
coordinated way upstream please.
Comment 7 Jean-Yves Lefort 2007-12-01 07:47:51 EST
It has nothing to do with mn-tooltips. That timeout is a one-shot timeout. It is
caused by one or more of the following:

- MN updating the "Sent" time fields of the tooltip's mail summary. These fields
are updated every 500 milliseconds.
- If you're monitoring an Evolution mailbox, MN pinging Evo every second to
check if it's still running.
- If the icon is blinking because of an error, the 500 ms blink timeout (obviously).

I see nothing unnecessary in these actions.
Comment 8 Bastien Nocera 2007-12-01 09:00:31 EST
(In reply to comment #7)
> It has nothing to do with mn-tooltips. That timeout is a one-shot timeout. It is
> caused by one or more of the following:
> 
> - MN updating the "Sent" time fields of the tooltip's mail summary. These fields
> are updated every 500 milliseconds.

This should only be updated when the tooltip is queried. It doesn't need to be
updated otherwise...

> - If you're monitoring an Evolution mailbox, MN pinging Evo every second to
> check if it's still running.

Evolution can also use D-Bus to tell your application that new mail has come in.
See the mail-notification plugin:
http://svn.gnome.org/viewvc/evolution/trunk/plugins/mail-notification/mail-notification.c?revision=34537&view=markup

You just need to check the folder URI or name to see if it pertains to you.

> - If the icon is blinking because of an error, the 500 ms blink timeout
(obviously).

That's obvious, but does it respect the GTK+ no-animation configuration option?
Comment 9 Jean-Yves Lefort 2007-12-01 10:07:54 EST
(In reply to comment #8)
> (In reply to comment #7)
> > It has nothing to do with mn-tooltips. That timeout is a one-shot timeout. It is
> > caused by one or more of the following:
> > 
> > - MN updating the "Sent" time fields of the tooltip's mail summary. These fields
> > are updated every 500 milliseconds.
> 
> This should only be updated when the tooltip is queried. It doesn't need to be
> updated otherwise...

GtkTooltip (which I will switch to in a couple of months, now that it supports
the "custom widget" feature that initially motivated my own tooltips fork) does
not provide a way to run code when the tooltip is shown or hidden. Even if it
did, it would be bad design to add code for suppressing the updates while the
tooltip is hidden, since these updates are extremely cheap.

> > - If you're monitoring an Evolution mailbox, MN pinging Evo every second to
> > check if it's still running.
> 
> Evolution can also use D-Bus to tell your application that new mail has come in.
> See the mail-notification plugin:
>
http://svn.gnome.org/viewvc/evolution/trunk/plugins/mail-notification/mail-notification.c?revision=34537&view=markup
> 
> You just need to check the folder URI or name to see if it pertains to you.

I have no idea what you are talking about nor why do you think that dbus could
lift the pinging requirement. That link points to an Evolution plugin which not
only does not use dbus, but also cannot be compared to MN: while that plugin
performs the notifications (popup and icon) itself, the MN plugin simply informs
MN (a standalone application) that a folder has changed.

> > - If the icon is blinking because of an error, the 500 ms blink timeout
> (obviously).
> 
> That's obvious, but does it respect the GTK+ no-animation configuration option?

What this has to do with the fact that making the icon blink involves running
code every 500 ms? By the way, it seems to me that blinking cannot be considered
an animation. GtkStatusIcon (which also supports blinking) does not respect that
setting either.
Comment 10 Jean-Yves Lefort 2007-12-01 10:14:31 EST
(In reply to comment #5)
> > Upstream seems to belive that is okay
> 
> I maintain another two packages from the same upstream. It is a good upstream,
> there are good packages from it, but... the promotion of patches for this
> upstream is... a little bit harder rather than could be expected.
> 
> If you believe me, than it is our task to fix this.

I imagine that you're talking about me, but unfortunately I've never received
any patch from you.
Comment 11 Bastien Nocera 2007-12-07 06:10:52 EST
(In reply to comment #9)
> (In reply to comment #8)
> > (In reply to comment #7)
> > > It has nothing to do with mn-tooltips. That timeout is a one-shot timeout.
It is
> > > caused by one or more of the following:
> > > 
> > > - MN updating the "Sent" time fields of the tooltip's mail summary. These
fields
> > > are updated every 500 milliseconds.
> > 
> > This should only be updated when the tooltip is queried. It doesn't need to be
> > updated otherwise...
> 
> GtkTooltip (which I will switch to in a couple of months, now that it supports
> the "custom widget" feature that initially motivated my own tooltips fork) does
> not provide a way to run code when the tooltip is shown or hidden. Even if it
> did, it would be bad design to add code for suppressing the updates while the
> tooltip is hidden, since these updates are extremely cheap.

From the GtkTooltip docs:
"
Connect to the GtkWidget::query-tooltip signal. This signal will be emitted when
a tooltip is supposed to be shown. One of the arguments passed to the signal
handler is a GtkTooltip object. This is the object that we are about to display
as a tooltip, and can be manipulated in your callback using functions like
gtk_tooltip_set_icon(). There are functions for setting the tooltip's markup,
setting an image from a stock icon, or even putting in a custom widget.
"

So it's possible (and easy) to avoid wake-ups with the new tooltips. The fact
that they're "cheap" updates, I'm not denying, but they're also waking up the
process needlessly.

> > > - If you're monitoring an Evolution mailbox, MN pinging Evo every second to
> > > check if it's still running.
> > 
> > Evolution can also use D-Bus to tell your application that new mail has come in.
> > See the mail-notification plugin:
> >
>
http://svn.gnome.org/viewvc/evolution/trunk/plugins/mail-notification/mail-notification.c?revision=34537&view=markup
> > 
> > You just need to check the folder URI or name to see if it pertains to you.
> 
> I have no idea what you are talking about nor why do you think that dbus could
> lift the pinging requirement. That link points to an Evolution plugin which not
> only does not use dbus, but also cannot be compared to MN: while that plugin
> performs the notifications (popup and icon) itself, the MN plugin simply informs
> MN (a standalone application) that a folder has changed.

You're right, it doesn't use D-Bus (not sure why I though that). But the Evo
plugin shows that there's no need to poke evolution itself for updates, and the
main application doesn't need to query the plugin if the plugin is telling the
main application about its change in status (eg. emmitting a D-Bus signal from
the plugin that the main application would receive).

> > > - If the icon is blinking because of an error, the 500 ms blink timeout
> > (obviously).
> > 
> > That's obvious, but does it respect the GTK+ no-animation configuration option?
> 
> What this has to do with the fact that making the icon blink involves running
> code every 500 ms? By the way, it seems to me that blinking cannot be considered
> an animation. GtkStatusIcon (which also supports blinking) does not respect that
> setting either.

You're right as well. Ignore that.
Comment 12 Jean-Yves Lefort 2007-12-07 07:03:20 EST
(In reply to comment #11)
> So it's possible (and easy) to avoid wake-ups with the new tooltips. The fact
> that they're "cheap" updates, I'm not denying, but they're also waking up the
> process needlessly.

I'm updating it every 500 ms because the displayed time is relative. Eg: "Sent:
15 seconds ago".

> You're right, it doesn't use D-Bus (not sure why I though that). But the Evo
> plugin shows that there's no need to poke evolution itself for updates, and the
> main application doesn't need to query the plugin if the plugin is telling the
> main application about its change in status (eg. emmitting a D-Bus signal from
> the plugin that the main application would receive).

I don't poke Evo for updates. I have already mentioned that I ping it to check
whether it's running or not.
Comment 13 Bastien Nocera 2007-12-07 07:21:50 EST
(In reply to comment #12)
> (In reply to comment #11)
> > So it's possible (and easy) to avoid wake-ups with the new tooltips. The fact
> > that they're "cheap" updates, I'm not denying, but they're also waking up the
> > process needlessly.
> 
> I'm updating it every 500 ms because the displayed time is relative. Eg: "Sent:
> 15 seconds ago".

That doesn't mean you need to update the tooltip _straight away_. You could
update it only when it's going to be shown, meaning you can remove the
continuous (and unneeded) update when the tooltip isn't being shown.

> > You're right, it doesn't use D-Bus (not sure why I though that). But the Evo
> > plugin shows that there's no need to poke evolution itself for updates, and the
> > main application doesn't need to query the plugin if the plugin is telling the
> > main application about its change in status (eg. emmitting a D-Bus signal from
> > the plugin that the main application would receive).
> 
> I don't poke Evo for updates. I have already mentioned that I ping it to check
> whether it's running or not.

You could add D-Bus to your Evo plugin, and get notified when the service
appears, so you don't need to ping it.
Comment 14 Jean-Yves Lefort 2007-12-07 08:41:59 EST
(In reply to comment #13)
> That doesn't mean you need to update the tooltip _straight away_. You could
> update it only when it's going to be shown, meaning you can remove the
> continuous (and unneeded) update when the tooltip isn't being shown.

It's still silly. You're asking me make the code more convoluted just to save an
infinitesimal amount of resources. I've already said above that I won't do that.
It is questionable engineering, to say the least.

And btw, it would only suppress the updates that occur before the tooltip is
shown, since there is no "unquery-tooltip" signal for suppressing the updates
that occur after the tooltip has been closed.

> You could add D-Bus to your Evo plugin, and get notified when the service
> appears, so you don't need to ping it.

I might consider that option (not to get rid of the entirely neglectible ping
penalty, but to update the UI sooner after Evo is started or exited) if it turns
out that dbus provides an easy way to embed widgets in another process. I need
it for embedding the Evolution folder list widget inside the MN props dialog.
Comment 15 Thorsten Leemhuis 2007-12-10 01:46:16 EST
> It's still silly. You're asking me make the code more convoluted just to save an
> infinitesimal amount of resources. [...]

It might be a "infinitesimal amount of resources" if you count only MN -- but if
you look at the big picture then MN and other apps that waste a similar amount
of resources sum up to a noticeable amount of wasted resources, which results in
a higher power consumption and thus shorter battery life on laptops.
Comment 16 Jean-Yves Lefort 2007-12-11 20:07:58 EST
MN does not waste resources. As I said, it makes no sense to perform an
optimization which would make the code more complex if that optimization brings
no measurable performance improvements.
Comment 17 Thorsten Leemhuis 2007-12-12 01:33:12 EST
(In reply to comment #16)
> MN does not waste resources.

The process get active two times a second even when there is nothing to do (no
pop-up being shown, no evolution account configured, no error blinking). That
wakes up the CPU, which has to do a bit of work -- that might not be much
resources, but it are (power) resources that get wasted. And it made four people
(two of them well known developers) argue with you here, so it seems to be
important for some people.

> As I said, it makes no sense to perform an
> optimization which would make the code more complex if that optimization brings
> no measurable performance improvements.

Performance as in "faster" is not the only thing we aim for these days (and not
what this bug is about). We aim for "better energy performance" (e.g. use less
energy)
Comment 18 Jean-Yves Lefort 2007-12-12 21:01:52 EST
(In reply to comment #17)
> (In reply to comment #16)
> > MN does not waste resources.
> 
> The process get active two times a second even when there is nothing to do (no
> pop-up being shown, no evolution account configured, no error blinking). That
> wakes up the CPU, which has to do a bit of work -- that might not be much
> resources, but it are (power) resources that get wasted. And it made four people
> (two of them well known developers) argue with you here, so it seems to be
> important for some people.

You don't seem to realize that regardless of whether MN is blocking in poll() or
running, your CPU does not sleep. The OS has to service interrupts, schedule all
processes that are in run state (MN hardly being the only one), and so on.

> > As I said, it makes no sense to perform an
> > optimization which would make the code more complex if that optimization brings
> > no measurable performance improvements.
> 
> Performance as in "faster" is not the only thing we aim for these days (and not
> what this bug is about). We aim for "better energy performance" (e.g. use less
> energy)

These neglectible cycles consume a neglectible amount of energy.
Comment 19 Dmitry Butskoy 2007-12-13 07:25:17 EST
> ...your CPU does not sleep. The OS has to service interrupts,
> schedule all processes that are in run state

But the latest Linux kernels are "tickless". In other words, no more HZ ...

It could provide a possibility where your CPU can be stopped at all until you
press some button on your laptop. The stopped (or decreased speed) CPU eats less
buttery power. Thus the idea to avoid even 0.5 sec timeouts is not soo idiotic ;)

Certainly it is some newest feature of the Linux kernels only, hence you have a
right to not handle it in the upstream project. But could you at least point for
the people where they could start to implement some patch on your code?
Comment 20 Jean-Yves Lefort 2007-12-13 10:32:50 EST
(In reply to comment #19)
> > ...your CPU does not sleep. The OS has to service interrupts,
> > schedule all processes that are in run state
> 
> But the latest Linux kernels are "tickless". In other words, no more HZ ...
> 
> It could provide a possibility where your CPU can be stopped at all until you
> press some button on your laptop. The stopped (or decreased speed) CPU eats less
> buttery power. Thus the idea to avoid even 0.5 sec timeouts is not soo idiotic ;)

How much power are you talking about? How much battery time do you intend to
save by complicating MN? It makes no sense to optimize if you don't know what
kind of gain can be expected from the optimization.
Comment 21 Dmitry Butskoy 2007-12-13 10:42:00 EST
How much I've understood, they want to fix each of such an application, and "in
a sum" it will give an effect, just totally.

See coment #15 and how many dependencies are present for "collect" bug #204948 ...
Comment 22 Bastien Nocera 2007-12-19 11:29:42 EST
(In reply to comment #20)
<snip>
> How much power are you talking about? How much battery time do you intend to
> save by complicating MN? It makes no sense to optimize if you don't know what
> kind of gain can be expected from the optimization.

You could save about an hour's worth of battery on a typical 4-hour battery-life
laptop, if all the applications are fixed. You can test this out easily using
powertop to disable/remove all the components that cause wakeups.
Comment 23 Jean-Yves Lefort 2007-12-20 11:52:48 EST
I don't doubt that you can save substantial battery time by disabling software.
You'll save even more by uninstalling your OS altogether. Yet, in a realistic
setup, the change we are discussing would have no measurable effect.

Indeed, MN is not the only cause of wakeups; even if you "fix" applications,
there will still be necessary wakeups; it's not like without MN, your CPU would
be able to idle for long.
Comment 24 Dmitry Butskoy 2007-12-20 12:24:58 EST
Upstream is not considering it as a bug. Closed. :-|
Comment 25 Arjan van de Ven 2007-12-20 12:54:19 EST
it's not like without MN, your CPU would
be able to idle for long.


this is a bogus argument; it's very possible (read: I have that on my machine 
at work) to 1.4 seconds of average idle time between wakeups.
Comment 26 Jean-Yves Lefort 2007-12-20 13:40:17 EST
(In reply to comment #25)
> it's not like without MN, your CPU would
> be able to idle for long.
> 
> 
> this is a bogus argument; it's very possible (read: I have that on my machine 
> at work) to 1.4 seconds of average idle time between wakeups.

Yes, it's possible to disable everything and display an impressive idleness. No
cursor blinking, no applets, no web browser, no music player, and so on. I don't
deny that it's possible. You could even rewrite powertop as a standalone
bootable program and display an even more impressive idleness.
Comment 27 Thorsten Leemhuis 2007-12-21 02:46:03 EST
(In reply to comment #26)
> Yes, it's possible to disable everything and display an impressive idleness.
> [...]

Okay okay, this is getting out of hand. It's not black (no MN) and white (MN
running), there are more states in between. So let's try to explain it in a
different way.

Jean-Yves, MN for us is like a small electric light somewhere in a car. If it's
on then it consumes a bit of energy, which results in a bit more fuel being
consumed my the engine. That's fine for example when the light serves a purpose
 -- e.g. to find switch in the night (in the MN case: check servers, show a
pop-up if new mail arrived, do all the other things MN was designed for). But
during days, where cars are driven most of the time, having the light on is just
wasting energy. Just a bit, but there are 100 other similar lights that do it as
well, which sums up to something measurable in total. That why we try to get all
of them out if there is no reasons for them.

For MN the lights afaics can be turned of when there is no evolution running, no
pop-up being shown and no mailbox polling needed. For a lot of use cases that's
the state in which mn is most of the time (for me it definitely is). That why we
like to see MN sleeping properly when there is nothing to do. 

Comment 28 Jean-Yves Lefort 2007-12-21 11:09:38 EST
I assert that this optimization would have no noticeable impact. Unless proven
otherwise, I won't perform it.
Comment 29 Nick Lamb 2008-05-01 20:58:28 EDT
"I assert that this optimization would have no noticeable impact."

Jean-Yves, are you asserting that your software is a special case, and should
not be held to the same requirement as other software? Otherwise, your argument
is senseless. If every program wakes up once per second because it has "no
noticeable impact" then the total impact can be several watts of wasted power
and thus is quite noticeable.

If you believe your program is a special case you should explain why, giving
examples that show why it's more important to wake up once per second to check
that there's no mail, rather than to wake up once per second to update a clock
that only shows minutes, or once per second to check that the mouse hasn't been
moved, or that the wireless network still has its radio switched off.

These types of wakeups have been eliminated, after considerable work, by other
people, so why does your software get to continue wasting power ?
Comment 30 Dmitry Butskoy 2008-05-04 07:16:52 EDT
For comment #29:

Since he is not in Cc: list, he does not hear you...

Does your comment regard to the latest upstream version 5.3? Perhaps it is
already fixed in 5.3 ...

Note You need to log in before you can comment on or make changes to this bug.