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.96) (envelope-from ) id 1wFTPX-005ANK-1i for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 08:58:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFTPW-00CYSF-2D for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 08:58:18 +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.96) (envelope-from ) id 1wFTPW-00CYS7-0p for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 08:58:18 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFTPT-00000002Rdf-3urn for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 08:58:17 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-c70f91776fcso2012535a12.0 for ; Wed, 22 Apr 2026 01:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776848293; x=1777453093; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=4AfoKKq+6F1tFbsi0eCpZnsA78q5znjlBCQBwUccCgo=; b=ZCpw28IUxG77exAccqD9Y94j/JcxX6//oCYgbadep+V20C3MInX0w67b3mWntk5a+I zibcm72U5ZOUt7Ul2Xb1MT5Q1jKTs4CJmf/JZzdqSuLnnAFOmO+3S27Lo9Jb4cpWCXG6 8y8Sy3EFhMVg723unjYVpPohyaj+c4hpvtbHOadyQuR0R7fu0xmK/r5shTBctdAgOAGV 4+aKjC+zJIj49tlohvuqCyet59AeiTF9zMdOWUy1uUCJMBHwOk2sry9MEDiKIjNapQUX 3Xu5qKkgeOaHCMwBDrQgXEnCnvVt78MvhUMp2OlxkYVd16icMIKxly3hd+xQfNXUXXr8 iRVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776848293; x=1777453093; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4AfoKKq+6F1tFbsi0eCpZnsA78q5znjlBCQBwUccCgo=; b=b09sOg+50/8hq9OwE8xt7IpYsCul/heH1VhUuDxfTqTz7KS4DN+xBgATQN4+anCSZR GLWYH+Gr7Vd+1bxRVDNBXZoarSGWYMO462Igsm5NHu0CGBsPx1KAGQkkLqiABWVK8Jgy DgGhyLyBMA67/Kkm42lP76rWg6DWr8Dg42lNPsaJyPug7mkNYnBXbVCELOpFF1pzj7nc nNRDQroprhok8tVc2lhRl//6GcQU8S06eCIgdE6v2gWpKEpSzatkcftDGlKpUuATBHeS tqxKXbRgumbfNfMStHpT3DtJwiO5oblMLGYjUV91Bqfwv5UT7sazeyW4HiPGEmVlWkyW YW3A== X-Forwarded-Encrypted: i=1; AFNElJ/iaQSa77PpVvupjXgtYwkoYL7henhuz3sLTlMQ4M+JkiyfLEITI7a91yNmC/kR305WBBIwELePQGMELoHG@lists.postgresql.org X-Gm-Message-State: AOJu0YyVOk4Uckeghz7myzZGgYKhUG7L9eNJ4mToBBT93n/z5g0v9KJI 4McUkJXUZHR7h0jbREBde/SqKdS3Z/pNkcgXuSDUaADDKgfKpngO9Jh4 X-Gm-Gg: AeBDiesH8Qoi1FsJXqlwZt/qod8l30tcSH7lfFslx7vgyF6qYvR+mCTDBWLG5IqMQdH Le7LbI3AuXD7huW06HcMSKKPdGiSQvKRJrVua2yi0LYi0wW7rVAEkn+emuH/ScUEQIrxq7lvvfX W1on8zkXVFfJEdWi9y4RS0aAJ0JoX7GPqTN4ehgWeMUMQ7LnS0GnZgNpC8cSTJohVxq0824JQFg 67ftWpoWvYh/uYUMsGmp3eZNjqwVdJt21rEDbDeAxk+PNnWPRgRNenIUhoNK2/QoyFiGhjiWbyW +Qsc5LE/kkqr+HlxAJOuSSVNDXfYc2e8XNvVGTWWskKSLivZ8Qul0SZD2XQYs+oTUMXCJlb0zaC PIlKt+iNb89blgERuQVdjegmsfqd2dCpgUXKhcs6vyrwXQIHKWCht9VoLmVWfW0NTAFpJhhkKAt 5eE9sEC6apXNB8BrHgcvy1Jup2UEWz62DrJrhVFQ2c+fdybDBAVBok X-Received: by 2002:a05:6a20:9146:b0:3a2:d79c:415d with SMTP id adf61e73a8af0-3a2d79c436bmr10087369637.30.1776848293301; Wed, 22 Apr 2026 01:58:13 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7976f8f4e8sm12268673a12.1.2026.04.22.01.58.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2026 01:58:12 -0700 (PDT) From: Chao Li Message-Id: <56B09FF0-13AB-4AF3-A4C4-29428A695FB0@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_7AEAD896-3818-4D56-9437-B46AB480B8B1" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: pg_test_timing: fix unit typo and widen diff type Date: Wed, 22 Apr 2026 16:57:32 +0800 In-Reply-To: Cc: "wang.xiao.peng" , lukas@fittl.com, PostgreSQL Hackers , Tom Lane , Hannu Krosing To: Fujii Masao References: <7d4afbdb.5322.19d70df0de4.Coremail.wxp_728@163.com> X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_7AEAD896-3818-4D56-9437-B46AB480B8B1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Apr 22, 2026, at 15:04, Fujii Masao wrote: >=20 > On Thu, Apr 9, 2026 at 3:13=E2=80=AFPM wang.xiao.peng = wrote: >> Just finished reviewing the v3 patches - looks good to me. The = pg_leftmost_one_pos64 fix is spot on, and using INT64_FORMAT for the = error message is the right approach. >=20 > Since pg_leftmost_one_pos64() can return up to 63, should the size of > histogram[] be changed from 32 to 64? If we want to display the full > histogram[] in the output, max_bit in output() would also need to be = set to 63. > Alternatively, it may be fine to keep max_bit =3D 31 and show only > the first 32 histogram entries. I revisited this patch and think it makes sense to extend histogram[] to = 64 entries. In practice, the higher buckets will almost always remain zero, and = output() already omits trailing histogram entries with zero counts, so = this change is unlikely to affect the actual runtime output in normal = cases. Accordingly, I also adjusted the minimum width of the first column, = since the maximum int64 value has 19 digits, and updated the printf = format accordingly. >=20 > Patch 0001 looks good to me. Cool. PFA v4: * 0001 unchanged from v3. * 0002 changed size of histogram[] 64. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_7AEAD896-3818-4D56-9437-B46AB480B8B1 Content-Disposition: attachment; filename=v4-0001-pg_test_timing-fix-unit-in-backward-clock-warning.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v4-0001-pg_test_timing-fix-unit-in-backward-clock-warning.patch" Content-Transfer-Encoding: quoted-printable =46rom=20f977c49219a708f7bec0f15d0250dc8554584639=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Thu,=202=20Apr=202026=2010:21:40=20+0800=0ASubject:=20[PATCH=20= v4=201/2]=20pg_test_timing:=20fix=20unit=20in=20backward-clock=20warning=0A= =0Apg_test_timing=20measures=20timing=20differences=20in=20nanoseconds=20= via=0AINSTR_TIME_GET_NANOSEC(),=20but=20the=20backward-clock=20warning=20= incorrectly=0Areported=20the=20value=20as=20milliseconds.=20Fix=20the=20= message=20to=20use=20"ns"=20so=0Athat=20it=20matches=20the=20actual=20= unit=20of=20diff.=0A=0AAuthor:=20Chao=20Li=20=0A= Reviewed-by:=20Lukas=20Fittl=20=0AReviewed-by:=20Fujii=20= Masao=20=0ADiscussion:=20= https://postgr.es/m/F780CEEB-A237-4302-9F55-60E9D8B6533D@gmail.com=0A---=0A= =20src/bin/pg_test_timing/pg_test_timing.c=20|=202=20+-=0A=201=20file=20= changed,=201=20insertion(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/src/bin/pg_test_timing/pg_test_timing.c=20= b/src/bin/pg_test_timing/pg_test_timing.c=0Aindex=20= 2afb0e6a410..944b25df1f2=20100644=0A---=20= a/src/bin/pg_test_timing/pg_test_timing.c=0A+++=20= b/src/bin/pg_test_timing/pg_test_timing.c=0A@@=20-281,7=20+281,7=20@@=20= test_timing(unsigned=20int=20duration,=20TimingClockSourceType=20source,=20= bool=20fast_timin=0A=20=09=09if=20(unlikely(diff=20<=200))=0A=20=09=09{=0A= =20=09=09=09fprintf(stderr,=20_("Detected=20clock=20going=20backwards=20= in=20time.\n"));=0A-=09=09=09fprintf(stderr,=20_("Time=20warp:=20%d=20= ms\n"),=20diff);=0A+=09=09=09fprintf(stderr,=20_("Time=20warp:=20%d=20= ns\n"),=20diff);=0A=20=09=09=09exit(1);=0A=20=09=09}=0A=20=0A--=20=0A= 2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_7AEAD896-3818-4D56-9437-B46AB480B8B1 Content-Disposition: attachment; filename=v4-0002-pg_test_timing-use-int64-for-largest-observed-tim.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v4-0002-pg_test_timing-use-int64-for-largest-observed-tim.patch" Content-Transfer-Encoding: quoted-printable =46rom=20d8f053cba2221b365317d3dbf8642cf28cefac72=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Thu,=202=20Apr=202026=2010:29:06=20+0800=0ASubject:=20[PATCH=20= v4=202/2]=20pg_test_timing:=20use=20int64=20for=20largest=20observed=20= time=0A=20delta=0A=0Apg_test_timing=20obtains=20timing=20deltas=20with=20= INSTR_TIME_GET_NANOSEC(),=0Awhich=20returns=20a=20nanosecond=20value=20= that=20should=20be=20stored=20in=20int64.=20Adjust=0Adiff=20and=20= largest_diff=20to=20use=20int64=20accordingly.=0A=0AAlso=20fix=20the=20= corresponding=20printf=20format=20specifiers=20so=20these=20values=20are=0A= printed=20correctly.=0A=0AAuthor:=20Chao=20Li=20=0A= Reviewed-by:=20Lukas=20Fittl=20=0AReviewed-by:=20Fujii=20= Masao=20=0ADiscussion:=20= https://postgr.es/m/F780CEEB-A237-4302-9F55-60E9D8B6533D@gmail.com=0A---=0A= =20src/bin/pg_test_timing/pg_test_timing.c=20|=2028=20= ++++++++++++++-----------=0A=201=20file=20changed,=2016=20insertions(+),=20= 12=20deletions(-)=0A=0Adiff=20--git=20= a/src/bin/pg_test_timing/pg_test_timing.c=20= b/src/bin/pg_test_timing/pg_test_timing.c=0Aindex=20= 944b25df1f2..530347a9aa5=20100644=0A---=20= a/src/bin/pg_test_timing/pg_test_timing.c=0A+++=20= b/src/bin/pg_test_timing/pg_test_timing.c=0A@@=20-18,14=20+18,14=20@@=20= static=20unsigned=20int=20test_duration=20=3D=203;=0A=20static=20double=20= max_rprct=20=3D=2099.99;=0A=20=0A=20/*=20record=20duration=20in=20powers=20= of=202=20nanoseconds=20*/=0A-static=20long=20long=20int=20histogram[32];=0A= +static=20long=20long=20int=20histogram[64];=0A=20=0A=20/*=20record=20= counts=20of=20first=2010K=20durations=20directly=20*/=0A=20#define=20= NUM_DIRECT=2010000=0A=20static=20long=20long=20int=20= direct_histogram[NUM_DIRECT];=0A=20=0A=20/*=20separately=20record=20= highest=20observed=20duration=20*/=0A-static=20int32=20largest_diff;=0A= +static=20int64=20largest_diff;=0A=20static=20long=20long=20int=20= largest_diff_count;=0A=20=0A=20=0A@@=20-262,8=20+262,8=20@@=20= test_timing(unsigned=20int=20duration,=20TimingClockSourceType=20source,=20= bool=20fast_timin=0A=20=0A=20=09while=20(INSTR_TIME_GT(end_time,=20cur))=0A= =20=09{=0A-=09=09int32=09=09diff,=0A-=09=09=09=09=09bits;=0A+=09=09int64=09= =09diff;=0A+=09=09int32=09=09bits;=0A=20=09=09instr_time=09diff_time;=0A=20= =0A=20=09=09prev=20=3D=20cur;=0A@@=20-281,13=20+281,17=20@@=20= test_timing(unsigned=20int=20duration,=20TimingClockSourceType=20source,=20= bool=20fast_timin=0A=20=09=09if=20(unlikely(diff=20<=200))=0A=20=09=09{=0A= =20=09=09=09fprintf(stderr,=20_("Detected=20clock=20going=20backwards=20= in=20time.\n"));=0A-=09=09=09fprintf(stderr,=20_("Time=20warp:=20%d=20= ns\n"),=20diff);=0A+=09=09=09fprintf(stderr,=20_("Time=20warp:=20"=20= INT64_FORMAT=20"=20ns\n"),=20diff);=0A=20=09=09=09exit(1);=0A=20=09=09}=0A= =20=0A=20=09=09/*=20What=20is=20the=20highest=20bit=20in=20the=20time=20= diff?=20*/=0A=20=09=09if=20(diff=20>=200)=0A-=09=09=09bits=20=3D=20= pg_leftmost_one_pos32(diff)=20+=201;=0A+=09=09{=0A+=09=09=09bits=20=3D=20= pg_leftmost_one_pos64(diff)=20+=201;=0A+=09=09=09/*=20histogram=20should=20= be=20define=20large=20enough=20*/=0A+=09=09=09Assert(bits=20<=20= lengthof(histogram));=0A+=09=09}=0A=20=09=09else=0A=20=09=09=09bits=20=3D=20= 0;=0A=20=0A@@=20-324,7=20+328,7=20@@=20test_timing(unsigned=20int=20= duration,=20TimingClockSourceType=20source,=20bool=20fast_timin=0A=20= static=20void=0A=20output(uint64=20loop_count)=0A=20{=0A-=09int=09=09=09= max_bit=20=3D=2031;=0A+=09int=09=09=09max_bit=20=3D=20= lengthof(histogram)=20-=201;=0A=20=09const=20char=20*header1=20=3D=20= _("<=3D=20ns");=0A=20=09const=20char=20*header1b=20=3D=20_("ns");=0A=20=09= const=20char=20*header2=20=3D=20/*=20xgettext:no-c-format=20*/=20_("%=20= of=20total");=0A@@=20-342,7=20+346,7=20@@=20output(uint64=20loop_count)=0A= =20=09=09max_bit--;=0A=20=0A=20=09/*=20set=20minimum=20column=20widths=20= */=0A-=09len1=20=3D=20Max(8,=20len1);=0A+=09len1=20=3D=20Max(19,=20= len1);=0A=20=09len2=20=3D=20Max(10,=20len2);=0A=20=09len3=20=3D=20= Max(10,=20len3);=0A=20=09len4=20=3D=20Max(10,=20len4);=0A@@=20-360,8=20= +364,8=20@@=20output(uint64=20loop_count)=0A=20=09=09double=09=09prct=20= =3D=20(double)=20histogram[i]=20*=20100=20/=20loop_count;=0A=20=0A=20=09=09= rprct=20+=3D=20prct;=0A-=09=09printf("%*ld=20=20=20%*.4f=20%*.4f=20= %*lld\n",=0A-=09=09=09=20=20=20len1,=20(1L=20<<=20i)=20-=201,=0A+=09=09= printf("%*llu=20=20=20%*.4f=20%*.4f=20%*lld\n",=0A+=09=09=09=20=20=20= len1,=20(1ULL=20<<=20i)=20-=201,=0A=20=09=09=09=20=20=20len2,=20prct,=0A=20= =09=09=09=20=20=20len3,=20rprct,=0A=20=09=09=09=20=20=20len4,=20= histogram[i]);=0A@@=20-409,8=20+413,8=20@@=20output(uint64=20loop_count)=0A= =20=09=09double=09=09prct=20=3D=20(double)=20largest_diff_count=20*=20= 100=20/=20loop_count;=0A=20=0A=20=09=09printf("...\n");=0A-=09=09= printf("%*d=20=20=20%*.4f=20%*.4f=20%*lld\n",=0A-=09=09=09=20=20=20len1,=20= largest_diff,=0A+=09=09printf("%*lld=20=20=20%*.4f=20%*.4f=20%*lld\n",=0A= +=09=09=09=20=20=20len1,=20(long=20long)=20largest_diff,=0A=20=09=09=09=20= =20=20len2,=20prct,=0A=20=09=09=09=20=20=20len3,=20100.0,=0A=20=09=09=09=20= =20=20len4,=20largest_diff_count);=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A= =0A= --Apple-Mail=_7AEAD896-3818-4D56-9437-B46AB480B8B1--