Re: pg_test_timing: fix unit typo and widen diff type

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: "wang.xiao.peng" <wxp_728@163.com>, lukas@fittl.com, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Tom Lane <tgl@sss.pgh.pa.us>, Hannu Krosing <hannuk@google.com>
Date: 2026-04-23T02:02:31Z
Lists: pgsql-hackers

Attachments


> On Apr 23, 2026, at 00:11, Fujii Masao <masao.fujii@gmail.com> wrote:
> 
> On Wed, Apr 22, 2026 at 5:58 PM Chao Li <li.evan.chao@gmail.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/




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pg_test_timing: store timing deltas in int64

  2. pg_test_timing: fix unit in backward-clock warning