Re: [chrony-dev] [PATCH] MacOS X - add drift removal

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Graph at http://whatroute.net/chrony/chrony-predict-error-20150812.png

Purple: frequency ppm
Green: offset_sd
Red: RMS offset
Magenta: mean (weighted) offset
Orange: mean (weighted) System time

Single lan connected stratum 1 NTP server

Predicted error patch
Dynamic drift_removal_interval (0.1 secs throughout test . i.e. minimum)

I think this result is pretty good - better then 1usec mean 'System time' most of the time.

> On 11/08/2015, at 10:59 pm, Miroslav Lichvar <mlichvar@xxxxxxxxxx> wrote:
> 
> On Thu, Aug 06, 2015 at 04:57:43AM +1200, Bryan Christianson wrote:
>>> @@ -119,7 +119,7 @@ start_adjust(void)
>>> }
>>> 
>>> UTI_DiffTimevalsToDouble(&elapsed, &T1, &T0);
>>> -  accrued_error = elapsed * current_freq;
>>> +  accrued_error = (elapsed + DRIFT_REMOVAL_INTERVAL / 2.0) * current_freq;
>>> 
>>> adjust_required = - (accrued_error + offset_register);
>> 
>> This changes the effective drift (as seen in tracking.log) from 18ppm to 6ppm but System time still hovers around -10us 
> 
> If it changes the reported drift, it doesn't work as intended :). The
> problem probably is that the the precorrection is not included in the
> offset register and when the adjustment is stopped, the register will
> be off by that value.
> 
> How about this?
> 
> --- a/sys_macosx.c
> +++ b/sys_macosx.c
> @@ -108,7 +108,7 @@ start_adjust(void)
> { 
>   struct timeval newadj, oldadj;
>   struct timeval T1;
> -  double elapsed, accrued_error;
> +  double elapsed, accrued_error, expected_error;
>   double adjust_required;
>   double rounding_error;
>   double old_adjust_remaining;
> @@ -120,8 +120,9 @@ start_adjust(void)
> 
>   UTI_DiffTimevalsToDouble(&elapsed, &T1, &T0);
>   accrued_error = elapsed * current_freq;
> +  expected_error = DRIFT_REMOVAL_INTERVAL / 2.0 * current_freq;
> 
> -  adjust_required = - (accrued_error + offset_register);
> +  adjust_required = - (accrued_error + offset_register + expected_error);
> 
>   UTI_DoubleToTimeval(adjust_required, &newadj);
>   UTI_TimevalToDouble(&newadj, &adjustment_requested);
> @@ -133,7 +134,7 @@ start_adjust(void)
> 
>   UTI_TimevalToDouble(&oldadj, &old_adjust_remaining);
> 
> -  offset_register = rounding_error - old_adjust_remaining;
> +  offset_register = rounding_error - old_adjust_remaining - expected_error;
> 
>   T0 = T1;
> }
> 
> -- 
> Miroslav Lichvar
> 
> -- 
> To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
> For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
> Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.
> 


--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/