[ntp:questions] Vista NTP tamed, but with a blunt object

Terje Mathisen terje.mathisen at hda.hydro.com
Tue Jan 20 06:59:35 UTC 2009


Dave Hart wrote:
> I have a couple of machines on the same LAN behind consumer broadband
> NAT running ntp 4.2.4p6.
> 
> One is running Windows XP, the other Windows Vista, both 32-bit OSes.
> The Windows XP machine has done well with NTP, usually below 10ms
> offset.  The Vista machine, however, has spasmed with spikes of plus
> or minus 30-90ms in the offset with a wandering frequency drift
> estimate.
> 
> I've taken a blunt object to nt_clockstuff.c and was able to
> dramatically improve the performance on Vista by detecting its 1ms
> system time granularity (vs 10-15ms on earlier Windows) and switching
> QueryPerformanceCounter-based interpolation off at runtime, relying
> solely on GetSystemTimeAsFileTime to satisfy higher-level NTP requests
> for the current time.
> 
> I've posted three loopstats graphs that illustrate the difference on:
> 
> http://davehart.net/ntp/vista/blunt/index.html

It seems pretty obvious that we'll need to either detect at runtime that 
the system clock runs at 1000 Hz, or have a startup flag which 
enables/disables the current interpolation routine.

The alternative is somewhat ugly, and Dave Mills will probably pipe up 
and tell me it won't work (since it can cause instability):

Run a second clock control loop which filters the interpolation clock 
samples, only keeping those that arrive "early":

I.e. continuously calculate the average time (in QPC units) between two 
SystemTime updates, and discard those that arrive relatively late, i.e. 
with higher than 67th (or some other number) percentile of the delta time.

Another alternative is to modify the interpolation routine to be much 
more lightweight, avoiding all OS locks, by falling back on the RDTSC 
opcode, even if that works poorly on multi-cpu/multi-core machines.

However, the crucial issue is that there is simply no valid reason to 
deliver worse clock precision that what you get by simply returning the 
current SystemTime value:

If the calculated interpolation offset is larger than the average offset 
between two system clock ticks, then fall back on the base time without 
interpolation.

I have a Vista (64) laptop here, I can try to test a couple of 
alternatives and report back.

Terje

-- 
- <Terje.Mathisen at hda.hydro.com>
"almost all programming can be viewed as an exercise in caching"




More information about the questions mailing list