After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 348749 - clock wakes up too frequently
clock wakes up too frequently
Status: RESOLVED FIXED
Product: gnome-panel
Classification: Other
Component: clock
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Panel Maintainers
Panel Maintainers
Depends on:
Blocks: 356586
 
 
Reported: 2006-07-26 08:37 UTC by Allison Karlitskaya (desrt)
Modified: 2007-02-21 21:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix. (4.11 KB, patch)
2006-07-27 15:45 UTC, Allison Karlitskaya (desrt)
needs-work Details | Review
A fix for the continuous wake up of the clock, and the no regular update of Internet Time. (5.58 KB, patch)
2006-08-01 22:43 UTC, raster
needs-work Details | Review
an example of how to get and set timezone (33.29 KB, text/plain)
2006-08-08 00:00 UTC, William Jon McCann
  Details
alternative patch that is more minimally invasive (1.35 KB, patch)
2006-09-01 17:45 UTC, Arjan van de Ven
none Details | Review
another patch (1.35 KB, patch)
2006-09-01 18:19 UTC, Matthias Clasen
none Details | Review

Description Allison Karlitskaya (desrt) 2006-07-26 08:37:09 UTC
the clock does a syscall per second, even when seconds are disabled.

this is bad for battery life on portables.

it shouldn't be too hard to do the following:

if we are in don't-display-seconds mode:
  - take the current time of day and figure out how far until the next minute boundry.
  - schedule our next wakeup for that long -- not in 1 second from now.
Comment 1 Allison Karlitskaya (desrt) 2006-07-27 15:45:55 UTC
Created attachment 69742 [details] [review]
fix.

while fixing this bug i found another bug related to internet time.

we do something like printf("%3.0f", time) for internet time without second.  printf rounds up.  this means that @345.67 would show as @346 with seconds disabled which is a bit odd.

this wrongness is componded by the fact that the old "check if the time shown on the clock has changed" rounds down meaning that the change would actually occur only on integer boundries and therefore the clock would appear to be functioning normally (except if changing the format/orientation/etc of the clock while in the 0.5..1.0 period).

i fixed this by flooring the value before giving it to printf.

otherwise the patch should fix the problem as described.  please give it a go.
Comment 2 William Jon McCann 2006-07-27 17:34:00 UTC
IIRC this used to work correctly.  I think this regression was caused by the patch from bug #156796.
Comment 3 Allison Karlitskaya (desrt) 2006-07-27 21:18:38 UTC
One thing to note: the entire idea of sleeping for the interval of an 'internet time second' is cracked (at least with the current code).

The time() syscall is used to get the current time.  This only has second-level accuracy so even if you sleep for 800ms you will not get more than one-second accuracy.

Note also that nobody even noticed the bug about the improper rounding in internet time.  This makes me question how many people use internet time at all.
Comment 4 Vincent Untz 2006-07-28 06:17:34 UTC
Internet time should most probably be killed, or at least hidden.

Bug #156796 is indeed when we reintroduce the bug, but it clearly fixed a bug too. I don't know what we can do here...
Comment 5 Allison Karlitskaya (desrt) 2006-07-28 07:46:27 UTC
"If seconds are not showed the time is updated only every minute"

i don't understand why this is a problem.  if seconds are not shown then the correct behaviour is that the displayed time will change once per minute.

maybe i'm being terribly obtuse here.  if so, please explain to me slowly and with a baseball bat what the problem is :)
Comment 6 raster 2006-08-01 22:43:04 UTC
Created attachment 70049 [details] [review]
A fix for the continuous wake up of the clock, and the no regular update of Internet Time.

Hi all:

I fixed both bugs (wake up and internet time) with this patch. It calculates the time so far for the next minute and reprograms the timer for that time, unless the time is 60 seconds; in that case it will put the timer to 60 seconds and don't touch it again unless the user changes the configuration. Normally only two sets of the timer are needed.

For the second bug (the jumps in the internet time) I used the microsecond resolution (thanks, gettimeofday() :). Now it counts fine.
Comment 7 Vincent Untz 2006-08-07 21:49:23 UTC
I'll accept a patch which does nothing but monitors /etc/timezone to know that the clock should be updated.
Comment 8 Allison Karlitskaya (desrt) 2006-08-07 22:55:36 UTC
I've actually thought about a different problem.

If you actually change the date/time on your computer (not just the timezone), then the clock will take as long as a minute to update.  This is probably a more common case than changing your timezone.




Not sure if there is anything we can do about this, really.


In an ideal world, anything that changes the time would have a way of alerting all interested programs on the system.  Alternatively, the kernel could alert any interested parties when the time is stepped by more than a few seconds.

We need some more love from upstream for this to happen properly :(
Comment 9 William Jon McCann 2006-08-07 23:56:13 UTC
(In reply to comment #7)
> I'll accept a patch which does nothing but monitors /etc/timezone to know that
> the clock should be updated.

I think you'll find that it is a little more difficult than that - especially if you want something robust and reasonable cross-platform.
Comment 10 William Jon McCann 2006-08-08 00:00:47 UTC
Created attachment 70438 [details]
an example of how to get and set timezone

Here is an example from one of my ancient and slightly wrong-headed attempts to solve the timezone problems (from bug #154085).  So, you'd have to look at more than /etc/timezone.
Comment 11 Arjan van de Ven 2006-09-01 17:45:45 UTC
Created attachment 72035 [details] [review]
alternative patch that is more minimally invasive

Alternative patch attached; what it does is just the change to wait until the next redisplay, everything else already works as expected

yes this means that if you change timezones you may need to wait upto one minute for the clock to update. All other OSes have similar things as well and nobody seems to care about it..
Comment 12 Matthias Clasen 2006-09-01 18:19:18 UTC
Created attachment 72039 [details] [review]
another patch

For reference, here is the patch that I've put in the Fedora rpm
Comment 13 Behdad Esfahbod 2006-09-01 20:16:33 UTC
(In reply to comment #11)

> yes this means that if you change timezones you may need to wait upto one
> minute for the clock to update. All other OSes have similar things as well and
> nobody seems to care about it..

Well, actually I care, and at some point reported it in bugzilla.  This gives the feeling that the time change did not go through.  It is confusing, but probably not enough to reject patches in this bug. :-)
Comment 14 Allison Karlitskaya (desrt) 2006-09-02 01:37:35 UTC
Think about, also, a laptop returning from sleep.
Comment 15 Vincent Untz 2007-02-21 21:19:11 UTC
I committed a patch based on the latest ones.

I didn't fix the internet time issue, since the two patches fixing this are mixed with the patch for this bug. Ryan, raster: could you update your patches and add them to bug 410542? Thanks.