[ntp:questions] improving ntpd performance on Windows

Dave Hart davehart at gmail.com
Wed Mar 4 19:44:37 UTC 2009

On Mar 2, 1:46 pm, "David J Taylor" <david-tay... at blueyonder.neither-
this-bit.nor-this.co.uk> wrote:
> Folks,
> Dave Hart asked that I post this information:
> Very briefly, I happen to have a 100Hz system, and have been playing with
> the improved version of ntpd.exe on a Windows 2000 system.  Working with
> Dave, we found that it did have some issues, and it seems that these
> issues have probably been resolved by setting the sample interval to 26
> milliseconds instead of the default 43 milliseconds.

After seeing the performance of David Taylor's Windows ntpd with a
refclock on a 100 Hz system was not doing as well as my 64 Hz system,
David spent a chunk of time testing all the intervals from 26 through
32 on his system and noting the jitter over a few minutes.  He found
that 27 was the best NTPD_INT_INT value for a 100 Hz system of those
tested.  David, would you mind posting your results in case anyone
else wants to try more intervals and do so comparably?

> Although with a Windows XP or later system, you could do this by setting a
> System environment variable:
> Variable:
> String value:
>   26
> You would do this by right clicking on my computer and pick properties.
> Use the Environment Variables button in the Advanced tab of the Computer
> Properties dialog, and be sure to add a System variable rather than a User
> variable.
> However, in a Windows 2000 system, it seems that the environment is not
> read again when your stop and restart a service, so Dave advised me to run
> ntpd.exe interactively, so I ended up with a command file like:
> ___________________________________
> CD <where-ntpd.exe lives>
> ntpd -n -g -c "c:\ntp\ntp.conf" -M
> ___________________________________

The system environment variable works on Windows 2000, but you have to
restart the PC for it to take effect.  Running interactively works
around that.  On XP and later, as David indicated, you can set the
system environment variable and restart the NTP service and have the
new value respected immediately.  Apparently as of XP the service
control manager re-reads the environment variables from the registry
on each service start.

I released another test version today on http://davehart.net/ntp/refclock/
Contrary to my previous claim, my recent versions have not been using
the observed performance counter frequency instead of the nominal one
from QueryPerformanceFrequency.  A range-gate in my code to observe
the performance counter was preventing any changes silently.  This had
apparently been the case since I switched to the new interpolation
strategy.  Today's version re-enables the tuning and seems to have
knocked a bit more jitter out of the interpolated time in my case.
The nominal frequency is used for the first 36 minutes as four 512
second samples of the observed counter frequency are collected, then
the observed value is switched into use and updated every 512 seconds
thereafter.  This resulted in cutting short-term jitter in half
(observed as a vertical smearing of the offset graph line).  The
relatively long averaging period of over 30 minutes is not ideal, but
comes from experimentation where smaller averaging periods seemed to
cause too much varaition in the observed counter frequency.

Dave Hart

More information about the questions mailing list