Discussion:
[chrony-users] makestep in Chrony
Hei Chan
2018-05-06 10:30:48 UTC
Permalink
Hi,
I am reading this:https://chrony.tuxfamily.org/manual.html#makestep-command
It mentions, "Normally chronyd will cause the system to gradually correct any time offset, by slowing down or speeding up the clock as required".  Most of the Linux machines are using TSC as the source:$ cat /sys/devices/system/clocksource/clocksource0/current_clocksourcetsc
Given a machine using TSC as the clock source and new Intel CPUs have invariant TSC, how can chrony slow down or speed up the clock?  I am sure I misunderstand the doc.
Thanks.

Cheers,Hei
Hei Chan
2018-05-15 01:57:30 UTC
Permalink
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony finishes synch so that I can get the best estimate when I try to derive time from (invariant) tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?

Yes to both :)

I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue the command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst', then as soon as it returns (the clock is synchronized right?), then I do something like:
s = cpuid + rdtscclock_getime(REALTIME_CLOCK, &t)e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
Then, I can use the map to estimate the TSC frequency every 2 t's with the assumption that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in nano.
You might question why I don't just have chronyd running in background and call clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main issue is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it just fails internally and loops and then take a long time to return.
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core at C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar to "chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble?  Email ***@chrony.tuxfamily.org.
Bill Unruh
2018-05-15 03:25:59 UTC
Permalink
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony finishes
synch so that I can get the best estimate when I try to derive time from (invariant)
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst', then
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the assumption
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main issue
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it just
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core at
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar to
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Hei Chan
2018-05-15 03:45:18 UTC
Permalink
Hi Bill,
Here is the source:https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L183

