From: | John Naylor <johncnaylorls(at)gmail(dot)com> |
---|---|
To: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
Cc: | li(dot)evan(dot)chao(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Raw parse tree is not dumped to log |
Date: | 2025-09-01 09:40:05 |
Message-ID: | CANWCAZbLjkDigNRqqobFfbtYxmnXbXEej=jNPvD9xKnxsomZNw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Sep 1, 2025 at 8:13 AM Tatsuo Ishii <ishii(at)postgresql(dot)org> wrote:
>
> > Branch alignment surely shouldn't matter in a function that is called
> > once per query?
>
> According to my test, it seems using unlikely() makes a small but
> non-negligible performance improvement over the code without
> unlikely() for small queries.
>
> Test method: Apply the latest patch (it needs rebasing) to master.
> Disable debug_print_raw_parse. Run pgbench with following arguments:
>
> $ pgbench -c 10 -j 10 -f bench.sql -T 60 test
> cat bench.sql
> SELECT 1;
>
> I ran pgbench 3 times and here's the results:
>
> case 1: with patch (unlikely() is used)
> tps = 63279.645198 (without initial connection time)
> tps = 62385.016698 (without initial connection time)
> tps = 62950.431703 (without initial connection time)
> average: 62871.697866
>
> case 2: with patch (unlikely() is not used)
> tps = 62462.798551 (without initial connection time)
> tps = 63085.646278 (without initial connection time)
> tps = 61361.373551 (without initial connection time)
> average: 62303.272793
>
> case 1 (62871.697866) / case 2 (62303.272793) = 1.009213
>
> It seems case 1 (unlikely() is used) is about 0.9% faster than case
> 2
The individual runs have quite a bit of variation.
It's good to cross check results against known facts. If my napkin
math is right, a ~1% speedup for ~60ktps/s amounts to saving ~160ns
per query. It's not plausible that forcing the compiler's hand for
this branch would save several hundred clock cycles.
To be fair I tried to reproduce and found only noise-level differences:
master: 61553
case 1: 61423
case 2: 61647
--
John Naylor
Amazon Web Services
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Jones | 2025-09-01 10:12:57 | Re: COPY TO: provide hint when WHERE clause is used |
Previous Message | Amul Sul | 2025-09-01 09:35:16 | Refactoring: Use soft error reporting for *_opt_error functions |