Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJaST-005jpQ-IO for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2024 15:09:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sJaSR-00F1TC-1S for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2024 15:09:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJaSQ-00F1Sy-LR for pgsql-hackers@lists.postgresql.org; Tue, 18 Jun 2024 15:09:15 +0000 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJaSP-002Iph-As for pgsql-hackers@postgresql.org; Tue, 18 Jun 2024 15:09:14 +0000 Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-443580f290dso316471cf.1 for ; Tue, 18 Jun 2024 08:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718723351; x=1719328151; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dMQkRPoEdXRioBAJSarJwh/UE3UtmcCFpQEOQIOiOoE=; b=RaTGMn72EYHVTsnKwUM6NoAnTicTxYw2cjjSNK9peHn6W+vZDSD15tSNTmnUuNOo3o EXprycD8zoVIvIhkpQSUSk45XbiDI01viyMqF8hY5IfkSGvQaprTXcYW+NfsFOAA04zt 4erandtpvm352mD+WxHmdVj1pv3LQPAVFeQ5Vjnpl35OHfMEzq2EWVr14wlnrmtQFndT Jy+68IbjRlQtki6QerzTaSwfdrpyIJ4LmUsql4Mr9ZOEFGs1mO7Z7syHpzUkv6jUC+lp XyF2hxeSHBwUdMCMKCcskJFbzeslKtqC1fh0KTkgxGgxujd/093WcJNo8abYhrjiUOiV LC7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718723351; x=1719328151; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dMQkRPoEdXRioBAJSarJwh/UE3UtmcCFpQEOQIOiOoE=; b=CSHOiVr+T5jPcGSgfkEYI4jy7p+QMXjpsdmcW+d0+ZEm3jwdpJoXaC0ZX3YUn+2wyR YsO6q5cBYG/HDFmgN3txoOwBOILdI+vYoC8eJZ06Cq6xEa0QkrwB+HlMv++Yx0krPvBe ttYKWYOjsKwNlgL/I72RJguzjI9tNAzOgfj3d00oWxk/awz9B21quHpKsliK02SEoQQt DJey1aVwIrKwQmhEZI1ADOdqWp0+m6TS+pBot7k6NqROqB6pKOpGkUNqZJVparkmKtjC 5vJlp62saGZx5lhSocHE0Qsx1Saq6DoWskzz7WgJNDH9pEt87LfBvfCZmxZ4cus4NB88 Ulpw== X-Forwarded-Encrypted: i=1; AJvYcCU6w4ISVV8ZHp8pLEvtaGEPBTOalgXls4KhmJ/q2kHg5APLTDWFtOia+UG9RwpKRt33S/bR8KGMlu4HoWqPlpzJAll1Ng077jOgwaRC X-Gm-Message-State: AOJu0YyuQkA32IioIbMo5kxypdSl6uZVd7yKF4ql1rL+ACsSkyKA3j0t QvPvIYLNxkHCeplPXbSdjzRMeN8v2QXNrqVVJXbdm89zjPzSkYvWUQtxs4zX9lFvz4yP4Lr8b2A igoBems461+bV4YeEJ9NfIEsBMdDHjetz9Ecm X-Google-Smtp-Source: AGHT+IHhLmSxtvfG7COplZUIj03wkTD+nfmLVZ+QiwMAdVETjVQOvkNfrKH3pX1e/U2zu68sIZdcHqg6JFhmMT/Ur9o= X-Received: by 2002:ac8:7d84:0:b0:444:97b7:e3b1 with SMTP id d75a77b69052e-4449da892fbmr3209081cf.13.1718723351223; Tue, 18 Jun 2024 08:09:11 -0700 (PDT) MIME-Version: 1.0 References: <47AEACEE-E5CC-40E4-8611-01F3A465AF16@yandex-team.ru> In-Reply-To: <47AEACEE-E5CC-40E4-8611-01F3A465AF16@yandex-team.ru> From: Hannu Krosing Date: Tue, 18 Jun 2024 17:08:57 +0200 Message-ID: Subject: Re: What is a typical precision of gettimeofday()? To: "Andrey M. Borodin" Cc: Peter Eisentraut , Ants Aasma , gregsmithpgsql@gmail.com, pgsql-hackers Content-Type: multipart/alternative; boundary="000000000000d1a092061b2b7673" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d1a092061b2b7673 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I plan to send patch to pg_test_timing in a day or two the underlying time precision on modern linux seems to be 2 ns for some Intel CPUs 10 ns for Zen4 40 ns for ARM (Ampere) --- Hannu | On Tue, Jun 18, 2024 at 7:48=E2=80=AFAM Andrey M. Borodin wrote: > > > > On 19 Mar 2024, at 13:28, Peter Eisentraut wrote= : > > > > I feel that we don't actually have any information about this > portability concern. Does anyone know what precision we can expect from > gettimeofday()? Can we expect the full microsecond precision usually? > > At PGConf.dev Hannu Krossing draw attention to pg_test_timing module. I= =E2=80=99ve > tried this module(slightly modified to measure nanoseconds) on some > systems, and everywhere I found ~100ns resolution (95% of ticks fall into > 64ns and 128ns buckets). > > I=E2=80=99ll add cc Hannu, and also pg_test_timing module authors Ants an= g Greg. > Maybe they can add some context. > > > Best regards, Andrey Borodin. --000000000000d1a092061b2b7673 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I plan to send patch to pg_test_timing in a day or two=C2= =A0

the underlying time precision on modern linux seems to be
2 ns for some Intel CPUs
10 ns for Zen4
40 ns for ARM (Ampere)
---
Hannu



|


=C2=A0

On Tue, Jun 18, 202= 4 at 7:48=E2=80=AFAM Andrey M. Borodin <x4mmm@yandex-team.ru> wrote:


> On 19 Mar 2024, at 13:28, Peter Eisentraut <peter@eisentraut.org> wrote:
>
> I feel that we don't actually have any information about this port= ability concern.=C2=A0 Does anyone know what precision we can expect from g= ettimeofday()?=C2=A0 Can we expect the full microsecond precision usually?<= br>
At PGConf.dev Hannu Krossing draw attention to pg_test_timing module. I=E2= =80=99ve tried this module(slightly modified to measure nanoseconds) on som= e systems, and everywhere I found ~100ns resolution (95% of ticks fall into= 64ns and 128ns buckets).

I=E2=80=99ll add cc Hannu, and also pg_test_timing module authors Ants ang = Greg. Maybe they can add some context.


Best regards, Andrey Borodin.
--000000000000d1a092061b2b7673--