Sometimes the minutes update may have a latency of up to 9 seconds. Reproduce as follows. Start gkrellm and configure it display the time with one second resolution. Bring up the datetime plugin properties panel and wait for gkrellm to show the system time is 8 or 9 seconds past the minute. (The datetime plugin's time format must show minutes, but not seconds.) Click close immediately. Wait for gkrellm to show the next minute (i.e. the minute tick) and begin counting seconds. The datetime plugin displays the current minutes after a delay of 8 or 9 seconds. This procedure is more reliable and (the latency more annoying) if the computer is accurately synced with atomic time (e.g. by running ntpd) and if a radio-controlled clock (also synced with atomic time) is available that "ticks" each second. (Some analog radio-controlled clocks make an audible sound each second.) WWV could also be used for an audible tick. Version is trunk. See also bug 4117, comment 4.
Created attachment 1649 patch to synchronize plugin updates with system clock This patch is on top of the patch attached in bug 4117, comment 2.
Thanks for the patch. I simplified the math a bit and committed as r4862. I think it should be mathematically equivalent, and seems to work for me. Please reopen this bug if there are any problems.
(In reply to comment #2) > Thanks for the patch. I simplified the math a bit and committed as r4862. I > think it should be mathematically equivalent, and seems to work for me. Thanks! Your simplification is much nicer. I would never have thought to cast to a gint64 to avoid overflow. A stack of four instances of the plugin with each configured to update once a second appears to update simultaneously and in sync with my radio-controlled clock (with the computer running ntpd). Likewise when all four are configured to update once a minute. Running strace on the panel shows a latency of about 3 ms on the update of the first instance and a latency of about 5 ms to 8 ms for the fourth instance. Powertop shows 1.0 wakeups per second when all four updates are once a second and less than 0.1 wakeups per second when all updates are once a minute.
Created attachment 1652 strace snippet showing update latencies in stack of four instances This strace snippet was captured with the panel running four instances of the datetime plugin. All four instances were configured to display the time in seconds. The annotation names the functions called by datetime_update() that ultimately make calls to gettimeofday(). $ ps -e | grep xfce4-panel 2383 ? 00:04:01 xfce4-panel $ strace -p 2383 -ttt 2>strace1.txt
Heh, those are some cool ways of verifying the change, thanks.