Re: Fixing MSVC's inability to detect elog(ERROR) does not return

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fixing MSVC's inability to detect elog(ERROR) does not return
Date: 2025-09-02 02:57:21
Message-ID: CAApHDvpZyaTcyjrQ0cYxusJe6M=6QrmfZHue=Q1=7+ZpWymHHA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 24 Jul 2025 at 23:03, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> Please review my patch at
>
> https://www.postgresql.org/message-id/ccb273c9-7544-4748-8638-30feba212e6e@eisentraut.org
> https://commitfest.postgresql.org/patch/5934/

Now that we're building with C11, here's a rebased patch with the new
pg_builtin_constant() macro.

I did some study into the code generation with the patched version. I
see that errstart_cold() is being used correctly when the elevel is >=
ERROR. Unfortunately, MSVC does not seem to have anything like
__attribute__((cold)), so that does nothing different than what
errstart() does.

I also looked at the size of postgres.exe to see if the code
generation had improved due to ereport_domain's __assume(0) being
correctly picked up now. I was surprised to see that the binary had
increased in size by about 13K:

master: 10147840 bytes.
patched: 10161152 bytes.

Most of this extra seems to come from the errstart_cold function, as
if I adjust ereport_domain with:

- errstart_cold(elevel, domain) : \
+ errstart(elevel, domain) : \

The size is 10149888 bytes, or 2k more than master.

The reason I looked into this is because I wanted to check MSVC was
correctly eliminating the errstart_code / errstart ternary condition.
It does. I'm not sure where the extra 2k comes from, however.

I'm unable to detect any performance differences running pgbench -M
prepared -T 60 -S or with pgbench -M simple -T 60 -S.

David

Attachment Content-Type Size
v4-0001-Detect-elog-ERROR-can-t-return-in-MSVC-when-using.patch application/octet-stream 4.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-09-02 02:59:39 Re: SQL:2023 JSON simplified accessor support
Previous Message Chao Li 2025-09-02 02:46:35 Re: SQL:2023 JSON simplified accessor support