[ntp:questions] WinNT Port Performance Counter Stability and Drift

Brian Inglis Brian.Inglis at Shaw.ca
Thu Nov 7 22:15:25 UTC 2013


 From the attached extract from my ntp log the current performance counter appears to have much higher drift ~25PPM than my hardware clock; my own calibration, timings, and loopstats over the last couple of years show ~0.9PPM.

A possible reason is that currently when calibrating and using PCC only a bare rdtsc instruction is used.
 From discussions in various places, summarized well in the article linked below, rdtsc may be executed out of order, adding jitter.
These discussions recommend rdtsc be preceded by mfence (as it works on all PCs that support rdtsc) to avoid out of order execution during calibration loops.
The calibration also needs to be wired to a single cpu, results from the first call to the calibration function discarded to eliminate cache and pipeline fill delays, and all results significantly higher than average discarded because the hardware can switch into System Management Mode BIOS at random, mainly to handle USB devices like mice, keyboards, drives.
See http://lists.freebsd.org/pipermail/freebsd-amd64/2012-July/014756.html, links from that, and similar articles on the LKML and MSDN.
-- 
Take care. Thanks, Brian Inglis
-------------- next part --------------
12 Oct 17:03:41 ntpd[2968]: ntpd 4.2.6p5 at 1.2349-o Jul 30 11:55:08 (UTC+02:00) 2012  (2)
12 Oct 17:03:41 ntpd[2968]: logging to file C:/ProgramData/NTP/etc/ntp.log
12 Oct 17:03:41 ntpd[2968]: Raised to realtime priority class
12 Oct 17:03:41 ntpd[2968]: MM timer resolution: 1..1000000 msec, set to 1 msec
12 Oct 17:03:41 ntpd[2968]: Performance counter frequency 2.539 MHz
12 Oct 17:03:41 ntpd[2968]: Clock interrupt period 15.600 msec
12 Oct 17:03:41 ntpd[2968]: Windows clock precision 15.600 msec, min. slew 6.410 ppm/s
12 Oct 17:03:41 ntpd[2968]: HZ 64.102 using 43 msec timer 23.256 Hz 64 deep
12 Oct 17:03:44 ntpd[2968]: proto: precision = 0.400 usec
12 Oct 17:03:45 ntpd[2968]: 0.0.0.0 c012 02 freq_set ntpd 0.850 PPM
12 Oct 17:03:52 ntpd[2968]: 0.0.0.0 c61c 0c clock_step +0.529863 s
12 Oct 17:03:52 ntpd[2968]: HZ 64.102 using 43 msec timer 23.256 Hz 64 deep
12 Oct 17:03:55 ntpd[2968]: 0.0.0.0 c614 04 freq_mode
12 Oct 17:18:56 ntpd[2968]: 0.0.0.0 c412 02 freq_set ntpd 6.215 PPM
12 Oct 17:18:56 ntpd[2968]: 0.0.0.0 c415 05 clock_sync
12 Oct 17:21:43 ntpd[2968]: ctr 2.537964 MHz -471.02 PPM using 2.538762 MHz -156.74 PPM
12 Oct 17:39:43 ntpd[2968]: ctr 2.539225 MHz +25.60 PPM using 2.538783 MHz -148.47 PPM
12 Oct 17:57:43 ntpd[2968]: ctr 2.539224 MHz +25.21 PPM using 2.538805 MHz -139.81 PPM
12 Oct 22:09:41 ntpd[2968]: clock would have gone backward 1 times, max 20.9 usec
13 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
14 Oct 11:21:41 ntpd[2968]: clock would have gone backward 1 times, max 33.1 usec
14 Oct 17:57:43 ntpd[2968]: ctr 2.539226 MHz +25.99 PPM
15 Oct 02:21:41 ntpd[2968]: clock would have gone backward 1 times, max 59.1 usec
15 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
15 Oct 18:51:41 ntpd[2968]: clock would have gone backward 1 times, max 31.9 usec
16 Oct 14:03:41 ntpd[2968]: clock would have gone backward 1 times, max 30.7 usec
16 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
17 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
18 Oct 01:27:41 ntpd[2968]: clock would have gone backward 1 times, max 39.0 usec
18 Oct 17:21:41 ntpd[2968]: clock would have gone backward 1 times, max 29.1 usec
18 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
19 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
19 Oct 19:09:41 ntpd[2968]: clock would have gone backward 1 times, max 28.3 usec
20 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
21 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
22 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
23 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
24 Oct 13:27:41 ntpd[2968]: clock would have gone backward 1 times, max 27.9 usec
24 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
25 Oct 05:03:41 ntpd[2968]: clock would have gone backward 1 times, max 5.5 usec
25 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
25 Oct 22:09:41 ntpd[2968]: clock would have gone backward 1 times, max 19.3 usec
26 Oct 04:27:41 ntpd[2968]: clock would have gone backward 1 times, max 26.0 usec
26 Oct 10:45:41 ntpd[2968]: clock would have gone backward 1 times, max 26.7 usec
26 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
27 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
28 Oct 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
29 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
29 Oct 21:51:41 ntpd[2968]: clock would have gone backward 1 times, max 28.4 usec
30 Oct 06:15:41 ntpd[2968]: clock would have gone backward 1 times, max 57.1 usec
30 Oct 10:09:41 ntpd[2968]: clock would have gone backward 1 times, max 38.2 usec
30 Oct 17:03:41 ntpd[2968]: clock would have gone backward 1 times, max 10.6 usec
30 Oct 17:57:43 ntpd[2968]: ctr 2.539220 MHz +23.63 PPM
30 Oct 22:45:41 ntpd[2968]: clock would have gone backward 1 times, max 26.0 usec
31 Oct 01:27:41 ntpd[2968]: clock would have gone backward 1 times, max 62.3 usec
31 Oct 05:21:41 ntpd[2968]: clock would have gone backward 1 times, max 26.0 usec
31 Oct 17:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
31 Oct 20:57:41 ntpd[2968]: clock would have gone backward 1 times, max 4.3 usec
 1 Nov 00:33:41 ntpd[2968]: clock would have gone backward 1 times, max 28.7 usec
 1 Nov 07:27:41 ntpd[2968]: clock would have gone backward 1 times, max 27.9 usec
 1 Nov 14:03:41 ntpd[2968]: clock would have gone backward 1 times, max 26.4 usec
 1 Nov 17:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
 2 Nov 11:03:41 ntpd[2968]: clock would have gone backward 1 times, max 59.5 usec
 2 Nov 17:57:43 ntpd[2968]: ctr 2.539221 MHz +24.02 PPM
 3 Nov 09:45:41 ntpd[2968]: clock would have gone backward 1 times, max 28.8 usec
 3 Nov 16:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
 4 Nov 03:41:45 ntpd[2968]: 66.219.116.140 948d 8d popcorn 0.004811 s
 4 Nov 16:57:43 ntpd[2968]: ctr 2.539222 MHz +24.42 PPM
 5 Nov 10:21:41 ntpd[2968]: clock would have gone backward 1 times, max 37.4 usec
 5 Nov 16:57:43 ntpd[2968]: ctr 2.539221 MHz +24.02 PPM
 6 Nov 14:15:41 ntpd[2968]: clock would have gone backward 1 times, max 28.3 usec
 6 Nov 16:57:43 ntpd[2968]: ctr 2.539223 MHz +24.81 PPM
 7 Nov 03:09:41 ntpd[2968]: clock would have gone backward 1 times, max 29.9 usec
 7 Nov 03:45:41 ntpd[2968]: clock would have gone backward 1 times, max 32.2 usec


More information about the questions mailing list