| Lists: | pgsql-hackers |
|---|
| From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | [PATCH v1] elog.c: Remove special case which avoided %*s format strings.. |
| Date: | 2020-08-03 04:59:48 |
| Message-ID: | 20200803045948.GB27754@telsasoft.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
..which should no longer be needed since it was a performance hack for specific
platform snprintf, which are no longer used.
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-elog.c-Remove-special-case-which-avoided-s-format.patch | text/x-diff | 9.4 KB |
| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings.. |
| Date: | 2020-08-04 07:35:55 |
| Message-ID: | 20200804073555.GE2091@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Sun, Aug 02, 2020 at 11:59:48PM -0500, Justin Pryzby wrote:
> ..which should no longer be needed since it was a performance hack for specific
> platform snprintf, which are no longer used.
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?
--
Michael
| From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings.. |
| Date: | 2020-08-04 09:06:16 |
| Message-ID: | CAApHDvokeTiu5qgd1Vr0gA13BHwNX45=5JfJZiCzwEe32Qi7dg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Tue, 4 Aug 2020 at 19:36, Michael Paquier <michael(at)paquier(dot)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
| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
| Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH v1] elog.c: Remove special case which avoided %*s format strings.. |
| Date: | 2020-08-05 08:22:52 |
| Message-ID: | 20200805081956.GF2091@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Lists: | pgsql-hackers |
On Tue, Aug 04, 2020 at 09:06:16PM +1200, David Rowley wrote:
> 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.
Ouch. Thanks for the reference. Indeed it looks that it would hurt
even with just a simple PL function.
--
Michael