[ntp:questions] Power-saving patch to NTP

David L. Mills mills at udel.edu
Sat May 17 03:48:32 UTC 2008


Evandro and others,

Now it's me that missed the point. I didn't realize you were concerned 
about a milliwatt or two every second. My first kneejerk reaction was 
why would you use ntpd on a laptop under conditions where it might 
sleep? Better to kill it before sleeping and restart when waking up. My 
second jerk was, even if the seconds interrupt could be avoided, there 
are still arriving and departing packets. I assume this wakes the beast, 
although at 1024 s poll, that might not be a problem.

Well, let's consider the case of a tickless ntpd and see what breaks. 
The first thing that breaks is the frequency discipline. As somebody 
mentioned, that can be done in the kernel on the assumption that tick 
interrupts dyill work. At a tick interrupt rate of 1000 Hz, this doesn't 
seem a good idea. Or maybe the hardware can be programmed to adjust the 
frequency. The frequency needs to be desciplined to the order of a few 
parts in 10^9, which would require some unusual chipset capabilities.

A second approach might be to abandon frequency discipline except when a 
packet shows up, which with laptops I know will considerably degrade the 
accuracy, probablly to many tens of milliseconds, but this might not 
matter if the machine is sleeping. When it comes awake; however, there 
will ee nasty transient. Even more clever, anticipate the change due to 
the calibrated frequency error and yank accordingly. To do this, 
however, means a substantial modification of the clock discipline 
algorithm and some kind os switch to know when to do this.

Next, just dropping in a timer queue facility makes no sense unless 
those peskty seconds counters can be replaced by calculated intervals 
that may have to be recalculated when some event or other happens. To do 
this is a major redesign job. Even considering the effort and testing 
requiree, it might be a worthwhile project better suited to an 
implementation other than ntpd. Maybe openNTP or chrony would be a 
better place to start.

Better yet, take the ntp_proto.c module from thedistribution, throw 
everything else out and rebuild the infrastructure specialized for 
laptops. I must disclose I have an ulterior motive here, since an 
approach like this is needed for spacecraft.

Dave

Evandro Menezes wrote:

> On May 16, 12:29 pm, "David L. Mills" <mi... at udel.edu> wrote:
> 
>>In modern machines a timer interupt takes about one microsecond and to
>>scan through the one-second code is really quick. So, we are talking
>>about an overhead in the order of .00001 percent.
> 
> 
> In terms of performance, yes, but in terms of power, no.  If NTP gets
> the CPU out of a deep stand-by state, then it may take hundreds of
> milliseconds for the CPU to go back to that state.  Moreover, NTP 1s-
> timer may prevent the CPU from going to even deeper stand-by states.
> 
> With this in mind, if NTP wakes the CPU up in order to do nothing,
> it's not doing the right thing, IMHO.
> 
> HTH




More information about the questions mailing list