Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings.. - Mailing list pgsql-hackers

From David Rowley
Subject Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings..
Date
Msg-id CAApHDvokeTiu5qgd1Vr0gA13BHwNX45=5JfJZiCzwEe32Qi7dg@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings..  (Michael Paquier <michael@paquier.xyz>)
Responses Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings..  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On Tue, 4 Aug 2020 at 19:36, Michael Paquier <michael@paquier.xyz> wrote:
> Did you check if our implementation of src/port/snprintf.c makes %*s
> much slower than %s or not?  FWIW, I have just run a small test on my
> laptop, and running 100M calls of snprintf() with "%s" in a tight loop
> takes 2.7s, with "%*s" and a padding of 0 it takes 4.2s.  So this test
> tells that we are far from something that's substantially slower, and
> to simplify the code your change makes sense.  Still, there could be a
> point in keeping this optimization, but fix the comment to remove the
> platform-dependent part of it.  Any thoughts?

It's not just converting "%s" to "%*s", it's sometimes changing a
appendStringInfoString() call to appendStringInfo(). It's hard to
imagine the formatting version could ever be as fast as
appendStringInfo().

FWIW, the tests I did to check this when initially working on it are
in [1].  Justin, it would be good if you could verify you're making as
bad as what's mentioned on that thread again.

David

[1]
https://www.postgresql.org/message-id/flat/20130924165104.GQ4832%40eldon.alvh.no-ip.org#4e8a716ff0bde1e950fe7ddca1d75454



pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: SSL TAP test fails due to default client certs.
Next
From: Asim Praveen
Date:
Subject: Re: [PATCH] - Provide robust alternatives for replace_string