[ntp:questions] Allan deviation survey

Miroslav Lichvar mlichvar at redhat.com
Thu Sep 16 14:17:14 UTC 2010


On Thu, Sep 16, 2010 at 01:23:28AM +0000, David L. Mills wrote:
> The fastest machine I can find on campus has precision -22, or about
> 230 ns. Then, I peeked at time.nist.gov, which is actually three
> machines behind a load leveler. It reports to be an i386 running
> FreeBSD 61. Are you ready for this? It reports precision -29 or 1.9
> ns! I'm rather suspiciousabout that number. What  processor and
> operating system are you using. What is the precision reported by
> ntpd?

The processor is 2.4GHz Intel Core 2 with two cores and it's running
Linux 2.6.35. The precision reported by ntpd is -23.

As I have said, this is with the tsc clocksource. Kernel uses tsc only
when it's reliable and this seems to depend on used hardware
combination. When switched to hpet clocksource, the precision is 480
ns and with acpi_pm clocksource it's 1900 ns.

To give you an idea what would be the precision with tsc if there was
no system overhead, try this program:

#include <stdio.h>
#include <sys/time.h>

#define rdtsc(val) \
__asm__ __volatile__("rdtsc" : "=a" (val) : : "edx")
#define NUM 1000000

int main() {
	int a, b, i;
	struct timeval tv1, tv2;
	gettimeofday(&tv1, NULL);
	gettimeofday(&tv1, NULL);
	rdtsc(a);
	for (i = 0; i < NUM; i++)
		rdtsc(b);
	gettimeofday(&tv2, NULL);
	i = (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec;
	printf("%f MHz, rdtsc: %f nanoseconds, %f cycles\n",
			(double)(b - a) / i,
			(double)i * 1000 / NUM,
			(double)(b - a) / NUM);
	return 0;
}

The dual-core Core 2 CPU:
2394.053013 MHz, rdtsc: 28.012000 nanoseconds, 67.062213 cycles

A single-core Athlon 64:
2000.448523 MHz, rdtsc: 3.351000 nanoseconds, 6.703503 cycles

-- 
Miroslav Lichvar



More information about the questions mailing list