[Ntp] Antw: Re: Antw: [EXT] Minutes from IETF 108 NTP WG session

Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> Mon, 03 August 2020 11:01 UTC

Return-Path: <Ulrich.Windl@rz.uni-regensburg.de>
X-Original-To: ntp@ietfa.amsl.com
Delivered-To: ntp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C14763A0E12 for <ntp@ietfa.amsl.com>; Mon, 3 Aug 2020 04:01:08 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0
X-Spam-Level:
X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LMq3QyupGfud for <ntp@ietfa.amsl.com>; Mon, 3 Aug 2020 04:01:07 -0700 (PDT)
Received: from mx3.uni-regensburg.de (mx3.uni-regensburg.de [IPv6:2001:638:a05:137:165:0:4:4e79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E29B73A0C95 for <ntp@ietf.org>; Mon, 3 Aug 2020 04:01:06 -0700 (PDT)
Received: from mx3.uni-regensburg.de (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id A1D55600005E for <ntp@ietf.org>; Mon, 3 Aug 2020 13:01:03 +0200 (CEST)
Received: from gwsmtp.uni-regensburg.de (gwsmtp1.uni-regensburg.de [132.199.5.51]) by mx3.uni-regensburg.de (Postfix) with ESMTP id 7851C6000052 for <ntp@ietf.org>; Mon, 3 Aug 2020 13:01:03 +0200 (CEST)
Received: from uni-regensburg-smtp1-MTA by gwsmtp.uni-regensburg.de with Novell_GroupWise; Mon, 03 Aug 2020 13:01:03 +0200
Message-Id: <5F27EE6E020000A10003A657@gwsmtp.uni-regensburg.de>
X-Mailer: Novell GroupWise Internet Agent 18.2.1
Date: Mon, 03 Aug 2020 13:01:02 +0200
From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
To: "ntp@ietf.org" <ntp@ietf.org>, mlichvar@redhat.com
References: <16876866-D4DB-4941-A533-B92BCFFF60F3@gmail.com> <5F27ABE4020000A10003A63F@gwsmtp.uni-regensburg.de> <20200803103618.GK762467@localhost>
In-Reply-To: <20200803103618.GK762467@localhost>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/Biz_K0FiV7_LVQyVwa2DtZQ8SeU>
Subject: [Ntp] Antw: Re: Antw: [EXT] Minutes from IETF 108 NTP WG session
X-BeenThere: ntp@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <ntp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ntp>, <mailto:ntp-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ntp/>
List-Post: <mailto:ntp@ietf.org>
List-Help: <mailto:ntp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ntp>, <mailto:ntp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 03 Aug 2020 11:01:09 -0000

>>> Miroslav Lichvar <mlichvar@redhat.com> schrieb am 03.08.2020 um 12:36 in
Nachricht <20200803103618.GK762467@localhost>:
> On Mon, Aug 03, 2020 at 08:17:08AM +0200, Ulrich Windl wrote:
>> "It turns out that for trades a nanosecond resolution matters."
>> 
>> I wonder what's really behind that claim: Reading the current system time
on 
> a
>> current Linux server yields in about 1µs precision (independent from how 
> the
>> clock is synchronized).
> 
> On modern computers running Linux, at least for the last decade, the
> time it takes to read the system clock is usually less than 50
> nanoseconds. I have not seen a sub‑10ns clock yet. That's still an

Hi!

I'm surprised.

I wrote an algorithm like this to "measure":

typedef struct timespec ts_t;           /* short-cut for struct timespec */
static  long    get_res(ts_t *tsp)
{
        int             result;
        ts_t            samples[CLOCK_SAMPLES];
        unsigned        u;

        if ( (result = clock_getres(CLOCK_MONOTONIC, tsp)) != 0 )
                goto leave;
        assert(tsp->tv_sec == 0);
        for ( u = 0; u < CLOCK_SAMPLES; ++u )
        {
                get_time(samples + u);
        }
        for ( u = 1; u < CLOCK_SAMPLES; ++u )
        {
                samples[u - 1] = subtract_time(&samples[u], &samples[u - 1]);
        }
        qsort(samples, CLOCK_SAMPLES - 1, sizeof(samples[0]), cmp_time);
        if ( samples[0].tv_nsec > tsp->tv_nsec )
                tsp->tv_nsec = samples[0].tv_nsec;
leave:  return(result);
}

On one machine I got these debugging messages:
(D)get_res: resolution is 0.000000001 ## from POSIX call
(D)get_res: smallest delta is 0.000001514
(D)get_res: largest delta is 0.000001695
(I)set_resolution: ts 0.000001514, digits 6, nsecs 1000

So your machines must be way faster... OK, I tried the latest generation we
have:
(D)get_res: resolution is 0.000000001
(D)get_res: smallest delta is 0.000000030
(D)get_res: largest delta is 0.000000100
(D)set_resolution: ts 0.000000030, digits 8, nsecs 10

> order of magnitude to get into the sub‑nanosecond range. Even if the
> CPU was so fast that it could read and convert the TSC counter in less
> than a nanosecond, there is no POSIX API to return the timestamp in a
> sub‑nanosecond resolution.
> 
> I guess for hardware clocks (e.g. NICs that support hardware
> timestamping) a sub‑nanosecond resolution might be needed sooner than
> for the system clock.
> 
> NTP has a 1/4ns resolution. For the White Rabbit that might not be
> good enough. For synchronizing ordinary computers (in financial
> industry or other) I think that will be sufficient for quite some
> time. In any case, a correction extension field (which will need to be
> supported in switches/routers in order to get a sub‑nanosecond
> accuracy) can have a better resolution than the timestamps in the NTP
> header.
> 
>> So before claiming that financial industry needs sub‑nanosecond
resolution,
>> I'd like to see hard facts and details.
> 
> FWIW, I have not heard anyone asking for a sub‑nanosecond resolution
> yet. The accuracy of the clock is a bigger issue.
> 
>> The other thing is: How small would the stability of the clock have to be
to
>> make any sub‑nanosecond resolution be realistic? 0.001 PPM?
>> Real "normal" servers will probably have 1 PPM, and a "certified 
> chronograph"
>> will allow around 50 PPM (AFAIK)...
> 
> For sub‑nanosecond stability with an ordinary computer clock, the
> update interval would need to very short, e.g. few milliseconds.
> 
> In a test I did with two directly connected idle computers and a
> polling interval of ‑6 (using the interleaved mode), the reported
> stability was just a few nanoseconds. With a shorter interval it might
> be possible to get it under 1 nanosecond, but I'm not sure what would
> be the point when the precision and accuracy of the clock is in tens
> nanoseconds at best.

My guess is that your oscillator was much better than standard, TCXO and OCXO,
or you have a very stable temperature around.

Regards,
Ulrich