Re: pg_test_timing: fix unit typo and widen diff type

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: "wang(dot)xiao(dot)peng" <wxp_728(at)163(dot)com>, lukas(at)fittl(dot)com, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hannu Krosing <hannuk(at)google(dot)com>
Subject: Re: pg_test_timing: fix unit typo and widen diff type
Date: 2026-04-23 02:02:31
Message-ID: 21E668C0-CEAE-44F8-B585-319F31883AFE@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Apr 23, 2026, at 00:11, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> On Wed, Apr 22, 2026 at 5:58 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>> PFA v4:
>>
>> * 0001 unchanged from v3.
>> * 0002 changed size of histogram[] 64.
>
> Thanks for updating the patch!
>
> Since patch 0001 is a bug fix, it should be backpatched to the supported stable
> branches. However, in v19 the unit should be changed like s/ms/ns, while in v18
> and earlier s/ms/us, since those older branches report the diff in microseconds.
> Right?

I just checked old branches. Looks like 0001 can be back-patched down to v10. Yes, pre-19, all branches use microsecond, so the back-patch should change “ms” to “us”.

I have helped create back-patch diff files as attached:

* nocfbot.v10-v13.pg_test_timing-backpatch.diff for v10-v13
* nocfbot.v14-v15.pg_test_timing-backpatch.diff for v14-v15
* nocfbot.v16-v18.pg_test_timing-backpatch.diff for v16-v18

For v16 to v18, we can make a tiny improvement by replacing “1e9” with a constant macro NS_PER_S. This change has been included in the diff.

I have built and tested on all branches.

>
> Patch 0002 looks more like an improvement than a bug fix, so we should probably
> wait for the next CommitFest before committing it. Thoughts?
>

I see 0002 a bit differently. In v19, the unit changed from microseconds to nanoseconds, which introduced a potential overflow: nanoseconds require int64, but the local variable remained int32. So I think this is actually a v19-only bug.

PFA v5: 0001 replaced “1e9” with NS_PER_S; 0002 unchanged.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
nocfbot.v10-v13.pg_test_timing-backpatch.diff application/octet-stream 488 bytes
nocfbot.v14-v15.pg_test_timing-backpatch.diff application/octet-stream 495 bytes
nocfbot.v16-v18.pg_test_timing-backpatch.diff application/octet-stream 806 bytes
v5-0001-pg_test_timing-fix-unit-in-backward-clock-warning.patch application/octet-stream 1.7 KB
v5-0002-pg_test_timing-use-int64-for-largest-observed-tim.patch application/octet-stream 3.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Haibo Yan 2026-04-23 02:25:55 Re: Implement missing join selectivity estimation for range types
Previous Message Peter Smith 2026-04-23 02:00:31 Re: Parallel Apply