As you can see, clock_gettime() is in a while loop because sometimes, it might fail...
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony finishes
synch so that I can get the best estimate when I try to derive time from (invariant)
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst', then
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the assumption
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main issue
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it just
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core at
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar to
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Bill Unruh
2018-05-15 05:16:11 UTC
Permalink
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L183
As you can see, clock_gettime() is in a while loop because sometimes, it might fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?

Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from (invariant)
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst',
then
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the assumption
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it just
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core at
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Hei Chan
2018-05-15 05:57:04 UTC
Permalink
If I remember correctly that there was a post explaining why it wasn't a bug, the post mentioned the value was written to a shared memory (or some sort), and the writer and reader aren't protected by a lock for performance reason, and so it needs to spin (i.e while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely remember it was like 200 nano or more.
Tho, the comparison between the latency of rdtsc and the latency of clock_gettime() (~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so I comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L183
As you can see, clock_gettime() is in a while loop because sometimes, it might fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?

Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from (invariant)
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst',
then
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the assumption
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it just
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core at
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Bill Unruh
2018-05-15 06:58:38 UTC
Permalink
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the post
mentioned the value was written to a shared memory (or some sort), and the writer and
reader aren't protected by a lock for performance reason, and so it needs to spin (i.e
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely remember
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of clock_gettime()
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so I
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L183
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst',
then
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Hei Chan
2018-05-15 10:29:28 UTC
Permalink
Hi Bill,
I think you are indeed confused.  I want accuracy in 100s of ns range.  But again I want no jitter/extra latency in my application.
In all my measurement from point A to point B, the time span is less than 15 micro 99.9999% of the time (0.0001% for the undesired jitter).  And the measurement is taken probably 1.5 billion times (or more a day) in multiple cores (~10?).  As you can see timestamping happens very frequent in my system.  Hence, that's why I have a weird thought of using rdtsc-clock_gettime() map.
I have to admit that I don't know how to use the chrony/ntp's parameters very well.  What parameters would you recommend with a NTP source that is one hop a way within the same data center?
So what would you suggest me to use to synchronize in a datacenter that PTP isn't available and GPS clock isn't allowed?
And indeed I have thought about a better solution for quiet some time because of the conditions above and temperature effect on TSC.  But I can't think of a way to measure from A to B without jitter and latency, and at the same time, I would like to know the approximate epoch time of each "timestamping".  (again no jitter/latency is more important than accuracy of the epoch time.).
If you have a good suggestion, i am all ears.
Thanks!
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the post
mentioned the value was written to a shared memory (or some sort), and the writer and
reader aren't protected by a lock for performance reason, and so it needs to spin (i.e
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely remember
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of clock_gettime()
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so I
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L183
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to issue
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst',
then
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time in
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated core
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one) similar
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Bill Unruh
2018-05-15 15:01:34 UTC
Permalink
Hi Bill,
I think you are indeed confused.  I want accuracy in 100s of ns range.  But again I
want no jitter/extra latency in my application.
That is really tough. And you are operating with your hands tied behind your
back.
In all my measurement from point A to point B, the time span is less than 15 micro
99.9999% of the time (0.0001% for the undesired jitter).  And the measurement is taken
probably 1.5 billion times (or more a day) in multiple cores (~10?).  As you can see
timestamping happens very frequent in my system.  Hence, that's why I have a weird
thought of using rdtsc-clock_gettime() map.
Sure. The designers of the Linux clock had the same idea.
I have to admit that I don't know how to use the chrony/ntp's parameters very well. 
What parameters would you recommend with a NTP source that is one hop a way within the
same data center?
And how is that ntp source disciplined? How do you know that the time
delivered by that source has any accuracy whatsoever. And added to that, there
are the transmission problems. The hubs and routers between your machine and
that ntp source introduce jitter and delays. Contention for the ethernet
introduces jitter. The interrupt handling in your computer introduces jitter.
The abysmally slow network (even gigabit cable takes microseconds to send a
packet down the line, and then there is teh behaviour of the ethernet cards
which will amass data and only send it when enough has accumulated and it
feels like sending something. If you want accurate times you HAVE to have
something like gps/pps and to get tens of nanosecond precision, you need to have a
pretty sophisticated one.
So what would you suggest me to use to synchronize in a datacenter that PTP isn't
available and GPS clock isn't allowed?
Here is one of the worl'd foremost watches. Now I want to repair it, but you
must wear boxing gloved while doing so, and you are not allowed to remove them
for any reason.
And indeed I have thought about a better solution for quiet some time because of the
conditions above and temperature effect on TSC.  But I can't think of a way to measure
from A to B without jitter and latency, and at the same time, I would like to know the
approximate epoch time of each "timestamping".  (again no jitter/latency is more
approximate? century? year? day, second, millisecond, microsecond nanosecond?
important than accuracy of the epoch time.).
But make sure you never remove those gloves.
If you have a good suggestion, i am all ears.
And at a budget of $50? How much are you willing to spend?
Thanks!
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the
post
Post by Hei Chan
mentioned the value was written to a shared memory (or some sort), and the writer and
reader aren't protected by a lock for performance reason, and so it needs to spin
(i.e
Post by Hei Chan
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely
remember
Post by Hei Chan
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of clock_gettime()
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so I
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L18
3
Post by Hei Chan
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to
issue
Post by Hei Chan
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst',
then
Post by Hei Chan
as soon as it returns (the clock is synchronized right?), then I do something
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time
in
Post by Hei Chan
Post by Hei Chan
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated
core
Post by Hei Chan
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one)
similar
Post by Hei Chan
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Hei Chan
2018-05-16 02:00:44 UTC
Permalink
Hi Bill,
Let's say I am willing to spend 1K-2K USD for any hardware that can give accurate time (in millisecond without drifting) and that hardware can be installed in a 1U server, then I think it could be a good solution.  Any tip?  Anything installed outside the server isn't allowed.
Hi Bill,
I think you are indeed confused.  I want accuracy in 100s of ns range.  But again I
want no jitter/extra latency in my application.
That is really tough. And you are operating with your hands tied behind your
back.
In all my measurement from point A to point B, the time span is less than 15 micro
99.9999% of the time (0.0001% for the undesired jitter).  And the measurement is taken
probably 1.5 billion times (or more a day) in multiple cores (~10?).  As you can see
timestamping happens very frequent in my system.  Hence, that's why I have a weird
thought of using rdtsc-clock_gettime() map.
Sure. The designers of the Linux clock had the same idea.
I have to admit that I don't know how to use the chrony/ntp's parameters very well. 
What parameters would you recommend with a NTP source that is one hop a way within the
same data center?
And how is that ntp source disciplined? How do you know that the time
delivered by that source has any accuracy whatsoever. And added to that, there
are the transmission problems. The hubs and routers between your machine and
that ntp source introduce jitter and delays. Contention for the ethernet
introduces jitter. The interrupt handling in your computer introduces jitter.
The abysmally slow network (even gigabit cable takes microseconds to send a
packet down the line, and then there is teh behaviour of the ethernet cards
which will amass data and only send it when enough has accumulated and it
feels like sending something. If you want accurate times you HAVE to have
something like gps/pps and to get tens of nanosecond precision, you need to have a
pretty sophisticated one.
So what would you suggest me to use to synchronize in a datacenter that PTP isn't
available and GPS clock isn't allowed?
Here is one of the worl'd foremost watches. Now I want to repair it, but you
must wear boxing gloved while doing so, and you are not allowed to remove them
for any reason.
And indeed I have thought about a better solution for quiet some time because of the
conditions above and temperature effect on TSC.  But I can't think of a way to measure
from A to B without jitter and latency, and at the same time, I would like to know the
approximate epoch time of each "timestamping".  (again no jitter/latency is more
approximate? century? year? day, second, millisecond, microsecond nanosecond?
important than accuracy of the epoch time.).
But make sure you never remove those gloves.
If you have a good suggestion, i am all ears.
And at a budget of $50? How much are you willing to spend?
Thanks!
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the
post
Post by Hei Chan
mentioned the value was written to a shared memory (or some sort), and the writer and
reader aren't protected by a lock for performance reason, and so it needs to spin
(i.e
Post by Hei Chan
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely
remember
Post by Hei Chan
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of clock_gettime()
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so I
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L18
3
Post by Hei Chan
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to
issue
Post by Hei Chan
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst',
then
Post by Hei Chan
as soon as it returns (the clock is synchronized right?), then I do something
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time
in
Post by Hei Chan
Post by Hei Chan
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The main
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes, it
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated
core
Post by Hei Chan
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one)
similar
Post by Hei Chan
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Hei Chan
2018-05-16 02:46:41 UTC
Permalink
Wow, that's pretty amazing.  I probably will buy one to play around given such low cost.  I just looked up online...40$ shipping included.
But then I think I can't use it in the data center as I don't think it can receive the GPS signal.

On Wednesday, May 16, 2018, 10:27:34 AM GMT+8, Bill Unruh <***@physics.ubc.ca> wrote:

I use a cheap GPS/PPS card (Sure electronics. Cost $50). which keeps my machine in the sub-usec range.
(On chrony, here is the output of the tracking
Reference ID    : 50505330 (PPS0)
Stratum        : 1
Ref time (UTC)  : Wed May 16 02:15:54 2018
System time    : 0.000000001 seconds fast of NTP time
Last offset    : -0.000000042 seconds
RMS offset      : 0.000000167 seconds
Frequency      : 4.447 ppm fast
Residual freq  : -0.000 ppm
Skew            : 0.002 ppm
Root delay      : 0.000000001 seconds
Root dispersion : 0.000015283 seconds
Update interval : 16.0 seconds
Leap status    : Normal


and the PPS sources line

#* PPS0                          0  4  377    23  -348ns[ -375ns] +/- 334ns

I do not have experience with the atomic clocks available.

I know they exist.
One step would be to put in an over controled crystal into your machine. That
would bring the tsc drift down substantially. One could even use the thermal
compensation that I think exists in chrony. I have not used it so have no
advice on setting it up.
(It uses one of the motherboard thermometers as a proxy for the crystal
temperature, and fits to the drift as a function of temperature assuming a
linear relationship.






William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
UBC, Vancouver,BC _|_ Program in Cosmology |____ ***@physics.ubc.ca
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Hi Bill,
Let's say I am willing to spend 1K-2K USD for any hardware that can give accurate time
(in millisecond without drifting) and that hardware can be installed in a 1U server,
then I think it could be a good solution.  Any tip?  Anything installed outside the
server isn't allowed.
Hi Bill,
I think you are indeed confused.  I want accuracy in 100s of ns range.  But again I
want no jitter/extra latency in my application.
That is really tough. And you are operating with your hands tied behind your
back.
In all my measurement from point A to point B, the time span is less than 15 micro
99.9999% of the time (0.0001% for the undesired jitter).  And the measurement is
taken
probably 1.5 billion times (or more a day) in multiple cores (~10?).  As you can see
timestamping happens very frequent in my system.  Hence, that's why I have a weird
thought of using rdtsc-clock_gettime() map.
Sure. The designers of the Linux clock had the same idea.
I have to admit that I don't know how to use the chrony/ntp's parameters very well. 
What parameters would you recommend with a NTP source that is one hop a way within
the
same data center?
And how is that ntp source disciplined? How do you know that the time
delivered by that source has any accuracy whatsoever. And added to that, there
are the transmission problems. The hubs and routers between your machine and
that ntp source introduce jitter and delays. Contention for the ethernet
introduces jitter. The interrupt handling in your computer introduces jitter.
The abysmally slow network (even gigabit cable takes microseconds to send a
packet down the line, and then there is teh behaviour of the ethernet cards
which will amass data and only send it when enough has accumulated and it
feels like sending something. If you want accurate times you HAVE to have
something like gps/pps and to get tens of nanosecond precision, you need to have a
pretty sophisticated one.
So what would you suggest me to use to synchronize in a datacenter that PTP isn't
available and GPS clock isn't allowed?
Here is one of the worl'd foremost watches. Now I want to repair it, but you
must wear boxing gloved while doing so, and you are not allowed to remove them
for any reason.
And indeed I have thought about a better solution for quiet some time because of the
conditions above and temperature effect on TSC.  But I can't think of a way to
measure
from A to B without jitter and latency, and at the same time, I would like to know
the
approximate epoch time of each "timestamping".  (again no jitter/latency is more
approximate? century? year? day, second, millisecond, microsecond nanosecond?
important than accuracy of the epoch time.).
But make sure you never remove those gloves.
If you have a good suggestion, i am all ears.
And at a budget of $50? How much are you willing to spend?
Thanks!
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the
post
Post by Hei Chan
mentioned the value was written to a shared memory (or some sort), and the writer
and
Post by Hei Chan
reader aren't protected by a lock for performance reason, and so it needs to spin
(i.e
Post by Hei Chan
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely
remember
Post by Hei Chan
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of clock_gettime()
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so I
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L1
8
3
Post by Hei Chan
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
On Friday, May 11, 2018, 4:26:14 PM GMT+8, Miroslav Lichvar
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as chrony
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to
issue
Post by Hei Chan
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away]
iburst',
Post by Hei Chan
then
Post by Hei Chan
as soon as it returns (the clock is synchronized right?), then I do something
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch time
in
Post by Hei Chan
Post by Hei Chan
nano.
You might question why I don't just have chronyd running in background and call
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The
main
Post by Hei Chan
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes,
it
Post by Hei Chan
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated
core
Post by Hei Chan
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one)
similar
Post by Hei Chan
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Bill Unruh
2018-05-16 06:24:09 UTC
Permalink
Actually I was looking at it seems Sure no longer makes that gps board, or at
least I cannot find it using google or ebay.
Not sure what the best gps card is now.



William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
UBC, Vancouver,BC _|_ Program in Cosmology |____ ***@physics.ubc.ca
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Post by Hei Chan
Wow, that's pretty amazing.  I probably will buy one to play around given such low
cost.  I just looked up online...40$ shipping included.
But then I think I can't use it in the data center as I don't think it can receive the
GPS signal.
I use a cheap GPS/PPS card (Sure electronics. Cost $50). which keeps my machine in the
sub-usec range.
(On chrony, here is the output of the tracking
Reference ID    : 50505330 (PPS0)
Stratum        : 1
Ref time (UTC)  : Wed May 16 02:15:54 2018
System time    : 0.000000001 seconds fast of NTP time
Last offset    : -0.000000042 seconds
RMS offset      : 0.000000167 seconds
Frequency      : 4.447 ppm fast
Residual freq  : -0.000 ppm
Skew            : 0.002 ppm
Root delay      : 0.000000001 seconds
Root dispersion : 0.000015283 seconds
Update interval : 16.0 seconds
Leap status    : Normal
and the PPS sources line
#* PPS0                          0  4  377    23  -348ns[ -375ns] +/- 334ns
I do not have experience with the atomic clocks available.
I know they exist.
One step would be to put in an over controled crystal into your machine. That
would bring the tsc drift down substantially. One could even use the thermal
compensation that I think exists in chrony. I have not used it so have no
advice on setting it up.
(It uses one of the motherboard thermometers as a proxy for the crystal
temperature, and fits to the drift as a function of temperature assuming a
linear relationship.
William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Hi Bill,
Let's say I am willing to spend 1K-2K USD for any hardware that can give accurate
time
(in millisecond without drifting) and that hardware can be installed in a 1U server,
then I think it could be a good solution.  Any tip?  Anything installed outside the
server isn't allowed.
Hi Bill,
I think you are indeed confused.  I want accuracy in 100s of ns range.  But again I
want no jitter/extra latency in my application.
That is really tough. And you are operating with your hands tied behind your
back.
In all my measurement from point A to point B, the time span is less than 15 micro
99.9999% of the time (0.0001% for the undesired jitter).  And the measurement is
taken
probably 1.5 billion times (or more a day) in multiple cores (~10?).  As you can
see
timestamping happens very frequent in my system.  Hence, that's why I have a weird
thought of using rdtsc-clock_gettime() map.
Sure. The designers of the Linux clock had the same idea.
I have to admit that I don't know how to use the chrony/ntp's parameters very
well. 
What parameters would you recommend with a NTP source that is one hop a way within
the
same data center?
And how is that ntp source disciplined? How do you know that the time
delivered by that source has any accuracy whatsoever. And added to that, there
are the transmission problems. The hubs and routers between your machine and
that ntp source introduce jitter and delays. Contention for the ethernet
introduces jitter. The interrupt handling in your computer introduces jitter.
The abysmally slow network (even gigabit cable takes microseconds to send a
packet down the line, and then there is teh behaviour of the ethernet cards
which will amass data and only send it when enough has accumulated and it
feels like sending something. If you want accurate times you HAVE to have
something like gps/pps and to get tens of nanosecond precision, you need to have a
pretty sophisticated one.
So what would you suggest me to use to synchronize in a datacenter that PTP isn't
available and GPS clock isn't allowed?
Here is one of the worl'd foremost watches. Now I want to repair it, but you
must wear boxing gloved while doing so, and you are not allowed to remove them
for any reason.
And indeed I have thought about a better solution for quiet some time because of
the
conditions above and temperature effect on TSC.  But I can't think of a way to
measure
from A to B without jitter and latency, and at the same time, I would like to know
the
approximate epoch time of each "timestamping".  (again no jitter/latency is more
approximate? century? year? day, second, millisecond, microsecond nanosecond?
important than accuracy of the epoch time.).
But make sure you never remove those gloves.
If you have a good suggestion, i am all ears.
And at a budget of $50? How much are you willing to spend?
Thanks!
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the
post
Post by Hei Chan
mentioned the value was written to a shared memory (or some sort), and the writer
and
Post by Hei Chan
reader aren't protected by a lock for performance reason, and so it needs to spin
(i.e
Post by Hei Chan
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely
remember
Post by Hei Chan
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of
clock_gettime()
Post by Hei Chan
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so
I
Post by Hei Chan
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L
1
8
3
Post by Hei Chan
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
On Friday, May 11, 2018, 4:26:14 PM GMT+8, Miroslav Lichvar
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as
chrony
Post by Hei Chan
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to
issue
Post by Hei Chan
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away]
iburst',
Post by Hei Chan
then
Post by Hei Chan
as soon as it returns (the clock is synchronized right?), then I do something
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch
time
in
Post by Hei Chan
Post by Hei Chan
nano.
You might question why I don't just have chronyd running in background and
call
Post by Hei Chan
Post by Hei Chan
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The
main
Post by Hei Chan
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes,
it
Post by Hei Chan
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated
core
Post by Hei Chan
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one)
similar
Post by Hei Chan
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Burton, John
2018-05-16 13:27:49 UTC
Permalink
This post might be inappropriate. Click to display it.
Bill Unruh
2018-05-16 04:52:16 UTC
Permalink
William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
UBC, Vancouver,BC _|_ Program in Cosmology |____ ***@physics.ubc.ca
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Post by Hei Chan
Wow, that's pretty amazing.  I probably will buy one to play around given such low
cost.  I just looked up online...40$ shipping included.
But then I think I can't use it in the data center as I don't think it can receive the
GPS signal.
You do need a window or something like that to put the antenna in. but you can
run a pretty long cable (speed of light is a foot per nanosecond, slightly
less in a cable. ) So you can put the receiver and antenna somewhere where
they can see the sky, and then run even say cat 5 cable from there to the
computer. wire it up so that you use the usb power on the computer to drive
the receiver, and two of the other lines for the serial port, or even usb port
and the fifth line for the PPS.

Unforunately the PPS has, as it comes, no line already ready to deliver pps to
the computer, so you need to solder a line across the board to the serial port
interrupt line. You can estimate the transmission time along the wire by
something like .2m/ns, and tell chrony to subtract that time from the receipt
time of the pulse.
Post by Hei Chan
I use a cheap GPS/PPS card (Sure electronics. Cost $50). which keeps my machine in the
sub-usec range.
(On chrony, here is the output of the tracking
Reference ID    : 50505330 (PPS0)
Stratum        : 1
Ref time (UTC)  : Wed May 16 02:15:54 2018
System time    : 0.000000001 seconds fast of NTP time
Last offset    : -0.000000042 seconds
RMS offset      : 0.000000167 seconds
Frequency      : 4.447 ppm fast
Residual freq  : -0.000 ppm
Skew            : 0.002 ppm
Root delay      : 0.000000001 seconds
Root dispersion : 0.000015283 seconds
Update interval : 16.0 seconds
Leap status    : Normal
and the PPS sources line
#* PPS0                          0  4  377    23  -348ns[ -375ns] +/- 334ns
I do not have experience with the atomic clocks available.
I know they exist.
One step would be to put in an over controled crystal into your machine. That
would bring the tsc drift down substantially. One could even use the thermal
compensation that I think exists in chrony. I have not used it so have no
advice on setting it up.
(It uses one of the motherboard thermometers as a proxy for the crystal
temperature, and fits to the drift as a function of temperature assuming a
linear relationship.
William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Hi Bill,
Let's say I am willing to spend 1K-2K USD for any hardware that can give accurate
time
(in millisecond without drifting) and that hardware can be installed in a 1U server,
then I think it could be a good solution.  Any tip?  Anything installed outside the
server isn't allowed.
Hi Bill,
I think you are indeed confused.  I want accuracy in 100s of ns range.  But again I
want no jitter/extra latency in my application.
That is really tough. And you are operating with your hands tied behind your
back.
In all my measurement from point A to point B, the time span is less than 15 micro
99.9999% of the time (0.0001% for the undesired jitter).  And the measurement is
taken
probably 1.5 billion times (or more a day) in multiple cores (~10?).  As you can
see
timestamping happens very frequent in my system.  Hence, that's why I have a weird
thought of using rdtsc-clock_gettime() map.
Sure. The designers of the Linux clock had the same idea.
I have to admit that I don't know how to use the chrony/ntp's parameters very
well. 
What parameters would you recommend with a NTP source that is one hop a way within
the
same data center?
And how is that ntp source disciplined? How do you know that the time
delivered by that source has any accuracy whatsoever. And added to that, there
are the transmission problems. The hubs and routers between your machine and
that ntp source introduce jitter and delays. Contention for the ethernet
introduces jitter. The interrupt handling in your computer introduces jitter.
The abysmally slow network (even gigabit cable takes microseconds to send a
packet down the line, and then there is teh behaviour of the ethernet cards
which will amass data and only send it when enough has accumulated and it
feels like sending something. If you want accurate times you HAVE to have
something like gps/pps and to get tens of nanosecond precision, you need to have a
pretty sophisticated one.
So what would you suggest me to use to synchronize in a datacenter that PTP isn't
available and GPS clock isn't allowed?
Here is one of the worl'd foremost watches. Now I want to repair it, but you
must wear boxing gloved while doing so, and you are not allowed to remove them
for any reason.
And indeed I have thought about a better solution for quiet some time because of
the
conditions above and temperature effect on TSC.  But I can't think of a way to
measure
from A to B without jitter and latency, and at the same time, I would like to know
the
approximate epoch time of each "timestamping".  (again no jitter/latency is more
approximate? century? year? day, second, millisecond, microsecond nanosecond?
important than accuracy of the epoch time.).
But make sure you never remove those gloves.
If you have a good suggestion, i am all ears.
And at a budget of $50? How much are you willing to spend?
Thanks!
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the
post
Post by Hei Chan
mentioned the value was written to a shared memory (or some sort), and the writer
and
Post by Hei Chan
reader aren't protected by a lock for performance reason, and so it needs to spin
(i.e
Post by Hei Chan
while loop) to get the value out as soon as the writer finishes.
I don't have an exact percentage of occurrence nor the exact delay.  I vaguely
remember
Post by Hei Chan
it was like 200 nano or more.
I must say I am confused. You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in the
hundreds of usec range (on a good day). Or even a local server, which will
give you something like 10s of usec accuracy. There is a disconnect here.
If you really want ns accuracy you will have to use a refclock directly
connected to the machine. Even GPS has problems as it is only after the fact
that you can figure out the sawtooth time error on a really good gps timing
receiver and compensate for it.
Never mind the temperature changes which make the tsc wander away from its
rate. It is really unclear to me what you are trying to do, and why?
Post by Hei Chan
Tho, the comparison between the latency of rdtsc and the latency of
clock_gettime()
Post by Hei Chan
(~20 nano vs ~50 nano) is widely available online.
As I mentioned that jitter/latency is more important than accuracy in my case, so
I
Post by Hei Chan
comprised accuracy a bit (with complexity).
Hi Bill,
https://elixir.bootlin.com/linux/v4.9/source/arch/x86/entry/vdso/vclock_gettime.c#L
1
8
3
Post by Hei Chan
As you can see, clock_gettime() is in a while loop because sometimes, it might
fail...
Hm, yes. How much of a time delay do you get occassionally due to the while
loop?
Again that failure sounds like a bug.
Post by Hei Chan
Thanks for your reply.
See my comment inline.
On Friday, May 11, 2018, 4:26:14 PM GMT+8, Miroslav Lichvar
  Hi Bill,
Sorry that I wasn't clear.
What I tried to do is to call clock_gettime() and rdtsc(p) as soon as
chrony
Post by Hei Chan
finishes
Post by Hei Chan
synch so that I can get the best estimate when I try to derive time from
(invariant)
Post by Hei Chan
tsc.
Ok, so the assumption here is that once the system clock is
"synchronized" by chronyd there will be a linear function between the
tsc and system time? And the goal is to have a clock that can be read
in constant time and it doesn't have to be very accurate, but still
track the real time?
Yes to both :)
I'm not sure if that's possible. The tsc is the direct source for the
CLOCK_MONOTONIC_RAW clock. Its frequency doesn't change with chronyd's
adjustments, i.e. it's sensitive to temperature changes etc. The
constants of the linear function would have to be periodically updated
and then you would need to deal with locking, which would increase the
maximum latency in the reading of the clock.
Here is the design I am thinking.
I don't have chronyd run in backgroud, and periodically (through cronjob) to
issue
Post by Hei Chan
the
That is a terrible way of usign chrony. One of the key features of both chrony
and ntpd is that it disciplines not only the offset but also the the rate of
the clock. And the rate can only be determine over a (lengthy ) time period.
Why would you run it like this?
Post by Hei Chan
command chronyd -q 'pool [some NTP server/switch which is 1 switch away]
iburst',
Post by Hei Chan
then
Post by Hei Chan
as soon as it returns (the clock is synchronized right?), then I do something
No. See above.
Post by Hei Chan
s = cpuid + rdtsc
clock_getime(REALTIME_CLOCK, &t)
e = rdtscp + cpuid
Then, log it.
So after 24 hours, I have a map for rdtsc<->absolute epoch time in nano.
You have a very sophisticated program whose whole purpose is to continuously
set the translation between the tsc and the UTC. And you throw it all away and
use it in the way that Unix time was disciplined 40 years ago.
Post by Hei Chan
Then, I can use the map to estimate the TSC frequency every 2 t's with the
assumption
Post by Hei Chan
that t is correct and TSC will change between two t's.
Then, for everything I track with rdtsc, I can estimate the absolute epoch
time
in
Post by Hei Chan
Post by Hei Chan
nano.
You might question why I don't just have chronyd running in background and
call
Post by Hei Chan
Post by Hei Chan
clock_gettime(CLOCK_REATIME, &t) for all the stamping I do with rdtsc.  The
main
Post by Hei Chan
issue
Post by Hei Chan
is that clock_gettime(CLOCK_REALTIME) is great 99% of the time but sometimes,
it
Post by Hei Chan
just
Post by Hei Chan
fails internally and loops and then take a long time to return.
No idea what this is all about. I have never seen this. If it truely does
this, that is bug, and needs to be reported.
Post by Hei Chan
Any issue you see?
P.S.  calling chronyd and creating the map file will be done by one dedicated
core
Post by Hei Chan
at
Post by Hei Chan
C0 (i.e. off OS scheduler to improve accuracy)
Ideally, I have a C application that calls chrony's API (if there is one)
similar
Post by Hei Chan
to
Post by Hei Chan
"chronyd -q" to block till it finishes or gets a callback.
Any suggestion?
There is no C API for chrony (yet). Instead, you could use adjtimex()
and check the frequency and maxerror fields. The maxerror value
increases slowly and drops only when chronyd updates the clock. When
it drops below a threshold and the frequency didn't change
significantly, the system clock could be considered to be
synchronized.
--
Miroslav Lichvar
Stephen Satchell
2018-05-15 12:39:18 UTC
Permalink
Post by Bill Unruh
You are wanting accuracy in the 10s of ns range, but you
are using pool servers to set you clock, which will give you accuracy in
the hundreds of usec range (on a good day).
I continue to be puzzled as to why he needs such tight synchronization.
Perhaps if he could explain his application more thoroughly, we could
understand, and make suggestions. Frankly, I'd say that chrony (and
NTP) is not the right tool, based on the little we've been told.
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Miroslav Lichvar
2018-05-15 07:38:37 UTC
Permalink
Post by Hei Chan
If I remember correctly that there was a post explaining why it wasn't a bug, the post mentioned the value was written to a shared memory (or some sort), and the writer and reader aren't protected by a lock for performance reason, and so it needs to spin (i.e while loop) to get the value out as soon as the writer finishes.
How do you avoid this issue in your solution? If you update the
estimated frequency offset between real time and tsc, you will need to
prevent the conversion from using partially updated values. If you
don't update the offset at all (estimated only once on start), the
tsc-based clock will drift away.
--
Miroslav Lichvar
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Hei Chan
2018-05-15 11:23:07 UTC
Permalink
Since the application calling rdtsc+clock_gettime()+rdtsc (to create the mapping file) has its own dedicated core, and this application is only called after "chronyd -q 'pool [some NTP server/switch which is 1 switch away] iburst'" returns, at that time, I believe the clock is synchronized (right?).  Then, it is very rare to have other processes to update the clock.
And let's say it happens occasionally, I can just drop those mappings in the file, and continue my estimation with the mappings before and after.
  If I remember correctly that there was a post explaining why it wasn't a bug, the post mentioned the value was written to a shared memory (or some sort), and the writer and reader aren't protected by a lock for performance reason, and so it needs to spin (i.e while loop) to get the value out as soon as the writer finishes.
How do you avoid this issue in your solution? If you update the
estimated frequency offset between real time and tsc, you will need to
prevent the conversion from using partially updated values. If you
don't update the offset at all (estimated only once on start), the
tsc-based clock will drift away.
--
Miroslav Lichvar
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble?  Email ***@chrony.tuxfamily.org.
Stephen Satchell
2018-05-15 12:53:25 UTC
Permalink
Post by Hei Chan
Since the application calling rdtsc+clock_gettime()+rdtsc (to create
the mapping file) has its own dedicated core, and this application is
only called after "chronyd -q 'pool [some NTP server/switch which is
1 switch away] iburst'" returns, at that time, I believe the clock is
synchronized (right?). Then, it is very rare to have other processes
to update the clock.
Synchronized, but not regulated. Let me give you an example: in my
admin desktop system, chronyc reports that the frequency of the computer
clock is 12.373 ppm slow. So that means that the real-time clock will
lose time after being synchronized but not regulated. Chrony will turn
those knobs to compensate for the difference.

There are knobs in most operating systems's time software to compensate
for the inaccuracies, so that long-term accuracy of the real-time clock
is improved. Because the crystals will wander over temperature, one
would need to periodically re-synchronize, and perhaps tweak the RTC
clock regulation. That's what chrony (and NTP) do.

Both NTP and chrony assume that the base clock has an absolute accurate
of 100 ppm or better, and a relative accuracy of 5 ppm or better.
Virtually all modern computers (including cell phones) have crystals
that meet this specification.

Now, in a VM object, the base clock used for timekeeping is almost
worthless because the error and jitter fall outside of those boundaries.
That's why I scream and yell every time one of my clients installs NTP
into a virtual machine and calls it good. You are almost guaranteed to
have a false ticker. I could tell you stories...

Are you trying to do astronomical observations? If so, use the search
engine of your choice to find research papers on this subject.
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Alexander Bisogiannis
2018-05-15 12:56:38 UTC
Permalink
Post by Stephen Satchell
Now, in a VM object, the base clock used for timekeeping is almost
worthless because the error and jitter fall outside of those
boundaries. That's why I scream and yell every time one of my
clients installs NTP into a virtual machine and calls it good. You
are almost guaranteed to have a false ticker. I could tell you
stories...
Do you mean people are using VMs for chrony (ntp) servers or clients?
Stephen Satchell
2018-05-15 13:21:57 UTC
Permalink
Post by Alexander Bisogiannis
Post by Stephen Satchell
Now, in a VM object, the base clock used for timekeeping is almost
worthless because the error and jitter fall outside of those
boundaries.  That's why I scream and yell every time one of my clients
installs NTP into a virtual machine and calls it good.  You are almost
guaranteed to have a false ticker.  I could tell you stories...
Do you mean people are using VMs for chrony (ntp) servers or clients?
Yes.

"Go sail away, go sail away, go sail away with ticks..."
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Bill Unruh
2018-05-15 15:05:11 UTC
Permalink
William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
UBC, Vancouver,BC _|_ Program in Cosmology |____ ***@physics.ubc.ca
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Post by Stephen Satchell
Now, in a VM object, the base clock used for timekeeping is almost
worthless because the error and jitter fall outside of those boundaries.
That's why I scream and yell every time one of my clients installs NTP into
a virtual machine and calls it good. You are almost guaranteed to have a
false ticker. I could tell you stories...
Do you mean people are using VMs for chrony (ntp) servers or clients?
Probably both.
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Miroslav Lichvar
2018-05-15 13:08:09 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...